Skip to content

Conversation

@timsaucer
Copy link
Member

Which issue does this PR close?

Rationale for this change

If we have a StreamingTable that has both physical sort expressions and projection, we will get errors when trying to execute the plan if the sort expressions are not included in the projection.

What changes are included in this PR?

When we have both projection and physical sort expressions, project the schema and the sort expressions.

Are these changes tested?

Unit test added.

Are there any user-facing changes?

No

@github-actions github-actions bot added core Core DataFusion crate catalog Related to the catalog crate labels Jan 9, 2026
@timsaucer timsaucer marked this pull request as ready for review January 9, 2026 20:11
Copy link
Contributor

@kosiew kosiew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 110 to 115
if let Some(p) = projection {
let schema = Arc::new(self.schema.project(p)?);
LexOrdering::new(original_sort_exprs)
.and_then(|lex_ordering| project_ordering(&lex_ordering, &schema))
.map(|lex_ordering| lex_ordering.to_vec())
.unwrap_or_default()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment explaining the projection adjustment will be helpful here

@alamb
Copy link
Contributor

alamb commented Jan 16, 2026

Shall we merge it?

Thank you for the review @kosiew

@timsaucer
Copy link
Member Author

Yes. I just pushed the requested code comments, and I'll merge after CI finishes.

@timsaucer timsaucer added this pull request to the merge queue Jan 16, 2026
@timsaucer
Copy link
Member Author

Thank you @kosiew and @alamb

Merged via the queue into apache:main with commit e353eb0 Jan 16, 2026
28 checks passed
@alamb
Copy link
Contributor

alamb commented Jan 16, 2026

🎉 -- keeping the code flowing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

catalog Related to the catalog crate core Core DataFusion crate

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StreamingTable does not project physical sort expressions

3 participants