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

Inner join fails to be transformed into a interval join #8923

Closed
chenzl25 opened this issue Mar 31, 2023 · 0 comments · Fixed by #9071
Closed

Inner join fails to be transformed into a interval join #8923

chenzl25 opened this issue Mar 31, 2023 · 0 comments · Fixed by #9071
Assignees
Labels
type/bug Something isn't working
Milestone

Comments

@chenzl25
Copy link
Contributor

Describe the bug

The inner join will pull up non-equal conditions to utilize the vectorized filter, but it will cause the join fails to be transformed into an interval join.

create table t1 (ts1 timestamp with time zone, id1 int, watermark for ts1 as ts1 - INTERVAL '5' SECOND) append only;
create table t2 (ts2 timestamp with time zone, id2 int, watermark for ts2 as ts2 - INTERVAL '5' SECOND) append only;
explain create materialized view v as select * from t1 join t2 on id1 = id2 and ts1 between (ts2 - INTERVAL '30' SECOND) and (ts2 + INTERVAL '30' SECOND);


 StreamMaterialize { columns: [ts1, id1, ts2, id2, t1._row_id(hidden), t2._row_id(hidden)], stream_key: [t1._row_id, t2._row_id, id1], pk_columns: [t1._row_id, t2._row_id, id1], pk_conflict: "NoCheck" }
 └─StreamProject { exprs: [t1.ts1, t1.id1, t2.ts2, t2.id2, t1._row_id, t2._row_id] }
   └─StreamFilter { predicate: (t1.ts1 >= $expr1) AND (t1.ts1 <= $expr2) }
     └─StreamAppendOnlyHashJoin { type: Inner, predicate: t1.id1 = t2.id2 }
       ├─StreamExchange { dist: HashShard(t1.id1) }
       | └─StreamTableScan { table: t1, columns: [ts1, id1, _row_id] }
       └─StreamExchange { dist: HashShard(t2.id2) }
         └─StreamProject { exprs: [t2.ts2, t2.id2, (AtTimeZone((AtTimeZone(t2.ts2, 'UTC':Varchar) - '00:00:00':Interval), 'UTC':Varchar) - '00:00:30':Interval) as $expr1, (AtTimeZone((AtTimeZone(t2.ts2, 'UTC':Varchar) + '00:00:00':Interval), 'UTC':Varchar) + '00:00:30':Interval) as $expr2, t2._row_id], output_watermarks: [t2.ts2, $expr1, $expr2] }
           └─StreamTableScan { table: t2, columns: [ts2, id2, _row_id] }
(9 rows)

To Reproduce

No response

Expected behavior

No response

Additional context

No response

@chenzl25 chenzl25 added the type/bug Something isn't working label Mar 31, 2023
@github-actions github-actions bot added this to the release-0.19 milestone Mar 31, 2023
@chenzl25 chenzl25 self-assigned this Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant