Skip to content

Conversation

@mihaibudiu
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings December 28, 2025 18:32
@mihaibudiu mihaibudiu enabled auto-merge December 28, 2025 18:33
@mihaibudiu mihaibudiu requested review from abhizer, gz and ryzhyk December 28, 2025 18:33
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in the SQL compiler related to incorrect array casting behavior. The fix removes problematic special-case handling for empty arrays with DBSPTypeAny elements and improves cast expression handling in the Rust code generation backend.

Key Changes

  • Removed early-return optimization for empty array casts that was causing type inference failures
  • Enhanced compact mode cast expression generation to properly wrap casts with parentheses
  • Added regression test to prevent recurrence of the array cast bug

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
sql-to-dbsp-compiler/SQL-compiler/src/test/java/org/dbsp/sqlCompiler/compiler/sql/simple/Regression1Tests.java Added regression test issue5345() that verifies the array cast bug is fixed and removed unused @Ignore import
sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/visitors/inner/ExpandCasts.java Removed incorrect special-case handling for empty arrays with DBSPTypeAny elements during cast expansion
sql-to-dbsp-compiler/SQL-compiler/src/main/java/org/dbsp/sqlCompiler/compiler/backend/rust/ToRustInnerVisitor.java Added proper parenthesized cast syntax generation for compact mode instead of early return

Comment on lines +1277 to +1281
if (this.compact) {
this.builder.append("((")
.append(expression.type)
.append(")")
.append(expression.source)
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't seem like it produces valid rust. Is this compact format only for intermediate code / debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is only used for generating dot files right now.
some operations cannot even be synthesized as rust, but they should produce usable debugging output before they are converted into operations that can be synthesized as rust

DBSPTypeArray sourceVecType = sourceType.to(DBSPTypeArray.class);
// If the element type does not match, need to convert all elements
if (!type.getElementType().equals(sourceVecType.getElementType())) {
if (sourceVecType.getElementType().is(DBSPTypeAny.class)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the bug fix is here

@mihaibudiu mihaibudiu requested a review from blp December 30, 2025 07:01
@mihaibudiu mihaibudiu added this pull request to the merge queue Dec 30, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 30, 2025
Copy link
Member

@blp blp left a comment

Choose a reason for hiding this comment

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

I like fixing bugs by deleting code.

@mihaibudiu
Copy link
Contributor Author

Sorry to disappoint you @blp, I had to add some more code.
I will try to delete something else some other time.

@mihaibudiu
Copy link
Contributor Author

This is all due to a Calcite bug https://issues.apache.org/jira/browse/CALCITE-7347
In this PR I am working around it, but I plan to fix it.

@mihaibudiu mihaibudiu added this pull request to the merge queue Dec 30, 2025
Merged via the queue into main with commit f7432b3 Dec 30, 2025
1 check passed
@mihaibudiu mihaibudiu deleted the issue5345 branch December 30, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants