Skip to content

Conversation

@ygerzhedovich
Copy link
Contributor

@ygerzhedovich ygerzhedovich commented Dec 29, 2025

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:

    • Integration tests: Removed an ignored test flag for a previously skipped test case related to large IN statements.
    • RexToLixTranslator, RelJson, IgniteMdSelectivity, and ProjectableFilterableTableScan: Updated to integrate the newly introduced RexUtils methods for better processing of SEARCH and predicate handling logic.
  • Justifications:

    • Improvements aim to optimize query execution and reduce bytecode complexity.
    • The approach ensures more robust handling of nullable inputs in SQL operations.
  • 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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 expandSearchNullable and expandSearchNullableRecursive methods 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.expandSearch for 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants