Skip to content

feat: Update to Calcite 1.41.0.#19370

Open
gianm wants to merge 4 commits intoapache:masterfrom
gianm:calcite-141s
Open

feat: Update to Calcite 1.41.0.#19370
gianm wants to merge 4 commits intoapache:masterfrom
gianm:calcite-141s

Conversation

@gianm
Copy link
Copy Markdown
Contributor

@gianm gianm commented Apr 23, 2026

Main changes:

  1. Refreshed Parser.jj using dev/upgrade-calcite-parser.

  2. Added DruidTypeCoercion to ensure array comparison works properly. We need to be able to coerce BOOLEAN arrays to numeric arrays.

  3. Update various toDruidQueryForExplaining implementations to use unique field names for their row signatures. This was a pre-existing bug that was triggered by new Calcite behavior.

  4. Update DruidJoinRule to add null gates when hoisting literals over full or left outer joins. This was a pre-existing bug that was triggered by new Calcite behavior.

  5. Update FilterDecomposeConcatRule to handle SEARCH.

  6. Add InlineValuesSubQueryRule, which is needed to avoid unplannable plans for certain queries mixing UNNEST and SELECT-FROM-VALUES.

  7. Add DruidStripUnionArmCastRule, which is needed to remove new CASTs that would otherwise prevent table-level unions from planning.

  8. Remove workarounds and negative tests for CALCITE-6435, CALCITE-6715, and CALCITE-6473.

  9. Add test to verify WEEK and QUARTER math work properly (CALCITE-6581).

Main changes:

1) Refreshed Parser.jj using dev/upgrade-calcite-parser.

2) Added DruidTypeCoercion to ensure array comparison works properly.
   We need to be able to coerce BOOLEAN arrays to numeric arrays.

3) Update various toDruidQueryForExplaining implementations to use
   unique field names for their row signatures. This was a pre-existing
   bug that was triggered by new Calcite behavior.

4) Update DruidJoinRule to add null gates when hoisting literals over
   full or left outer joins. This was a pre-existing bug that was
   triggered by new Calcite behavior.

5) Update FilterDecomposeConcatRule to handle SEARCH.

6) Add InlineValuesSubQueryRule, which is needed to avoid unplannable
   plans for certain queries mixing UNNEST and SELECT-FROM-VALUES.

7) Add DruidStripUnionArmCastRule, which is needed to remove new CASTs
   that would otherwise prevent table-level unions from planning.

8) Remove workarounds and negative tests for CALCITE-6435, CALCITE-6715,
   CALCITE-6435, and CALCITE-6473.

9) Add test to verify WEEK and QUARTER math work properly (CALCITE-6581).
@github-actions github-actions Bot added Area - Batch Ingestion Area - Querying Area - Dependencies Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 labels Apr 23, 2026

private DruidStripUnionArmCastRule()
{
super(operand(Union.class, any()));

private DruidStripUnionArmCastRule()
{
super(operand(Union.class, any()));
*/
public static RowSignature fromRelDataTypeWithUniqueFields(final RelDataType rowType)
{
return fromRelDataType(SqlValidatorUtil.uniquify(rowType.getFieldNames()), rowType);
@gianm
Copy link
Copy Markdown
Contributor Author

gianm commented Apr 24, 2026

This will fix #18665 as well.

final List<RelNode> newInputs = new ArrayList<>(union.getInputs().size());
boolean anyChanged = false;
for (final RelNode input : union.getInputs()) {
final RelNode arm = input.stripped();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

P1 Stripping union-arm casts can change native output types

stripArmCasts removes numeric casts from UNION ALL arms whenever the resulting union row type still equals the original row type. That planner-level equality does not guarantee the native Druid query still emits the same column type: removing a BIGINT-to-FLOAT or DECIMAL-to-DOUBLE cast lets the scan arm expose its underlying native type, and the union datasource can then mix arm output types or choose a different runtime type than the SQL row type promised. This can change query results or fail during native union execution. Keep the casts in a project above each arm, or prove the native union path preserves the SQL cast semantics before stripping them.

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

Labels

Area - Batch Ingestion Area - Dependencies Area - MSQ For multi stage queries - https://github.com/apache/druid/issues/12262 Area - Querying

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants