Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(experiments): Hackily apply timestamp to ASOF LEFT JOIN #26852

Merged
merged 5 commits into from
Dec 12, 2024

Conversation

danielbachhuber
Copy link
Contributor

@danielbachhuber danielbachhuber commented Dec 11, 2024

See https://posthog.slack.com/archives/C07PXH2GTGV/p1733941329943129?thread_ts=1733936406.339719&cid=C07PXH2GTGV
See #26332

Changes

Hackily pulls timestamp statements from node.where and applies them to the ASOF LEFT JOIN.

Ideally, we'd directly reference the timestamp column from the data warehouse table. However, HogQL doesn't support referencing the parent clause, so this will have to suffice for now.

Includes a test to assert that the clause is included in the generated ClickHouse SQL.

How did you test this code?

Tests should pass. I also inspected the query output.

@danielbachhuber danielbachhuber requested a review from a team December 11, 2024 21:45
Copy link
Collaborator

@timgl timgl left a comment

Choose a reason for hiding this comment

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

Would also be good to add a test here to make sure this does what we think it does

# :HACK: We need to pull the timestamp gt/lt values from node.where.exprs[0] because
# we can't reference the parent data warehouse table in the where clause.
if (
node.where.exprs[0].op == ast.CompareOperationOp.GtEq
Copy link
Collaborator

Choose a reason for hiding this comment

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

WhereClauseExtractor is probably a better way of doing this.

@danielbachhuber
Copy link
Contributor Author

@timgl I added a test to assert the contents of the clickhouse_sql.

WhereClauseExtractor is probably a better way of doing this.

I'm not sure I follow. Can you provide a specific example?

@danielbachhuber danielbachhuber merged commit 0d72070 into master Dec 12, 2024
91 checks passed
@danielbachhuber danielbachhuber deleted the experiments/limit-join-timestamp branch December 12, 2024 15:31
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