Skip to content

Conversation

@songkant-aws
Copy link
Contributor

@songkant-aws songkant-aws commented Oct 9, 2025

Description

Fix the bug that Calcite will error out when CalciteRelBuilder explicitly calling makeNullLiteral for UDT type fields.

UDT type cast is handled by UDF. It's totally fine for CAST function, regardless whether the field value is NULL or non NULL. But for some cases in building RelNode, it has the problem of explicitly casting NULL to UDT type by RexBuilder.makeNullLiteral method. UDT cast is a RexCall of calling UDF, but makeNullLiteral internally expects the returned node to be RexLiteral of NULL. Thus, Calcite throws a hard error due to Java class casting failure.

This PR fixes this issue by adding a simple check and calling super method in case the RexNode to be cast is literally NULL.

Related Issues

Resolves #4383

Check List

  • New functionality includes testing.
  • New functionality has been documented.
  • New functionality has javadoc added.
  • New functionality has a user manual doc added.
  • New PPL command checklist all confirmed.
  • API changes companion pull request created.
  • Commits are signed per the DCO using --signoff or -s.
  • Public documentation issue/PR created.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@songkant-aws
Copy link
Contributor Author

cc @ahkcs @yuancu Please let me know if this simple fix can cover the issue.

@ahkcs
Copy link
Contributor

ahkcs commented Oct 9, 2025

Thanks for the fix! I think for #4383, it's more like an issue for long-term goals for multisearch command(can be applied to append command as well), so this PR might only partially resolve the issue

Content-Type: 'application/json'
ppl:
body:
query: source=log-test1 | append [ source=log-test2 ]
Copy link
Member

Choose a reason for hiding this comment

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

will source=log-test1 | append [ source=log-test2 ] | fields timestamp return - match: { datarows: [["2025-09-04 16:15:00"], [null]] }?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Synced offline. It will append unique name in case of type conflicts and select fields are also successful

@LantaoJin
Copy link
Member

Thanks for the fix! I think for #4383, it's more like an issue for long-term goals for multisearch command(can be applied to append command as well), so this PR might only partially resolve the issue

Is multisearch available? can you test that after this merged.

@LantaoJin LantaoJin added the bug Something isn't working label Oct 10, 2025
Copy link
Collaborator

@yuancu yuancu left a comment

Choose a reason for hiding this comment

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

LGTM

@songkant-aws
Copy link
Contributor Author

songkant-aws commented Oct 10, 2025

@ahkcs Makes sense. It's a short-term bug fix to not fail the query. 4383 wants to resolve another issue. I can create another report bug issue to avoid confusion

@yuancu yuancu merged commit 7d6357d into opensearch-project:main Oct 10, 2025
34 of 38 checks passed
@songkant-aws
Copy link
Contributor Author

@LantaoJin Tried the multisearch command. It also fixes the same issue in multisearch command.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Oct 10, 2025
Signed-off-by: Songkan Tang <[email protected]>
(cherry picked from commit 7d6357d)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
songkant-aws added a commit to songkant-aws/sql that referenced this pull request Oct 10, 2025
@songkant-aws songkant-aws deleted the udt-null-literal-fix branch October 10, 2025 05:48
LantaoJin pushed a commit that referenced this pull request Oct 10, 2025
(cherry picked from commit 7d6357d)

Signed-off-by: Songkan Tang <[email protected]>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
asifabashar pushed a commit to asifabashar/sql that referenced this pull request Oct 16, 2025
sandeshkr419 added a commit to sandeshkr419/sql that referenced this pull request Dec 3, 2025
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Simeon Widdis <[email protected]>
Co-authored-by: Manasvini B S <[email protected]>
Co-authored-by: opensearch-ci-bot <[email protected]>
Co-authored-by: Louis Chu <[email protected]>
Co-authored-by: Chen Dai <[email protected]>
Co-authored-by: Mebsina <[email protected]>
Co-authored-by: Yuanchun Shen <[email protected]>
Co-authored-by: opensearch-trigger-bot[bot] <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com>
Co-authored-by: Kai Huang <[email protected]>
Co-authored-by: Peng Huo <[email protected]>
Co-authored-by: Alexey Temnikov <[email protected]>
Co-authored-by: Riley Jerger <[email protected]>
Co-authored-by: Tomoyuki MORITA <[email protected]>
Co-authored-by: Lantao Jin <[email protected]>
Co-authored-by: Songkan Tang <[email protected]>
Co-authored-by: qianheng <[email protected]>
Co-authored-by: Simeon Widdis <[email protected]>
Co-authored-by: Xinyuan Lu <[email protected]>
Co-authored-by: Jialiang Liang <[email protected]>
Co-authored-by: Peter Zhu <[email protected]>
Co-authored-by: Vinay Krishna Pudyodu <[email protected]>
Co-authored-by: expani <[email protected]>
Co-authored-by: expani1729 <[email protected]>
Co-authored-by: Vamsi Manohar <[email protected]>
Co-authored-by: ritvibhatt <[email protected]>
Co-authored-by: Xinyu Hao <[email protected]>
Co-authored-by: Marc Handalian <[email protected]>
Co-authored-by: Marc Handalian <[email protected]>
Fix join type ambiguous issue when specify the join type with sql-like join criteria (opensearch-project#4474)
Fix issue 4441 (opensearch-project#4449)
Fix missing keywordsCanBeId (opensearch-project#4491)
Fix the bug of explicit makeNullLiteral for UDT fields (opensearch-project#4475)
Fix mapping after aggregation push down (opensearch-project#4500)
Fix percentile bug (opensearch-project#4539)
Fix JsonExtractAllFunctionIT failure (opensearch-project#4556)
Fix sort push down into agg after project already pushed (opensearch-project#4546)
Fix push down failure for min/max on derived field (opensearch-project#4572)
Fix compile issue in main (opensearch-project#4608)
Fix filter parsing failure on date fields with non-default format (opensearch-project#4616)
Fix bin nested fields issue (opensearch-project#4606)
Fix: Support Alias Fields in MIN, MAX, FIRST, LAST, and TAKE Aggregations (opensearch-project#4621)
fix rename issue (opensearch-project#4670)
Fixes for `Multisearch` and `Append` command (opensearch-project#4512)
Fix asc/desc keyword behavior for sort command (opensearch-project#4651)
Fix] Fix unexpected shift of extraction for `rex` with nested capture groups in named groups  (opensearch-project#4641)
Fix CVE-2025-48924 (opensearch-project#4665)
Fix sub-fields accessing of generated structs (opensearch-project#4683)
Fix] Incorrect Field Index Mapping in AVG to SUM/COUNT Conversion (opensearch-project#15)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport 2.19-dev bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC] Fix Type Conflict Schema Merging for Cross-Index Fields in Append and Multisearch Commands

4 participants