ignite-15189 SQL: Optimized code generation for IN statement with lit…#7328
Open
ygerzhedovich wants to merge 2 commits intoapache:mainfrom
Open
ignite-15189 SQL: Optimized code generation for IN statement with lit…#7328ygerzhedovich wants to merge 2 commits intoapache:mainfrom
ygerzhedovich wants to merge 2 commits intoapache:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes code generation for SQL IN statements with literals by implementing a new null-handling strategy that reduces generated bytecode size. The optimization adds a NULL check before expanding SEARCH/SARG operators when the input is nullable, rather than checking for NULL on every comparison in the IN list.
Key changes:
- Introduces
expandSearchNullableandexpandSearchNullableRecursivemethods in RexUtils to handle SEARCH/SARG expansion with optimized NULL handling - Updates code generation paths (RexToLixTranslator, RelJson) to use the new optimized expansion
- Preserves original
RexUtil.expandSearchfor non-code-generation contexts like partition pruning and selectivity estimation - Fixes a test that was previously commented out due to the bytecode size issue
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/util/RexUtils.java | Adds new methods for SEARCH/SARG expansion with preceding NULL check optimization and SearchExpandingShuttle visitor |
| modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/exec/exp/RexToLixTranslator.java | Updates code generation to use optimized expandSearchNullable method |
| modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/externalize/RelJson.java | Updates JSON serialization to use optimized recursive expansion |
| modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/rel/ProjectableFilterableTableScan.java | Updates explain output to use optimized recursive expansion |
| modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/prepare/pruning/PartitionPruningMetadataExtractor.java | Adds explanatory comment for continuing to use original RexUtil.expandSearch |
| modules/sql-engine/src/main/java/org/apache/ignite/internal/sql/engine/metadata/IgniteMdSelectivity.java | Adds explanatory comment and imports RexUtil explicitly for clarity |
| modules/sql-engine/src/integrationTest/sql/group1/function/generic/test_large_in.test | Enables previously failing test and fixes expected NULL result ordering |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
https://issues.apache.org/jira/browse/IGNITE-25289
This pull request introduces enhancements to the handling and expansion of SEARCH/SARG operations for nullable inputs in the SQL engine, modifies SQL engine tests, and adjusts the usage of utility functions across various modules.
Core Updates:
Added new utility methods (expandSearchNullable and expandSearchNullableRecursive) in the RexUtils class to optimize the expansion process for nullable inputs, reducing redundant NULL checks in generated bytecode.
Replaced older RexUtil methods (e.g., expandSearch) with the updated RexUtils alternatives where necessary to improve performance and handle specific nullable cases.
Affected Components:
Justifications:
The main difference with the original patch is the absence of an optimization for JSON plan serialization. Due to this breaking invariance, what we have before serialization should be the same as what we have after deserialization.