JamesIsHuang opened a new pull request, #61097:
URL: https://github.com/apache/doris/pull/61097
## Proposed changes
Issue Number: close #59692
Fix `RuntimeException("Not support comparison between JSONB literals")`
thrown by `JsonLiteral.compareLiteral()`, which causes queries using
`json_contains` to crash during FE optimization phases (filter estimation,
partition pruning).
### Changes:
- Fix legacy `JsonLiteral.compareLiteral()` to perform string-based
comparison instead of throwing RuntimeException.
- Make Nereids `JsonLiteral` implement `ComparableLiteral` interface with
`compareTo()` method.
- Add `JsonLiteralTest` covering both Nereids and legacy comparison behavior.
### Root Cause:
When executing queries like `SELECT JSON_CONTAINS(...)`, the FE optimizer's
filter estimation (`FilterEstimation`) or partition pruning
(`PartitionRangeExpander`) may call `toLegacyLiteral().compareTo()` on JSON
literals. The original `compareLiteral()` unconditionally threw
RuntimeException, crashing the query instead of allowing it to proceed to the
BE where `json_contains` is correctly implemented.
## Further comments
- SQL-level comparison predicate validation (`ComparisonPredicate`) still
correctly rejects direct JSON comparisons like `SELECT json_col = json_col` —
this fix only affects the internal FE optimization infrastructure.
- String-based comparison is acceptable for FE optimization use cases and
consistent with how `JsonLiteral` normalizes its string representation upon
construction.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]