[fix](json) fix RuntimeException when comparing JSONB literals#61097
Open
JamesIsHuang wants to merge 2 commits intoapache:masterfrom
Open
[fix](json) fix RuntimeException when comparing JSONB literals#61097JamesIsHuang wants to merge 2 commits intoapache:masterfrom
JamesIsHuang wants to merge 2 commits intoapache:masterfrom
Conversation
…e#59692) The legacy JsonLiteral.compareLiteral() threw RuntimeException("Not support comparison between JSONB literals"), causing queries with json_contains to crash during FE optimization (filter estimation, partition pruning). Changes: - Fix legacy JsonLiteral.compareLiteral() to perform string-based comparison instead of throwing RuntimeException. - Make Nereids JsonLiteral implement ComparableLiteral with compareTo() method. - Add JsonLiteralTest covering both Nereids and legacy comparison behavior. Made-with: Cursor
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
…vior Legacy compareLiteral() silently fell back to string comparison for non-JSON types, while Nereids correctly rejected cross-type comparison. Fix to handle PlaceHolderExpr, NullLiteral, MaxLiteral explicitly and throw RuntimeException for incompatible types. Made-with: Cursor
Author
|
run buildall |
TPC-H: Total hot run time: 27617 ms |
TPC-DS: Total hot run time: 153592 ms |
Contributor
FE UT Coverage ReportIncrement line coverage |
Contributor
FE Regression Coverage ReportIncrement line coverage |
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
Issue Number: close #59692
This PR addresses the remaining failure in reopened issue
#59692.The earlier incorrect-result cases for single
JSON_CONTAINScalls were already fixed by#53291. However, chained predicates such as:can still fail in FE with:
Root cause
During FE optimization phases such as filter estimation and partition pruning, JSON literals may be compared through legacy literal comparison paths. The legacy
JsonLiteral.compareLiteral()throwsRuntimeExceptionfor JSON literal comparisons, which aborts planning before execution reaches the BE wherejson_containsitself is handled correctly.Changes
JsonLiteral.compareLiteral()to support JSON literal comparison instead of throwing directly.JsonLiteralimplementComparableLiteralwithcompareTo().PlaceHolderExpr,NullLiteral, andMaxLiteral, and rejecting incompatible cross-type comparisons.JsonLiteralTestcovering both legacy and Nereids comparison behavior.Behavior
Before:
JSON_CONTAINSincorrect-result cases were already fixed by#53291.JSON_CONTAINSpredicates could still fail during FE optimization withNot support comparison between JSONB literals.After:
JSON_CONTAINSpredicates no longer fail because of JSON literal comparison in FE optimization.Further comments
json_col = json_col.JsonLiteralstores normalized string content and the goal is to avoid planner crashes rather than introduce new SQL-visible comparison semantics.