Skip to content

feat: Support defining sort order in index hints - #2246

Open
ferenc-csaky wants to merge 1 commit into
mainfrom
feat/index-hint-customization
Open

feat: Support defining sort order in index hints#2246
ferenc-csaky wants to merge 1 commit into
mainfrom
feat/index-hint-customization

Conversation

@ferenc-csaky

Copy link
Copy Markdown
Collaborator

Summary

Adds sort-order support for JDBC index hints and propagates Calcite sort direction into generated B-tree index candidates.

Key Changes

  • Supports index hints such as /*+ index(BTREE, col_a DESC, col_b) */.
  • Adds index-column directions to IndexDefinition.
  • Adds sort metadata to QueryIndexSummary.
  • Preserves Calcite RelFieldCollation.Direction when selecting indexes for limited sorted queries.
  • Generates distinct index names for descending columns.
  • Emits DESC in PostgreSQL CREATE INDEX DDL.
  • Adds IndexType.supportsSortOrder() to centralize index capability checks.
  • Rejects descending columns for index types that do not support sort order.
  • Adds parser, index-selector, and PostgreSQL DDL tests.

@ferenc-csaky ferenc-csaky added the enhancement New feature or request label Jul 31, 2026
@ferenc-csaky ferenc-csaky added this to the 0.11.0 milestone Jul 31, 2026
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.78947% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.04%. Comparing base (d4123f8) to head (9365c48).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...n/java/com/datasqrl/plan/global/IndexSelector.java 0.00% 18 Missing ⚠️
...va/com/datasqrl/plan/global/QueryIndexSummary.java 7.14% 12 Missing and 1 partial ⚠️
...engine/database/relational/ddl/CreateIndexDDL.java 0.00% 8 Missing ⚠️
...java/com/datasqrl/plan/global/IndexDefinition.java 55.55% 7 Missing and 1 partial ⚠️
...main/java/com/datasqrl/planner/hint/IndexHint.java 76.66% 4 Missing and 3 partials ⚠️
.../database/relational/PostgresStatementFactory.java 0.00% 6 Missing ⚠️
.../main/java/com/datasqrl/plan/global/IndexType.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2246      +/-   ##
============================================
+ Coverage     18.28%   19.04%   +0.75%     
- Complexity     1133     1169      +36     
============================================
  Files           612      612              
  Lines         17828    17882      +54     
  Branches       2175     2183       +8     
============================================
+ Hits           3260     3405     +145     
+ Misses        14246    14129     -117     
- Partials        322      348      +26     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@ferenc-csaky
ferenc-csaky force-pushed the feat/index-hint-customization branch from d18f4c1 to 9365c48 Compare July 31, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant