Skip to content

[CALCITE-7690] DELETE on a single-column table fails with "Cannot cast java.lang.Object to int" - #5150

Open
wasabii wants to merge 2 commits into
apache:mainfrom
wasabii:calcite-table-modify-delete-single-column
Open

[CALCITE-7690] DELETE on a single-column table fails with "Cannot cast java.lang.Object to int"#5150
wasabii wants to merge 2 commits into
apache:mainfrom
wasabii:calcite-table-modify-delete-single-column

Conversation

@wasabii

@wasabii wasabii commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

https://issues.apache.org/jira/browse/CALCITE-7690

DELETE on a single-column table generates (int) sinkRow from a sinkRow declared Object, because for
one column the table's Java row type is a primitive. javac accepts that cast; Janino does not, so the
generated code fails to compile.

Boxing the target type fixes it. Primitive.box leaves references unchanged, so the multi-column case is
unaffected.

Tests: ServerTest.testDeleteSingleColumn, testDeleteSingleObjectColumn and
testDeleteSingleNullableColumn. The tests added by [CALCITE-7510] are all two-column, so this shape was
never covered.

@mihaibudiu

Copy link
Copy Markdown
Contributor

Sometimes it's useful to have long descriptions of what's going on for short PRs, but I think in this case you are just wasting reviewer bandwidth. Can you please use shorter descriptions?

* type is a primitive. The generated sink key extractor must not cast
* Object to that primitive directly: Java allows such a cast but Janino,
* which compiles the generated code, does not implement it. */
@Test void testDeleteSingleColumn() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we have tests for columns which already have Object types, e.g., INT ARRAY?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this fails, you should figure out whether it's the same bug or another one. If it's another one, please file an issue. If it's the same one, maybe this is the place to fix it.

…t java.lang.Object to int"

EnumerableTableModify.deleteFromCollection casts the sink row, declared as
Object, to the table's Java row type. For a single-column table that type is
a primitive, so the generated code is "(int) sinkRow". javac accepts such a
cast; Janino does not.

Box the target type. Primitive.box leaves references unchanged, so the
multi-column case is unaffected.

Adds ServerTest.testDeleteSingleColumn, testDeleteSingleObjectColumn and
testDeleteSingleNullableColumn. The tests added by CALCITE-7510 are all
two-column, so this shape was never covered.
@wasabii
wasabii force-pushed the calcite-table-modify-delete-single-column branch from 99503c8 to c3c254a Compare August 4, 2026 23:44
@wasabii

wasabii commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

Shortened the description here and on the Jira, and cut the code comments down to a line or two. Thanks for the review.

@mihaibudiu

Copy link
Copy Markdown
Contributor

I think, as a rule, you should never submit something you haven't read entirely yourself, or something you would not have written yourself. It's fine to use a tool to write them, but you should treat the production as your own, and it should meet your personal quality standards.

@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

wasabii added a commit to ikvmnet/calcite-dotnet that referenced this pull request Aug 5, 2026
CALCITE-7690 and apache/calcite#5150 carry the one-line fix and two ServerTest
cases, verified against Calcite's build. When it reaches a snapshot the two
tests here go green untouched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
wasabii added a commit to ikvmnet/calcite-dotnet that referenced this pull request Aug 5, 2026
CALCITE-7690 and apache/calcite#5150 carry the one-line fix and two ServerTest
cases, verified against Calcite's build. When it reaches a snapshot the two
tests here go green untouched.
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.

2 participants