|
41 | 41 | └─StreamLocalityProvider { locality_columns: [t.a, t.b] } |
42 | 42 | └─StreamExchange [no_shuffle] { dist: UpstreamHashShard(t.b, t.a) } |
43 | 43 | └─StreamTableScan { table: t, columns: [t.a, t.b], stream_scan_type: ArrangementBackfill, stream_key: [t.b, t.a], pk: [b, a], dist: UpstreamHashShard(t.b, t.a) } |
| 44 | +- sql: | |
| 45 | + set enable_locality_backfill = true; |
| 46 | + create table t (a int, b int, c int); |
| 47 | + select count(*) from t where c > 1 group by a, b; |
| 48 | + stream_plan: |- |
| 49 | + StreamMaterialize { columns: [count, t.a(hidden), t.b(hidden)], stream_key: [t.a, t.b], pk_columns: [t.a, t.b], pk_conflict: NoCheck } |
| 50 | + └─StreamProject { exprs: [count, t.a, t.b] } |
| 51 | + └─StreamHashAgg { group_key: [t.a, t.b], aggs: [count] } |
| 52 | + └─StreamLocalityProvider { locality_columns: [t.a, t.b] } |
| 53 | + └─StreamExchange { dist: HashShard(t.a, t.b) } |
| 54 | + └─StreamProject { exprs: [t.a, t.b, t._row_id] } |
| 55 | + └─StreamFilter { predicate: (t.c > 1:Int32) } |
| 56 | + └─StreamTableScan { table: t, columns: [t.a, t.b, t._row_id, t.c], stream_scan_type: ArrangementBackfill, stream_key: [t._row_id], pk: [_row_id], dist: UpstreamHashShard(t._row_id) } |
| 57 | +- sql: | |
| 58 | + set enable_locality_backfill = true; |
| 59 | + create table t1 (a int, b int, c int); |
| 60 | + create table t2 (a int, b int, c int); |
| 61 | + select count(*) from t1 join t2 on t1.a = t2.a where t1.c > t2.c group by t1.b; |
| 62 | + stream_plan: |- |
| 63 | + StreamMaterialize { columns: [count, t1.b(hidden)], stream_key: [t1.b], pk_columns: [t1.b], pk_conflict: NoCheck } |
| 64 | + └─StreamProject { exprs: [count, t1.b] } |
| 65 | + └─StreamHashAgg { group_key: [t1.b], aggs: [count] } |
| 66 | + └─StreamLocalityProvider { locality_columns: [t1.b] } |
| 67 | + └─StreamExchange { dist: HashShard(t1.b) } |
| 68 | + └─StreamProject { exprs: [t1.b, t1._row_id, t1.a, t2._row_id] } |
| 69 | + └─StreamFilter { predicate: (t1.c > t2.c) } |
| 70 | + └─StreamHashJoin { type: Inner, predicate: t1.a = t2.a, output: all } |
| 71 | + ├─StreamExchange { dist: HashShard(t1.a) } |
| 72 | + │ └─StreamLocalityProvider { locality_columns: [t1.a] } |
| 73 | + │ └─StreamExchange { dist: HashShard(t1.a) } |
| 74 | + │ └─StreamTableScan { table: t1, columns: [t1.a, t1.b, t1.c, t1._row_id], stream_scan_type: ArrangementBackfill, stream_key: [t1._row_id], pk: [_row_id], dist: UpstreamHashShard(t1._row_id) } |
| 75 | + └─StreamExchange { dist: HashShard(t2.a) } |
| 76 | + └─StreamLocalityProvider { locality_columns: [t2.a] } |
| 77 | + └─StreamExchange { dist: HashShard(t2.a) } |
| 78 | + └─StreamTableScan { table: t2, columns: [t2.a, t2.c, t2._row_id], stream_scan_type: ArrangementBackfill, stream_key: [t2._row_id], pk: [_row_id], dist: UpstreamHashShard(t2._row_id) } |
| 79 | +- sql: | |
| 80 | + set enable_locality_backfill = true; |
| 81 | + create table t (a int, b int, c int); |
| 82 | + select RANK() OVER (PARTITION BY a ORDER BY b) as rank from t; |
| 83 | + stream_plan: |- |
| 84 | + StreamMaterialize { columns: [rank, t._row_id(hidden), t.a(hidden)], stream_key: [t._row_id, t.a], pk_columns: [t._row_id, t.a], pk_conflict: NoCheck } |
| 85 | + └─StreamProject { exprs: [rank, t._row_id, t.a] } |
| 86 | + └─StreamOverWindow { window_functions: [rank() OVER(PARTITION BY t.a ORDER BY t.b ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)] } |
| 87 | + └─StreamLocalityProvider { locality_columns: [t.a] } |
| 88 | + └─StreamExchange { dist: HashShard(t.a) } |
| 89 | + └─StreamTableScan { table: t, columns: [t.a, t.b, t._row_id], stream_scan_type: ArrangementBackfill, stream_key: [t._row_id], pk: [_row_id], dist: UpstreamHashShard(t._row_id) } |
| 90 | +- name: enforce locality for temporal join for both sides. |
| 91 | + sql: | |
| 92 | + set enable_locality_backfill = true; |
| 93 | + create table stream(id1 int, a1 int, b1 int); |
| 94 | + create table version(id2 int, a2 int, b2 int, primary key (id2)); |
| 95 | + create index idx2 on version (a2, b2); |
| 96 | + select id1, a1, id2, a2 from stream left join version FOR SYSTEM_TIME AS OF PROCTIME() on a1 = a2 and b1 = b2; |
| 97 | + stream_plan: |- |
| 98 | + StreamMaterialize { columns: [id1, a1, id2, a2, stream._row_id(hidden), stream.b1(hidden)], stream_key: [stream._row_id, id2, a1, stream.b1], pk_columns: [stream._row_id, id2, a1, stream.b1], pk_conflict: NoCheck } |
| 99 | + └─StreamExchange { dist: HashShard(stream.a1, idx2.id2, stream._row_id, stream.b1) } |
| 100 | + └─StreamTemporalJoin { type: LeftOuter, append_only: false, predicate: stream.a1 = idx2.a2 AND stream.b1 = idx2.b2, nested_loop: false, output: [stream.id1, stream.a1, idx2.id2, idx2.a2, stream._row_id, stream.b1] } |
| 101 | + ├─StreamExchange { dist: HashShard(stream.a1) } |
| 102 | + │ └─StreamLocalityProvider { locality_columns: [stream.a1, stream.b1] } |
| 103 | + │ └─StreamExchange { dist: HashShard(stream.a1, stream.b1) } |
| 104 | + │ └─StreamTableScan { table: stream, columns: [stream.id1, stream.a1, stream.b1, stream._row_id], stream_scan_type: ArrangementBackfill, stream_key: [stream._row_id], pk: [_row_id], dist: UpstreamHashShard(stream._row_id) } |
| 105 | + └─StreamExchange [no_shuffle] { dist: UpstreamHashShard(idx2.a2) } |
| 106 | + └─StreamTableScan { table: idx2, columns: [idx2.id2, idx2.a2, idx2.b2], stream_scan_type: UpstreamOnly, stream_key: [idx2.id2], pk: [a2, b2, id2], dist: UpstreamHashShard(idx2.a2) } |
| 107 | +- sql: | |
| 108 | + set enable_locality_backfill = true; |
| 109 | + create table t(a int, b int, c int) append only; |
| 110 | + select distinct on(a) * from t ; |
| 111 | + stream_plan: |- |
| 112 | + StreamMaterialize { columns: [a, b, c, t._row_id(hidden)], stream_key: [a], pk_columns: [a], pk_conflict: NoCheck } |
| 113 | + └─StreamAppendOnlyDedup { dedup_cols: [t.a] } |
| 114 | + └─StreamExchange { dist: HashShard(t.a) } |
| 115 | + └─StreamLocalityProvider { locality_columns: [t.a] } |
| 116 | + └─StreamExchange { dist: HashShard(t.a) } |
| 117 | + └─StreamTableScan { table: t, columns: [t.a, t.b, t.c, t._row_id], stream_scan_type: ArrangementBackfill, stream_key: [t._row_id], pk: [_row_id], dist: UpstreamHashShard(t._row_id) } |
| 118 | +- sql: | |
| 119 | + set enable_locality_backfill = true; |
| 120 | + create table t(a int, b int, c int); |
| 121 | + SELECT * FROM ( |
| 122 | + SELECT |
| 123 | + *, |
| 124 | + row_number() OVER (PARTITION BY a ORDER BY b) AS rank |
| 125 | + FROM t |
| 126 | + ) WHERE rank <= 1; |
| 127 | + stream_plan: |- |
| 128 | + StreamMaterialize { columns: [a, b, c, t._row_id(hidden), rank], stream_key: [a], pk_columns: [a], pk_conflict: NoCheck } |
| 129 | + └─StreamOverWindow { window_functions: [row_number() OVER(PARTITION BY t.a ORDER BY t.b ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)] } |
| 130 | + └─StreamLocalityProvider { locality_columns: [t.a] } |
| 131 | + └─StreamExchange [no_shuffle] { dist: UpstreamHashShard(t.a) } |
| 132 | + └─StreamGroupTopN { order: [t.b ASC], limit: 1, offset: 0, group_key: [t.a] } |
| 133 | + └─StreamLocalityProvider { locality_columns: [t.a] } |
| 134 | + └─StreamExchange { dist: HashShard(t.a) } |
| 135 | + └─StreamTableScan { table: t, columns: [t.a, t.b, t.c, t._row_id], stream_scan_type: ArrangementBackfill, stream_key: [t._row_id], pk: [_row_id], dist: UpstreamHashShard(t._row_id) } |
0 commit comments