Skip to content

fix(sql): fix ASOF JOIN crash when ON clause has symbol and other columns#6634

Merged
bluestreak01 merged 7 commits intomasterfrom
jh_asof_on_single_symbol_and_other_type
Jan 13, 2026
Merged

fix(sql): fix ASOF JOIN crash when ON clause has symbol and other columns#6634
bluestreak01 merged 7 commits intomasterfrom
jh_asof_on_single_symbol_and_other_type

Conversation

@jerrinot
Copy link
Copy Markdown
Contributor

@jerrinot jerrinot commented Jan 13, 2026

ASOF JOIN queries with a symbol column AND another column in the ON clause would throw UnsupportedOperationException when using the Light join factory.

The single-symbol optimization was incorrectly applied when there were multiple join keys, creating a map that only supported INT keys while the record copier attempted to write all column types.

In some cases it does not crash, but it can silently return wrong results.

…umns

ASOF JOIN queries with a symbol column AND another column in the ON clause
would throw UnsupportedOperationException when using the Light join factory.

The single-symbol optimization was incorrectly applied when there were
multiple join keys, creating a map that only supported INT keys while
the record copier attempted to write all column types.
@jerrinot jerrinot added the Bug Incorrect or unexpected behavior label Jan 13, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 13, 2026

Walkthrough

A modification to the ASOF join optimization in SqlCodeGenerator tightens the fallback condition for single-symbol short-circuit optimization by requiring exactly one join key column on the master side. A corresponding test method is added to verify ASOF join behavior with symbol and timestamp columns.

Changes

Cohort / File(s) Summary
ASOF Join Optimization Logic
core/src/main/java/io/questdb/griffin/SqlCodeGenerator.java
Adds column count validation to the single-symbol join fallback condition; optimization now triggers only when listColumnFilterA.getColumnCount() == 1 && isSingleSymbolJoin(symbolShortCircuit) is true, affecting both keyed and non-keyed ASOF join paths
ASOF Join Test Coverage
core/src/test/java/io/questdb/test/griffin/engine/join/AsOfJoinTest.java
Adds test method testAsOfJoinWithSymbolAndTimestampInOnClause() to verify ASOF JOIN behavior with symbol and timestamp in ON clause; method appears to be declared twice (duplicate)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

SQL

Suggested reviewers

  • bluestreak01
  • puzpuzpuz
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: preventing ASOF JOIN crashes when the ON clause contains both symbol and other columns.
Description check ✅ Passed The pull request description clearly explains the bug, root cause, and fix related to ASOF JOIN optimization.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jerrinot jerrinot requested a review from mtopolnik January 13, 2026 12:37
@jerrinot
Copy link
Copy Markdown
Contributor Author

@coderabbitai pls review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 13, 2026

🧩 Analysis chain

@jerrinot, I'll review the changes in this PR.


🏁 Script executed:

#!/bin/bash
# Fetch PR details
gh pr view 6634 --json title,body,files,additions,deletions

# Get the diff for this PR
gh pr diff 6634

Length of output: 4106


@jerrinot, I'll conduct a comprehensive review of this PR.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jerrinot jerrinot marked this pull request as draft January 13, 2026 12:42
@jerrinot jerrinot marked this pull request as ready for review January 13, 2026 13:17
@glasstiger
Copy link
Copy Markdown
Contributor

[PR Coverage check]

😍 pass : 3 / 3 (100.00%)

file detail

path covered line new line coverage
🔵 io/questdb/griffin/SqlCodeGenerator.java 3 3 100.00%

@bluestreak01 bluestreak01 merged commit baeb297 into master Jan 13, 2026
45 checks passed
@bluestreak01 bluestreak01 deleted the jh_asof_on_single_symbol_and_other_type branch January 13, 2026 15:48
jerrinot added a commit that referenced this pull request Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Incorrect or unexpected behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants