default.slt 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # this file DELIBERATELY does not specify the level or format for EXPLAIN
  10. simple conn=mz_system,user=mz_system
  11. ALTER SYSTEM SET unsafe_enable_table_keys = true
  12. ----
  13. COMPLETE 0
  14. statement ok
  15. CREATE TABLE t (
  16. a int,
  17. b int
  18. );
  19. statement ok
  20. CREATE TABLE u (
  21. c int,
  22. d int
  23. );
  24. statement ok
  25. CREATE TABLE v (
  26. e int,
  27. f int
  28. );
  29. statement ok
  30. CREATE INDEX t_a_idx ON t(a);
  31. statement ok
  32. CREATE VIEW ov AS SELECT * FROM t ORDER BY b asc, a desc LIMIT 5;
  33. statement ok
  34. CREATE VIEW iv AS
  35. SELECT * FROM t WHERE a IS NOT NULL;
  36. statement ok
  37. CREATE INDEX iv_a_idx ON iv(a);
  38. statement ok
  39. CREATE INDEX iv_b_idx ON iv(b);
  40. # This is an identical index to the above (on the same object, on the same key)
  41. statement ok
  42. CREATE INDEX iv_b_idx_2 ON iv(b);
  43. statement ok
  44. CREATE MATERIALIZED VIEW mv AS
  45. SELECT * FROM t WHERE a IS NOT NULL;
  46. statement ok
  47. CREATE MATERIALIZED VIEW non_empty_mv AS
  48. SELECT 1 as x, 2 as y;
  49. statement ok
  50. CREATE INDEX non_empty_mv_idx ON non_empty_mv(y + 7);
  51. statement ok
  52. CREATE MATERIALIZED VIEW empty_mv AS
  53. SELECT;
  54. statement ok
  55. CREATE INDEX empty_mv_idx ON empty_mv();
  56. mode cockroach
  57. # Test target cluster selection for mz_system tables without transactions.
  58. query T multiline
  59. EXPLAIN WITH(no fast path, humanized expressions)
  60. SELECT * FROM mz_views;
  61. ----
  62. Explained Query:
  63. →Arranged mz_catalog.mz_views
  64. Used Indexes:
  65. - mz_catalog.mz_views_ind (*** full scan ***)
  66. Target cluster: mz_catalog_server
  67. EOF
  68. # Test target cluster selection for mz_system tables inside a transaction.
  69. statement ok
  70. BEGIN
  71. statement ok
  72. SELECT * FROM t;
  73. query T multiline
  74. EXPLAIN WITH(no fast path, humanized expressions)
  75. SELECT * FROM mz_views;
  76. ----
  77. Explained Query:
  78. →Stream mz_catalog.mz_views
  79. Source mz_catalog.mz_views
  80. Target cluster: quickstart
  81. EOF
  82. statement ok
  83. ROLLBACK
  84. # Test constant error.
  85. query T multiline
  86. EXPLAIN WITH(humanized expressions)
  87. SELECT 1 / 0
  88. ----
  89. Explained Query (fast path):
  90. →Constant (error: "division by zero")
  91. Target cluster: quickstart
  92. EOF
  93. # Test constant with two elements.
  94. query T multiline
  95. EXPLAIN WITH(humanized expressions)
  96. (SELECT 1, 2) UNION ALL (SELECT 1, 2) UNION ALL (SELECT 3, 4)
  97. ----
  98. Explained Query (fast path):
  99. →Constant (2 rows)
  100. Target cluster: mz_catalog_server
  101. EOF
  102. # Test catalog queries (index found based on cluster auto-routing).
  103. query T multiline
  104. EXPLAIN WITH (humanized expressions)
  105. SELECT * FROM mz_internal.mz_source_status_history
  106. ----
  107. Explained Query (fast path):
  108. →Map/Filter/Project
  109. Project: #1, #0, #2..=#5
  110. →Indexed mz_internal.mz_source_status_history (using mz_internal.mz_source_status_history_ind)
  111. Used Indexes:
  112. - mz_internal.mz_source_status_history_ind (*** full scan ***)
  113. Target cluster: mz_catalog_server
  114. EOF
  115. # Test fast path rendering on a non-trivial index.
  116. query T multiline
  117. EXPLAIN WITH(humanized expressions)
  118. SELECT * FROM non_empty_mv where y + 7 = 9
  119. ----
  120. Explained Query (fast path):
  121. →Map/Filter/Project
  122. Project: #1, #2
  123. →Index Lookup on materialize.public.non_empty_mv (using materialize.public.non_empty_mv_idx)
  124. Lookup values: (9)
  125. Used Indexes:
  126. - materialize.public.non_empty_mv_idx (lookup)
  127. Target cluster: quickstart
  128. EOF
  129. # Test fast path rendering on an empty index on an empty relation.
  130. query T multiline
  131. EXPLAIN WITH(humanized expressions)
  132. SELECT * FROM empty_mv
  133. ----
  134. Explained Query (fast path):
  135. →Map/Filter/Project
  136. →Indexed materialize.public.empty_mv (using materialize.public.empty_mv_idx)
  137. Used Indexes:
  138. - materialize.public.empty_mv_idx (*** full scan ***)
  139. Target cluster: quickstart
  140. EOF
  141. # Test basic linear chains (fast path).
  142. query T multiline
  143. EXPLAIN WITH(humanized expressions)
  144. SELECT 1, a + b as c FROM iv WHERE b = 5 and a < 0 and a + b > 0
  145. ----
  146. Explained Query (fast path):
  147. →Map/Filter/Project
  148. Project: #4, #3
  149. Filter: (#1{a} < 0) AND ((#1{a} + #0{b}) > 0)
  150. Map: (#1{a} + 5), 1
  151. →Index Lookup on materialize.public.iv (using materialize.public.iv_b_idx_2)
  152. Lookup values: (5)
  153. Used Indexes:
  154. - materialize.public.iv_b_idx_2 (lookup)
  155. Target cluster: quickstart
  156. EOF
  157. # Test basic linear chains (slow path).
  158. query T multiline
  159. EXPLAIN WITH(humanized expressions)
  160. SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0
  161. ----
  162. Explained Query:
  163. →Read materialize.public.mv
  164. Source materialize.public.mv
  165. project=(#3, #2)
  166. filter=((#0{a} > 0) AND (#1{b} < 0) AND (#2 > 0))
  167. map=((#0{a} + #1{b}), 1)
  168. Target cluster: quickstart
  169. EOF
  170. # Test table functions in the select clause (FlatMap).
  171. query T multiline
  172. EXPLAIN WITH(humanized expressions)
  173. SELECT generate_series(a, b) from t
  174. ----
  175. Explained Query:
  176. →Table Function generate_series(#0{a}, #1{b}, 1)
  177. →Arranged materialize.public.t
  178. Used Indexes:
  179. - materialize.public.t_a_idx (*** full scan ***)
  180. Target cluster: quickstart
  181. EOF
  182. # Test Threshold, Union, Distinct, Negate.
  183. query T multiline
  184. EXPLAIN WITH(humanized expressions)
  185. SELECT a FROM t EXCEPT SELECT b FROM mv
  186. ----
  187. Explained Query:
  188. →Threshold Diffs #0
  189. →Arrange (#0)
  190. →Consolidating Union
  191. →Unarranged Raw Stream
  192. →Distinct GroupAggregate
  193. →Fused Map/Filter/Project
  194. Project: #0
  195. →Arranged materialize.public.t
  196. Key: (#0{a})
  197. →Negate Diffs
  198. →Unarranged Raw Stream
  199. →Distinct GroupAggregate
  200. →Read materialize.public.mv
  201. Source materialize.public.mv
  202. project=(#1)
  203. Used Indexes:
  204. - materialize.public.t_a_idx (*** full scan ***)
  205. Target cluster: quickstart
  206. EOF
  207. # Test Threshold, Union, Distinct, Negate.
  208. query T multiline
  209. EXPLAIN WITH(humanized expressions)
  210. SELECT a FROM t EXCEPT ALL SELECT b FROM mv
  211. ----
  212. Explained Query:
  213. →Threshold Diffs #0
  214. →Arrange (#0)
  215. →Consolidating Union
  216. →Fused Map/Filter/Project
  217. Project: #0
  218. →Arranged materialize.public.t
  219. Key: (#0{a})
  220. →Negate Diffs
  221. →Read materialize.public.mv
  222. Source materialize.public.mv
  223. project=(#1)
  224. Used Indexes:
  225. - materialize.public.t_a_idx (*** full scan ***)
  226. Target cluster: quickstart
  227. EOF
  228. # Test TopK.
  229. query T multiline
  230. EXPLAIN WITH(humanized expressions)
  231. SELECT * FROM ov
  232. ----
  233. Explained Query:
  234. →Consolidating Monotonic TopK
  235. Order By #1 asc nulls_last, #0 desc nulls_first
  236. Limit 5
  237. →Unarranged Raw Stream
  238. →Arranged materialize.public.t
  239. Used Indexes:
  240. - materialize.public.t_a_idx (*** full scan ***)
  241. Target cluster: quickstart
  242. EOF
  243. # Test Finish.
  244. query T multiline
  245. EXPLAIN WITH(humanized expressions)
  246. SELECT * FROM t ORDER BY b asc, a desc LIMIT 5
  247. ----
  248. Explained Query (fast path):
  249. Finish order_by=[#1 asc nulls_last, #0 desc nulls_first] limit=5 output=[#0, #1]
  250. →Map/Filter/Project
  251. →Indexed materialize.public.t (using materialize.public.t_a_idx)
  252. Used Indexes:
  253. - materialize.public.t_a_idx (*** full scan ***)
  254. Target cluster: quickstart
  255. EOF
  256. # Test Reduce (global).
  257. query T multiline
  258. EXPLAIN WITH(humanized expressions)
  259. SELECT abs(min(a) - max(a)) FROM t
  260. ----
  261. Explained Query:
  262. →With
  263. cte l0 =
  264. →Consolidating Monotonic GroupAggregate
  265. Aggregations: min, max
  266. Key:
  267. Project: ()
  268. →Fused Map/Filter/Project
  269. Project: #0
  270. →Arranged materialize.public.t
  271. Key: (#0{a})
  272. →Return
  273. →Map/Filter/Project
  274. Project: #2
  275. Map: abs((#0{"?column?"} - #1{"?column?"}))
  276. →Union
  277. →Unarranged Raw Stream
  278. →Arranged l0
  279. →Map/Filter/Project
  280. Project: #0, #1
  281. Map: null, null
  282. →Consolidating Union
  283. →Negate Diffs
  284. →Fused Map/Filter/Project
  285. Project: ()
  286. →Arranged l0
  287. Key: ()
  288. →Constant (1 row)
  289. Used Indexes:
  290. - materialize.public.t_a_idx (*** full scan ***)
  291. Target cluster: quickstart
  292. EOF
  293. # as above, but EXPLAIN PHYSICAL PLAN without AS will use VERBOSE text
  294. query T multiline
  295. EXPLAIN PHYSICAL PLAN WITH(humanized expressions) FOR
  296. SELECT abs(min(a) - max(a)) FROM t
  297. ----
  298. Explained Query:
  299. With
  300. cte l0 =
  301. Reduce::Hierarchical
  302. aggr_funcs=[min, max]
  303. skips=[0, 0]
  304. monotonic
  305. must_consolidate
  306. val_plan
  307. project=(#0, #0)
  308. key_plan
  309. project=()
  310. Get::Arrangement materialize.public.t
  311. project=(#0)
  312. key=#0{a}
  313. raw=false
  314. arrangements[0]={ key=[#0{a}], permutation=id, thinning=(#1) }
  315. types=[integer?, integer?]
  316. Return
  317. Mfp
  318. project=(#2)
  319. map=(abs((#0{"?column?"} - #1{"?column?"})))
  320. Union
  321. ArrangeBy
  322. input_key=[]
  323. raw=true
  324. Get::PassArrangements l0
  325. raw=false
  326. arrangements[0]={ key=[], permutation=id, thinning=(#0, #1) }
  327. Mfp
  328. project=(#0, #1)
  329. map=(null, null)
  330. Union consolidate_output=true
  331. Negate
  332. Get::Arrangement l0
  333. project=()
  334. key=
  335. raw=false
  336. arrangements[0]={ key=[], permutation=id, thinning=(#0, #1) }
  337. Constant
  338. - ()
  339. Used Indexes:
  340. - materialize.public.t_a_idx (*** full scan ***)
  341. Target cluster: quickstart
  342. EOF
  343. # Test Reduce (local).
  344. query T multiline
  345. EXPLAIN WITH(humanized expressions)
  346. SELECT abs(min(a) - max(a)) FROM t GROUP BY b
  347. ----
  348. Explained Query:
  349. →Map/Filter/Project
  350. Project: #3
  351. Map: abs((#1{"?column?"} - #2{"?column?"}))
  352. →Consolidating Monotonic GroupAggregate
  353. Aggregations: min, max
  354. Key:
  355. Project: #1
  356. →Arranged materialize.public.t
  357. Used Indexes:
  358. - materialize.public.t_a_idx (*** full scan ***)
  359. Target cluster: quickstart
  360. EOF
  361. # Test EXISTS subqueries.
  362. query T multiline
  363. EXPLAIN WITH(humanized expressions)
  364. SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELECT * FROM mv WHERE t.b > mv.b)
  365. ----
  366. Explained Query:
  367. →With
  368. cte l0 =
  369. →Differential Join %1 » %0
  370. Join stage 0 in %0 with lookup key #0{a}
  371. →Arranged materialize.public.t
  372. →Distinct GroupAggregate
  373. →Differential Join %0 » %1
  374. Join stage 0 in %1
  375. project=(#0)
  376. filter=((#0{a} < #1{a}))
  377. →Arrange (empty key)
  378. →Distinct GroupAggregate
  379. →Fused Map/Filter/Project
  380. Project: #0
  381. →Arranged materialize.public.t
  382. Key: (#0{a})
  383. →Arrange (empty key)
  384. →Fused Map/Filter/Project
  385. Project: #0
  386. →Read materialize.public.mv
  387. →Return
  388. →Differential Join %1 » %0
  389. Join stage 0 in %0 with lookup key #1
  390. →Arrange (#1)
  391. →Stream l0
  392. →Distinct GroupAggregate
  393. →Differential Join %0 » %1
  394. Join stage 0 in %1
  395. project=(#0)
  396. filter=((#0{b} > #1{b}))
  397. →Arrange (empty key)
  398. →Distinct GroupAggregate
  399. →Fused Map/Filter/Project
  400. Project: #1
  401. →Read l0
  402. →Arrange (empty key)
  403. →Fused Map/Filter/Project
  404. Project: #1
  405. →Read materialize.public.mv
  406. Used Indexes:
  407. - materialize.public.t_a_idx (*** full scan ***, differential join)
  408. Target cluster: quickstart
  409. EOF
  410. # Test SELECT subqueries.
  411. query T multiline
  412. EXPLAIN WITH(humanized expressions)
  413. SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE mv.b = t.b LIMIT 1) FROM t
  414. ----
  415. Explained Query:
  416. →With
  417. cte l0 =
  418. →Fused Map/Filter/Project
  419. Project: #1
  420. →Arranged materialize.public.t
  421. Key: (#0{a})
  422. cte l1 =
  423. →Distinct GroupAggregate
  424. →Stream l0
  425. cte l2 =
  426. →Arranged l1
  427. cte l3 =
  428. →Consolidating Monotonic Top1
  429. Group By#0
  430. →Differential Join %0 » %1
  431. Join stage 0 in %1 with lookup key #1{b}
  432. filter=((#0{b}) IS NOT NULL)
  433. →Arranged l2
  434. →Arranged materialize.public.iv
  435. cte l4 =
  436. →Consolidating Monotonic Top1
  437. Group By#0
  438. →Differential Join %0 » %1
  439. Join stage 0 in %1 with lookup key #1{b}
  440. →Arranged l2
  441. →Arrange (#1{b})
  442. →Read materialize.public.mv
  443. →Return
  444. →Delta Join [%0 » %1 » %2] [%1 » %2 » %0] [%2 » %1 » %0]
  445. Delta join path for input %0
  446. stage 0 for %1: lookup key #0
  447. stage 1 for %2: lookup key #0
  448. Delta join path for input %1
  449. stage 0 for %2: lookup key #0
  450. stage 1 for %0: lookup key #0
  451. Delta join path for input %2
  452. stage 0 for %1: lookup key #0
  453. stage 1 for %0: lookup key #0
  454. →Arrange (#0)
  455. →Stream l0
  456. →Arrange (#0)
  457. →Union
  458. →Stream l3
  459. →Map/Filter/Project
  460. Project: #0, #1
  461. Map: null
  462. →Consolidating Union
  463. →Negate Diffs
  464. →Fused Map/Filter/Project
  465. Project: #0
  466. →Read l3
  467. →Unarranged Raw Stream
  468. →Arranged l1
  469. →Arrange (#0)
  470. →Union
  471. →Stream l4
  472. →Map/Filter/Project
  473. Project: #0, #1
  474. Map: null
  475. →Consolidating Union
  476. →Negate Diffs
  477. →Fused Map/Filter/Project
  478. Project: #0
  479. →Read l4
  480. →Unarranged Raw Stream
  481. →Arranged l1
  482. Source materialize.public.mv
  483. filter=((#1{b}) IS NOT NULL)
  484. Used Indexes:
  485. - materialize.public.t_a_idx (*** full scan ***)
  486. - materialize.public.iv_b_idx (differential join)
  487. Target cluster: quickstart
  488. EOF
  489. # Test outer joins (ON syntax).
  490. query T multiline
  491. EXPLAIN WITH(humanized expressions)
  492. SELECT t1.a, t2.a
  493. FROM t as t1
  494. LEFT JOIN t as t2 ON t1.b = t2.b
  495. RIGHT JOIN t as t3 ON t2.b = t3.b
  496. ----
  497. Explained Query:
  498. →With
  499. cte l0 =
  500. →Fused Map/Filter/Project
  501. Filter: (#1{b}) IS NOT NULL
  502. →Arranged materialize.public.t
  503. Key: (#0{a})
  504. cte l1 =
  505. →Arrange (#1{b})
  506. →Stream l0
  507. cte l2 =
  508. →Arrange (#0{b})
  509. →Fused Map/Filter/Project
  510. Project: #1
  511. →Read l0
  512. cte l3 =
  513. →Delta Join [%0 » %1 » %2] [%1 » %0 » %2] [%2 » %0 » %1]
  514. Delta join path for input %0
  515. stage 0 for %1: lookup key #1{b}
  516. stage 1 for %2: lookup key #0{b}
  517. Delta join path for input %1
  518. stage 0 for %0: lookup key #1{b}
  519. stage 1 for %2: lookup key #0{b}
  520. Delta join path for input %2
  521. stage 0 for %0: lookup key #1{b}
  522. stage 1 for %1: lookup key #1{b}
  523. →Arranged l1
  524. →Arranged l1
  525. →Arranged l2
  526. →Return
  527. →Union
  528. →Map/Filter/Project
  529. Project: #0, #1
  530. Map: null, null
  531. →Consolidating Union
  532. →Negate Diffs
  533. →Differential Join %1 » %0
  534. Join stage 0 in %0 with lookup key #0{b}
  535. →Arranged l2
  536. →Distinct GroupAggregate
  537. →Fused Map/Filter/Project
  538. Project: #1
  539. →Read l3
  540. →Fused Map/Filter/Project
  541. Project: ()
  542. →Arranged materialize.public.t
  543. Key: (#0{a})
  544. →Fused Map/Filter/Project
  545. Project: #0, #2
  546. →Read l3
  547. Used Indexes:
  548. - materialize.public.t_a_idx (*** full scan ***)
  549. Target cluster: quickstart
  550. EOF
  551. # Test a single CTE.
  552. query T multiline
  553. EXPLAIN WITH(humanized expressions)
  554. WITH x AS (SELECT t.a * t.b as v from t) SELECT a.v + b.v FROM x as a, x as b
  555. ----
  556. Explained Query:
  557. →With
  558. cte l0 =
  559. →Arrange (empty key)
  560. →Fused Map/Filter/Project
  561. Project: #2
  562. Map: (#0{a} * #1{b})
  563. →Arranged materialize.public.t
  564. Key: (#0{a})
  565. →Return
  566. →Differential Join %0 » %1
  567. Join stage 0 in %1
  568. project=(#2)
  569. map=((#0{v} + #1{v}))
  570. →Arranged l0
  571. →Arranged l0
  572. Used Indexes:
  573. - materialize.public.t_a_idx (*** full scan ***)
  574. Target cluster: quickstart
  575. EOF
  576. # Test EXPLAIN INDEX for an indexed source
  577. query T multiline
  578. EXPLAIN WITH(humanized expressions)
  579. INDEX t_a_idx
  580. ----
  581. materialize.public.t_a_idx:
  582. →Arrange (#0{a})
  583. →Stream materialize.public.t
  584. Source materialize.public.t
  585. Target cluster: quickstart
  586. EOF
  587. # Test EXPLAIN INDEX for an indexed view (first index)
  588. query T multiline
  589. EXPLAIN WITH(humanized expressions)
  590. INDEX iv_a_idx;
  591. ----
  592. materialize.public.iv_a_idx:
  593. →Arrange (#0{a})
  594. →Stream materialize.public.iv
  595. materialize.public.iv:
  596. →Fused Map/Filter/Project
  597. Filter: (#0{a}) IS NOT NULL
  598. →Arranged materialize.public.t
  599. Key: (#0{a})
  600. Used Indexes:
  601. - materialize.public.t_a_idx (*** full scan ***)
  602. Target cluster: quickstart
  603. EOF
  604. # Test EXPLAIN INDEX for an indexed view (based on a prior index)
  605. query T multiline
  606. EXPLAIN WITH(humanized expressions)
  607. INDEX iv_b_idx;
  608. ----
  609. materialize.public.iv_b_idx:
  610. →Arrange (#1{b})
  611. →Arranged materialize.public.iv
  612. Used Indexes:
  613. - materialize.public.iv_a_idx (*** full scan ***, index export)
  614. Target cluster: quickstart
  615. EOF
  616. # Test EXPLAIN INDEX for an indexed view where the index is exactly the same as a prior index.
  617. query T multiline
  618. EXPLAIN WITH(humanized expressions)
  619. INDEX iv_b_idx_2;
  620. ----
  621. materialize.public.iv_b_idx_2:
  622. →Arranged materialize.public.iv
  623. Used Indexes:
  624. - materialize.public.iv_b_idx (plan root (no new arrangement), index export)
  625. Target cluster: quickstart
  626. Notices:
  627. - Notice: Index materialize.public.iv_b_idx_2 is identical to materialize.public.iv_b_idx, which is also defined on iv(b).
  628. Hint: Please drop all indexes except the first index created on iv(b) and recreate all dependent objects.
  629. EOF
  630. # Test multiple CTEs: a case where we cannot pull the let statement up through
  631. # the join because the local l0 is correlated against the lhs of the enclosing join.
  632. query T multiline
  633. EXPLAIN WITH(humanized expressions)
  634. SELECT
  635. *
  636. FROM
  637. (
  638. SELECT * FROM t
  639. ) as r1
  640. CROSS JOIN LATERAL (
  641. WITH r2 as (
  642. SELECT MAX(r1.a * t.a) AS m FROM t
  643. )
  644. SELECT * FROM r2 WHERE r2.m != r1.a
  645. ) as r3
  646. CROSS JOIN LATERAL (
  647. WITH r4 as (
  648. SELECT MAX(r1.a * t.a) AS m FROM t
  649. )
  650. SELECT * FROM r4 WHERE r4.m != r1.a OR (r4.m IS NOT NULL AND r1.a IS NULL)
  651. ) as r5;
  652. ----
  653. Explained Query:
  654. →With
  655. cte l0 =
  656. →Fused Map/Filter/Project
  657. Project: #0
  658. →Arranged materialize.public.t
  659. Key: (#0{a})
  660. cte l1 =
  661. →Arrange (empty key)
  662. →Stream l0
  663. cte l2 =
  664. →Differential Join %1 » %0
  665. Join stage 0 in %0 with lookup key #0{a}
  666. project=(#0, #2, #1)
  667. filter=((#0 != #1{m}))
  668. →Arranged materialize.public.t
  669. →Consolidating Monotonic GroupAggregate
  670. Aggregations: max
  671. Key:
  672. Project: #0
  673. →Differential Join %0 » %1
  674. Join stage 0 in %1
  675. →Arrange (empty key)
  676. →Distinct GroupAggregate
  677. →Stream l0
  678. →Arranged l1
  679. →Return
  680. →Differential Join %1 » %0
  681. Join stage 0 in %0 with lookup key #0
  682. project=(#0, #2, #3, #1)
  683. filter=((#0 != #1{m}))
  684. →Arrange (#0)
  685. →Stream l2
  686. →Consolidating Monotonic GroupAggregate
  687. Aggregations: max
  688. Key:
  689. Project: #0
  690. →Differential Join %0 » %1
  691. Join stage 0 in %1
  692. →Arrange (empty key)
  693. →Distinct GroupAggregate
  694. →Fused Map/Filter/Project
  695. Project: #0
  696. →Read l2
  697. →Arranged l1
  698. Used Indexes:
  699. - materialize.public.t_a_idx (*** full scan ***, differential join)
  700. Target cluster: quickstart
  701. EOF
  702. # Test cross join.
  703. query T multiline
  704. EXPLAIN WITH(humanized expressions)
  705. SELECT t1.a, t2.a FROM t as t1, t as t2
  706. ----
  707. Explained Query:
  708. →With
  709. cte l0 =
  710. →Arrange (empty key)
  711. →Fused Map/Filter/Project
  712. Project: #0
  713. →Arranged materialize.public.t
  714. Key: (#0{a})
  715. →Return
  716. →Differential Join %0 » %1
  717. Join stage 0 in %1
  718. →Arranged l0
  719. →Arranged l0
  720. Used Indexes:
  721. - materialize.public.t_a_idx (*** full scan ***)
  722. Target cluster: quickstart
  723. EOF
  724. # Test cyclic join.
  725. query T multiline
  726. EXPLAIN WITH(humanized expressions)
  727. SELECT t1.a, t2.a
  728. FROM
  729. t as t1,
  730. t as t2,
  731. t as t3
  732. WHERE t1.b = t2.b AND t2.b = t3.b
  733. ----
  734. Explained Query:
  735. →With
  736. cte l0 =
  737. →Fused Map/Filter/Project
  738. Filter: (#1{b}) IS NOT NULL
  739. →Arranged materialize.public.t
  740. Key: (#0{a})
  741. cte l1 =
  742. →Arrange (#1{b})
  743. →Stream l0
  744. →Return
  745. →Delta Join [%0 » %1 » %2] [%1 » %0 » %2] [%2 » %0 » %1]
  746. Delta join path for input %0
  747. stage 0 for %1: lookup key #1{b}
  748. stage 1 for %2: lookup key #0{b}
  749. Delta join path for input %1
  750. stage 0 for %0: lookup key #1{b}
  751. stage 1 for %2: lookup key #0{b}
  752. Delta join path for input %2
  753. stage 0 for %0: lookup key #1{b}
  754. stage 1 for %1: lookup key #1{b}
  755. →Arranged l1
  756. →Arranged l1
  757. →Arrange (#0{b})
  758. →Fused Map/Filter/Project
  759. Project: #1
  760. →Read l0
  761. Used Indexes:
  762. - materialize.public.t_a_idx (*** full scan ***)
  763. Target cluster: quickstart
  764. EOF
  765. # Create indexes required for differential join tests
  766. statement ok
  767. CREATE INDEX u_c_idx ON U(c);
  768. statement ok
  769. CREATE INDEX u_d_idx ON U(d);
  770. statement ok
  771. CREATE INDEX v_e_idx ON V(e);
  772. # Temporarily switch off enable_eager_delta_joins
  773. simple conn=mz_system,user=mz_system
  774. ALTER SYSTEM SET enable_eager_delta_joins = false
  775. ----
  776. COMPLETE 0
  777. # Test a differential join.
  778. query T multiline
  779. EXPLAIN WITH(humanized expressions)
  780. SELECT a, b, c, d, e, f
  781. FROM t, u, v
  782. WHERE a = c and d = e and b = f
  783. ----
  784. Explained Query:
  785. →Differential Join %0 » %1 » %2
  786. Join stage 1 in %2 with lookup key #0{e}, #1{f}
  787. Join stage 0 in %1 with lookup key #0{c}
  788. filter=((#0{a}) IS NOT NULL)
  789. →Arranged materialize.public.t
  790. →Arranged materialize.public.u
  791. →Arrange (#0{e}, #1{f})
  792. →Fused Map/Filter/Project
  793. Filter: (#0{e}) IS NOT NULL AND (#1{f}) IS NOT NULL
  794. →Arranged materialize.public.v
  795. Key: (#0{e})
  796. Used Indexes:
  797. - materialize.public.t_a_idx (differential join)
  798. - materialize.public.u_c_idx (differential join)
  799. - materialize.public.v_e_idx (*** full scan ***)
  800. Target cluster: quickstart
  801. EOF
  802. # Test a differential join WITH(join implementations).
  803. query T multiline
  804. EXPLAIN WITH(humanized expressions, join implementations)
  805. SELECT a, b, c, d, e, f
  806. FROM t, u, v
  807. WHERE a = c and d = e and b = f
  808. ----
  809. Explained Query:
  810. →Differential Join %0 » %1 » %2
  811. Join stage 1 in %2 with lookup key #0{e}, #1{f}
  812. Join stage 0 in %1 with lookup key #0{c}
  813. filter=((#0{a}) IS NOT NULL)
  814. →Arranged materialize.public.t
  815. →Arranged materialize.public.u
  816. →Arrange (#0{e}, #1{f})
  817. →Fused Map/Filter/Project
  818. Filter: (#0{e}) IS NOT NULL AND (#1{f}) IS NOT NULL
  819. →Arranged materialize.public.v
  820. Key: (#0{e})
  821. Used Indexes:
  822. - materialize.public.t_a_idx (differential join)
  823. - materialize.public.u_c_idx (differential join)
  824. - materialize.public.v_e_idx (*** full scan ***)
  825. Target cluster: quickstart
  826. EOF
  827. simple conn=mz_system,user=mz_system
  828. ALTER SYSTEM SET enable_eager_delta_joins = true
  829. ----
  830. COMPLETE 0
  831. # Create indexes required for delta join tests
  832. statement ok
  833. CREATE INDEX t_b_idx ON T(b);
  834. # Test a delta join without WITH(join implementations).
  835. query T multiline
  836. EXPLAIN WITH(humanized expressions)
  837. SELECT a, b, c, d, e, f
  838. FROM t, u, v
  839. WHERE b = c and d = e
  840. ----
  841. Explained Query:
  842. →Delta Join [%0 » %1 » %2] [%1 » %0 » %2] [%2 » %1 » %0]
  843. Delta join path for input %0
  844. stage 0 for %1: lookup key #0{c}
  845. project=(#1, #0, #2)
  846. filter=((#2{d}) IS NOT NULL)
  847. stage 1 for %2: lookup key #0{e}
  848. Delta join path for input %1
  849. stage 0 for %0: lookup key #1{b}
  850. project=(#2, #0, #1)
  851. filter=((#0{b}) IS NOT NULL)
  852. stage 1 for %2: lookup key #0{e}
  853. Delta join path for input %2
  854. stage 0 for %1: lookup key #1{d}
  855. project=(#2, #0, #1)
  856. filter=((#0{d}) IS NOT NULL)
  857. stage 1 for %0: lookup key #1{b}
  858. project=(#3, #0..=#2)
  859. filter=((#0{b}) IS NOT NULL)
  860. →Arranged materialize.public.t
  861. →Arranged materialize.public.u
  862. →Arranged materialize.public.v
  863. Used Indexes:
  864. - materialize.public.u_c_idx (delta join lookup)
  865. - materialize.public.u_d_idx (delta join lookup)
  866. - materialize.public.v_e_idx (delta join lookup)
  867. - materialize.public.t_b_idx (delta join 1st input (full scan))
  868. Target cluster: quickstart
  869. EOF
  870. # Test a delta join WITH(join implementations).
  871. query T multiline
  872. EXPLAIN WITH(join implementations, humanized expressions)
  873. SELECT a, b, c, d, e, f
  874. FROM t, u, v
  875. WHERE b = c and d = e
  876. ----
  877. Explained Query:
  878. →Delta Join [%0 » %1 » %2] [%1 » %0 » %2] [%2 » %1 » %0]
  879. Delta join path for input %0
  880. stage 0 for %1: lookup key #0{c}
  881. project=(#1, #0, #2)
  882. filter=((#2{d}) IS NOT NULL)
  883. stage 1 for %2: lookup key #0{e}
  884. Delta join path for input %1
  885. stage 0 for %0: lookup key #1{b}
  886. project=(#2, #0, #1)
  887. filter=((#0{b}) IS NOT NULL)
  888. stage 1 for %2: lookup key #0{e}
  889. Delta join path for input %2
  890. stage 0 for %1: lookup key #1{d}
  891. project=(#2, #0, #1)
  892. filter=((#0{d}) IS NOT NULL)
  893. stage 1 for %0: lookup key #1{b}
  894. project=(#3, #0..=#2)
  895. filter=((#0{b}) IS NOT NULL)
  896. →Arranged materialize.public.t
  897. →Arranged materialize.public.u
  898. →Arranged materialize.public.v
  899. Used Indexes:
  900. - materialize.public.u_c_idx (delta join lookup)
  901. - materialize.public.u_d_idx (delta join lookup)
  902. - materialize.public.v_e_idx (delta join lookup)
  903. - materialize.public.t_b_idx (delta join 1st input (full scan))
  904. Target cluster: quickstart
  905. EOF
  906. # Test a delta join where the first input has both a full scan and a lookup.
  907. query T multiline
  908. EXPLAIN WITH(join implementations, humanized expressions)
  909. SELECT a, b, c, d, e, f
  910. FROM t, u, v
  911. WHERE a = c and b = e
  912. ----
  913. Explained Query:
  914. →Delta Join [%0 » %1 » %2] [%1 » %0 » %2] [%2 » %0 » %1]
  915. Delta join path for input %0
  916. stage 0 for %1: lookup key #0{c}
  917. stage 1 for %2: lookup key #0{e}
  918. Delta join path for input %1
  919. stage 0 for %0: lookup key #0{a}
  920. project=(#0, #2, #1)
  921. filter=((#0{a}) IS NOT NULL AND (#2{b}) IS NOT NULL)
  922. stage 1 for %2: lookup key #0{e}
  923. Delta join path for input %2
  924. stage 0 for %0: lookup key #1{b}
  925. project=(#2, #0, #1)
  926. filter=((#0{b}) IS NOT NULL AND (#2{a}) IS NOT NULL)
  927. stage 1 for %1: lookup key #0{c}
  928. →Arranged materialize.public.t
  929. →Arranged materialize.public.u
  930. →Arranged materialize.public.v
  931. Used Indexes:
  932. - materialize.public.t_a_idx (delta join 1st input (full scan))
  933. - materialize.public.u_c_idx (delta join lookup)
  934. - materialize.public.v_e_idx (delta join lookup)
  935. - materialize.public.t_b_idx (delta join lookup)
  936. Target cluster: quickstart
  937. EOF
  938. # Test an IndexedFilter join.
  939. query T multiline
  940. EXPLAIN WITH(humanized expressions)
  941. SELECT a, max(b)
  942. FROM t
  943. WHERE a = 0
  944. GROUP BY a
  945. ----
  946. Explained Query:
  947. →Map/Filter/Project
  948. Project: #1, #0
  949. Map: 0
  950. →Consolidating Monotonic GroupAggregate
  951. Aggregations: max
  952. Key:
  953. Project: ()
  954. →Differential Join %1 » %0
  955. Join stage 0 in %0 with lookup key #0{a}
  956. →Arranged materialize.public.t
  957. →Arrange (#0)
  958. →Constant (1 row)
  959. Used Indexes:
  960. - materialize.public.t_a_idx (lookup)
  961. Target cluster: quickstart
  962. EOF
  963. # Create index for IndexedFilter test
  964. statement ok
  965. CREATE INDEX t_a_b_idx ON T(a,b)
  966. # Test an IndexedFilter join WITH(join implementations).
  967. query T multiline
  968. EXPLAIN WITH(join implementations, humanized expressions)
  969. SELECT a, max(b)
  970. FROM t
  971. WHERE (a = 0 AND b = 1) OR (a = 3 AND b = 4) OR (a = 7 AND b = 8)
  972. GROUP BY a
  973. ----
  974. Explained Query:
  975. →Consolidating Monotonic GroupAggregate
  976. Aggregations: max
  977. Key:
  978. Project: #0
  979. →Differential Join %1 » %0
  980. Join stage 0 in %0 with lookup key #0{a}, #1{b}
  981. →Arranged materialize.public.t
  982. →Arrange (#0, #1)
  983. →Constant (3 rows)
  984. Used Indexes:
  985. - materialize.public.t_a_b_idx (lookup)
  986. Target cluster: quickstart
  987. EOF
  988. # Test an IndexedFilter join on fast path WITH(join implementations).
  989. query T multiline
  990. EXPLAIN WITH(join implementations, humanized expressions)
  991. SELECT *
  992. FROM t
  993. WHERE (a = 0 AND b = 1) OR (a = 3 AND b = 4) OR (a = 7 AND b = 8)
  994. ----
  995. Explained Query (fast path):
  996. →Map/Filter/Project
  997. Project: #0, #1
  998. →Index Lookup on materialize.public.t (using materialize.public.t_a_b_idx)
  999. Lookup values: (0, 1); (3, 4); (7, 8)
  1000. Used Indexes:
  1001. - materialize.public.t_a_b_idx (lookup)
  1002. Target cluster: quickstart
  1003. EOF
  1004. # Test materialize#17348.
  1005. statement ok
  1006. CREATE TABLE r(f0 INT, f1 INT, f2 INT, f3 INT, f4 INT, f5 INT, f6 INT, f7 INT, f8 INT, f9 INT, f10 INT, f11 INT, f12 INT, f13 INT, f14 INT, f15 INT, f16 INT);
  1007. query T multiline
  1008. EXPLAIN WITH (humanized expressions)
  1009. SELECT *
  1010. FROM r AS r0, r AS r1
  1011. WHERE
  1012. r0.f0=r1.f0 AND
  1013. r0.f2=r1.f2 AND
  1014. r0.f3=r1.f3 AND
  1015. r0.f4=r1.f4 AND
  1016. r0.f6=r1.f6 AND
  1017. r0.f8=r1.f8 AND
  1018. r0.f9=r1.f9 AND
  1019. r0.f11=r1.f11 AND
  1020. r0.f12=r1.f12 AND
  1021. r0.f13=r1.f13 AND
  1022. r0.f15=r1.f15 AND
  1023. r0.f16=r1.f16;
  1024. ----
  1025. Explained Query:
  1026. →With
  1027. cte l0 =
  1028. →Arrange (#0{f0}, #2{f2}..=#4{f4}, #6{f6}, #8{f8}, #9{f9}, #11{f11}..=#13{f13}, #15{f15}, #16{f16})
  1029. →Read materialize.public.r
  1030. →Return
  1031. →Differential Join %0 » %1
  1032. Join stage 0 in %1 with lookup key #0{f0}, #2{f2}..=#4{f4}, #6{f6}, #8{f8}, #9{f9}, #11{f11}..=#13{f13}, #15{f15}, #16{f16}
  1033. →Arranged l0
  1034. →Arranged l0
  1035. Source materialize.public.r
  1036. filter=((#0{f0}) IS NOT NULL AND (#2{f2}) IS NOT NULL AND (#3{f3}) IS NOT NULL AND (#4{f4}) IS NOT NULL AND (#6{f6}) IS NOT NULL AND (#8{f8}) IS NOT NULL AND (#9{f9}) IS NOT NULL AND (#11{f11}) IS NOT NULL AND (#12{f12}) IS NOT NULL AND (#13{f13}) IS NOT NULL AND (#15{f15}) IS NOT NULL AND (#16{f16}) IS NOT NULL)
  1037. Target cluster: quickstart
  1038. EOF
  1039. # Regression test for database-issues#5674: support mz_now() on select from indexed table
  1040. # ---
  1041. simple conn=mz_system,user=mz_system
  1042. ALTER SYSTEM SET enable_rbac_checks TO false;
  1043. ----
  1044. COMPLETE 0
  1045. statement ok
  1046. DROP SCHEMA IF EXISTS public CASCADE;
  1047. simple conn=mz_system,user=mz_system
  1048. ALTER SYSTEM RESET enable_rbac_checks;
  1049. ----
  1050. COMPLETE 0
  1051. statement ok
  1052. CREATE SCHEMA public;
  1053. statement ok
  1054. CREATE TABLE t(a TIMESTAMP);
  1055. statement ok
  1056. CREATE DEFAULT INDEX ON t;
  1057. # EXPLAIN output is time-dependent, so we don't want show the output here, just
  1058. # assert that the query doesn't fail.
  1059. statement ok
  1060. EXPLAIN WITH (humanized expressions)
  1061. SELECT * FROM t WHERE a < mz_now();
  1062. # Regression test for materialize#19177
  1063. # ---
  1064. statement ok
  1065. DROP SCHEMA IF EXISTS public CASCADE;
  1066. statement ok
  1067. CREATE SCHEMA public;
  1068. statement ok
  1069. CREATE TABLE t1(x text);
  1070. statement ok
  1071. CREATE TABLE t2(x text);
  1072. statement ok
  1073. EXPLAIN WITH (humanized expressions)
  1074. SELECT * FROM t1, t2 WHERE t1.x || mz_internal.mz_session_id() = t2.x || mz_internal.mz_session_id();
  1075. # Regression test for the join visitation part of materialize#19177
  1076. statement ok
  1077. EXPLAIN WITH (humanized expressions)
  1078. SELECT * FROM t1, t2 WHERE t1.x || mz_now() = t2.x || mz_now();
  1079. query T multiline
  1080. EXPLAIN WITH(humanized expressions)
  1081. SELECT lag(x, 3, 'default') IGNORE NULLS OVER (ORDER BY x || x)
  1082. FROM t1;
  1083. ----
  1084. Explained Query:
  1085. →Map/Filter/Project
  1086. Project: #1
  1087. Map: record_get[0](#0)
  1088. →Fused Table Function unnest_list
  1089. →Non-incremental GroupAggregate
  1090. Aggregation: lag[ignore_nulls=true, order_by=[#0 asc nulls_last]](row(row(row(#0), row(#0{x}, 3, "default")), (#0{x} || #0{x})))
  1091. Key:
  1092. Project: ()
  1093. →Stream materialize.public.t1
  1094. Source materialize.public.t1
  1095. Target cluster: quickstart
  1096. EOF
  1097. query T multiline
  1098. EXPLAIN WITH(humanized expressions)
  1099. SELECT first_value(x) OVER (ORDER BY x || x ROWS BETWEEN 5 preceding AND CURRENT ROW)
  1100. FROM t1;
  1101. ----
  1102. Explained Query:
  1103. →Map/Filter/Project
  1104. Project: #1
  1105. Map: record_get[0](#0)
  1106. →Fused Table Function unnest_list
  1107. →Non-incremental GroupAggregate
  1108. Aggregation: first_value[order_by=[#0 asc nulls_last] rows between 5 preceding and current row](row(row(row(#0), #0{x}), (#0{x} || #0{x})))
  1109. Key:
  1110. Project: ()
  1111. →Stream materialize.public.t1
  1112. Source materialize.public.t1
  1113. Target cluster: quickstart
  1114. EOF
  1115. ## "Used indexes" tests
  1116. statement ok
  1117. CREATE TABLE t (
  1118. a int,
  1119. b int
  1120. );
  1121. statement ok
  1122. CREATE TABLE u (
  1123. c int,
  1124. d int
  1125. );
  1126. # If two indexes exist on the same table, then "Used indexes" should print the one that we are actually going to use
  1127. statement ok
  1128. CREATE INDEX u_c ON u(c);
  1129. statement ok
  1130. CREATE INDEX u_d ON u(d);
  1131. query T multiline
  1132. EXPLAIN WITH(humanized expressions)
  1133. SELECT *
  1134. FROM t, u
  1135. WHERE t.b = u.c;
  1136. ----
  1137. Explained Query:
  1138. →Differential Join %1 » %0
  1139. Join stage 0 in %0 with lookup key #1{b}
  1140. →Arrange (#1{b})
  1141. →Read materialize.public.t
  1142. →Arranged materialize.public.u
  1143. Source materialize.public.t
  1144. filter=((#1{b}) IS NOT NULL)
  1145. Used Indexes:
  1146. - materialize.public.u_c (differential join)
  1147. Target cluster: quickstart
  1148. EOF
  1149. query T multiline
  1150. EXPLAIN WITH(humanized expressions)
  1151. SELECT *
  1152. FROM t, u
  1153. WHERE t.b = u.d;
  1154. ----
  1155. Explained Query:
  1156. →Differential Join %1 » %0
  1157. Join stage 0 in %0 with lookup key #1{b}
  1158. →Arrange (#1{b})
  1159. →Read materialize.public.t
  1160. →Arranged materialize.public.u
  1161. Source materialize.public.t
  1162. filter=((#1{b}) IS NOT NULL)
  1163. Used Indexes:
  1164. - materialize.public.u_d (differential join)
  1165. Target cluster: quickstart
  1166. EOF
  1167. statement ok
  1168. DROP INDEX u_c;
  1169. # Let's test the weird situation that two identical indexes exist.
  1170. statement ok
  1171. CREATE INDEX t_a_idx_1 ON t(a);
  1172. statement ok
  1173. CREATE INDEX t_a_idx_2 ON t(a);
  1174. query T multiline
  1175. EXPLAIN WITH(humanized expressions)
  1176. SELECT *
  1177. FROM t, u
  1178. WHERE t.a = u.c
  1179. ----
  1180. Explained Query:
  1181. →Differential Join %0 » %1
  1182. Join stage 0 in %1 with lookup key #0{c}
  1183. →Arranged materialize.public.t
  1184. →Arrange (#0{c})
  1185. →Fused Map/Filter/Project
  1186. Project: #1, #0
  1187. Filter: (#1{c}) IS NOT NULL
  1188. →Arranged materialize.public.u
  1189. Key: (#1{d})
  1190. Used Indexes:
  1191. - materialize.public.u_d (*** full scan ***)
  1192. - materialize.public.t_a_idx_1 (differential join)
  1193. Target cluster: quickstart
  1194. EOF
  1195. # An index is used two times by the same (self) join. We should show a 1st input and a non-1st input usage.
  1196. query T multiline
  1197. EXPLAIN WITH(humanized expressions)
  1198. SELECT *
  1199. FROM t AS t1, t AS t2, t AS t3
  1200. WHERE t1.a = t2.a AND t2.a = t3.a;
  1201. ----
  1202. Explained Query:
  1203. →With
  1204. cte l0 =
  1205. →Arranged materialize.public.t
  1206. →Return
  1207. →Delta Join [%0 » %1 » %2] [%1 » %0 » %2] [%2 » %0 » %1]
  1208. Delta join path for input %0
  1209. stage 0 for %1: lookup key #0{a}
  1210. stage 1 for %2: lookup key #0{a}
  1211. Delta join path for input %1
  1212. stage 0 for %0: lookup key #0{a}
  1213. project=(#0, #2, #0, #1)
  1214. filter=((#0{a}) IS NOT NULL)
  1215. stage 1 for %2: lookup key #0{a}
  1216. Delta join path for input %2
  1217. stage 0 for %0: lookup key #0{a}
  1218. project=(#0, #2, #0, #1)
  1219. filter=((#0{a}) IS NOT NULL)
  1220. stage 1 for %1: lookup key #0{a}
  1221. →Arranged l0
  1222. →Arranged l0
  1223. →Arranged l0
  1224. Used Indexes:
  1225. - materialize.public.t_a_idx_1 (delta join lookup, delta join 1st input (full scan))
  1226. Target cluster: quickstart
  1227. EOF
  1228. # An index is used in both a join and a full scan.
  1229. query T multiline
  1230. EXPLAIN WITH(humanized expressions)
  1231. (SELECT t1.a + t2.a AS a, t1.b + t2.b AS b
  1232. FROM t AS t1, t AS t2
  1233. WHERE t1.a = t2.a)
  1234. UNION
  1235. (SELECT *
  1236. FROM t
  1237. WHERE b > 5)
  1238. ----
  1239. Explained Query:
  1240. →With
  1241. cte l0 =
  1242. →Arranged materialize.public.t
  1243. →Return
  1244. →Distinct GroupAggregate
  1245. →Union
  1246. →Differential Join %0 » %1
  1247. Join stage 0 in %1 with lookup key #0{a}
  1248. project=(#3, #4)
  1249. filter=((#0{a}) IS NOT NULL)
  1250. map=((#0{a} + #0{a}), (#1{b} + #2{b}))
  1251. →Arranged l0
  1252. →Arranged l0
  1253. →Fused Map/Filter/Project
  1254. Filter: (#1{b} > 5)
  1255. →Arranged materialize.public.t
  1256. Key: (#0{a})
  1257. Used Indexes:
  1258. - materialize.public.t_a_idx_1 (*** full scan ***, differential join)
  1259. Target cluster: quickstart
  1260. EOF
  1261. # An index exists that can't be used for the join because of having the wrong key.
  1262. query T multiline
  1263. EXPLAIN WITH(humanized expressions)
  1264. (SELECT t1.a + t2.a AS a, t1.b + t2.b AS b
  1265. FROM t AS t1, t AS t2
  1266. WHERE t1.b = t2.b)
  1267. UNION
  1268. (SELECT *
  1269. FROM t
  1270. WHERE b > 5)
  1271. ----
  1272. Explained Query:
  1273. →With
  1274. cte l0 =
  1275. →Arrange (#1{b})
  1276. →Fused Map/Filter/Project
  1277. Filter: (#1{b}) IS NOT NULL
  1278. →Arranged materialize.public.t
  1279. Key: (#0{a})
  1280. →Return
  1281. →Distinct GroupAggregate
  1282. →Union
  1283. →Differential Join %0 » %1
  1284. Join stage 0 in %1 with lookup key #1{b}
  1285. project=(#3, #4)
  1286. map=((#1{a} + #2{a}), (#0{b} + #0{b}))
  1287. →Arranged l0
  1288. →Arranged l0
  1289. →Fused Map/Filter/Project
  1290. Filter: (#1{b} > 5)
  1291. →Arranged materialize.public.t
  1292. Key: (#0{a})
  1293. Used Indexes:
  1294. - materialize.public.t_a_idx_1 (*** full scan ***)
  1295. Target cluster: quickstart
  1296. EOF
  1297. # Similar to the previous test, but exercises the full scan code inside the context loop of the Get case in
  1298. # `collect_index_reqs_inner`, where we don't have an index for the requested key.
  1299. statement ok
  1300. CREATE TABLE t_non_null (
  1301. a int NOT NULL,
  1302. b int NOT NULL
  1303. );
  1304. statement ok
  1305. CREATE INDEX t_non_null_a_idx ON t_non_null(a);
  1306. query T multiline
  1307. EXPLAIN WITH(humanized expressions)
  1308. (SELECT t1.a + t2.a AS a, t1.b + t2.b AS b
  1309. FROM t_non_null AS t1, t_non_null AS t2
  1310. WHERE t1.b = t2.b)
  1311. UNION
  1312. (SELECT *
  1313. FROM t_non_null
  1314. WHERE b > 5)
  1315. ----
  1316. Explained Query:
  1317. →With
  1318. cte l0 =
  1319. →Arrange (#1{b})
  1320. →Arranged materialize.public.t_non_null
  1321. →Return
  1322. →Distinct GroupAggregate
  1323. →Union
  1324. →Differential Join %0 » %1
  1325. Join stage 0 in %1 with lookup key #1{b}
  1326. project=(#3, #4)
  1327. map=((#1{a} + #2{a}), (#0{b} + #0{b}))
  1328. →Arranged l0
  1329. →Arranged l0
  1330. →Fused Map/Filter/Project
  1331. Filter: (#1{b} > 5)
  1332. →Arranged materialize.public.t_non_null
  1333. Key: (#0{a})
  1334. Used Indexes:
  1335. - materialize.public.t_non_null_a_idx (*** full scan ***)
  1336. Target cluster: quickstart
  1337. EOF
  1338. # This has 1 more full scan than the previous test, because the join needs 2 different arrangements.
  1339. # (But we print only one full scan due to deduplication.)
  1340. query T multiline
  1341. EXPLAIN WITH(humanized expressions)
  1342. (SELECT t1.a + t2.a AS a, t1.b + t2.b AS b
  1343. FROM t_non_null AS t1, t_non_null AS t2
  1344. WHERE t1.b = t2.b + 1)
  1345. UNION
  1346. (SELECT *
  1347. FROM t_non_null
  1348. WHERE b > 5)
  1349. ----
  1350. Explained Query:
  1351. →Distinct GroupAggregate
  1352. →Union
  1353. →Differential Join %0 » %1
  1354. Join stage 0 in %1 with lookup key (#1{b} + 1)
  1355. project=(#4, #5)
  1356. map=((#1{a} + #2{a}), (#0{b} + #3{b}))
  1357. →Arrange (#1{b})
  1358. →Arranged materialize.public.t_non_null
  1359. →Arrange ((#1{b} + 1))
  1360. →Arranged materialize.public.t_non_null
  1361. →Fused Map/Filter/Project
  1362. Filter: (#1{b} > 5)
  1363. →Arranged materialize.public.t_non_null
  1364. Key: (#0{a})
  1365. Used Indexes:
  1366. - materialize.public.t_non_null_a_idx (*** full scan ***)
  1367. Target cluster: quickstart
  1368. EOF
  1369. # An index is used in both a lookup and a full scan.
  1370. query T multiline
  1371. EXPLAIN WITH(humanized expressions)
  1372. SELECT * FROM t
  1373. UNION
  1374. SELECT * FROM t WHERE a = 5;
  1375. ----
  1376. Explained Query:
  1377. →Distinct GroupAggregate
  1378. →Union
  1379. →Unarranged Raw Stream
  1380. →Arranged materialize.public.t
  1381. →Differential Join %1 » %0
  1382. Join stage 0 in %0 with lookup key #0{a}
  1383. →Arranged materialize.public.t
  1384. →Arrange (#0)
  1385. →Constant (1 row)
  1386. Used Indexes:
  1387. - materialize.public.t_a_idx_2 (*** full scan ***, lookup)
  1388. Target cluster: quickstart
  1389. EOF
  1390. # Several lookups using different indexes
  1391. statement ok
  1392. CREATE INDEX t_b_idx ON t(b);
  1393. query T multiline
  1394. EXPLAIN WITH(humanized expressions)
  1395. SELECT * FROM t
  1396. UNION ALL
  1397. SELECT * FROM t WHERE b = 7
  1398. UNION ALL
  1399. SELECT * FROM t WHERE a = 5
  1400. UNION ALL
  1401. SELECT * FROM u WHERE c = 3
  1402. UNION ALL
  1403. SELECT * FROM u WHERE d = 1;
  1404. ----
  1405. Explained Query:
  1406. →Union
  1407. →Unarranged Raw Stream
  1408. →Arranged materialize.public.t
  1409. →Differential Join %1 » %0
  1410. Join stage 0 in %0 with lookup key #1{b}
  1411. →Arranged materialize.public.t
  1412. →Arrange (#0)
  1413. →Constant (1 row)
  1414. →Differential Join %1 » %0
  1415. Join stage 0 in %0 with lookup key #0{a}
  1416. →Arranged materialize.public.t
  1417. →Arrange (#0)
  1418. →Constant (1 row)
  1419. →Fused Map/Filter/Project
  1420. Project: #1, #0
  1421. Filter: (#1{c} = 3)
  1422. →Arranged materialize.public.u
  1423. Key: (#1{d})
  1424. →Differential Join %1 » %0
  1425. Join stage 0 in %0 with lookup key #1{d}
  1426. →Arranged materialize.public.u
  1427. →Arrange (#0)
  1428. →Constant (1 row)
  1429. Used Indexes:
  1430. - materialize.public.u_d (*** full scan ***, lookup)
  1431. - materialize.public.t_a_idx_2 (lookup)
  1432. - materialize.public.t_b_idx (*** full scan ***, lookup)
  1433. Target cluster: quickstart
  1434. EOF
  1435. # Fast path with a LIMIT and no ORDER BY. This is not a full scan.
  1436. query T multiline
  1437. EXPLAIN WITH(humanized expressions)
  1438. SELECT a+b as x
  1439. FROM t
  1440. WHERE a < 7
  1441. LIMIT 3;
  1442. ----
  1443. Explained Query (fast path):
  1444. Finish limit=3 output=[#0]
  1445. →Map/Filter/Project
  1446. Project: #2
  1447. Filter: (#0{a} < 7)
  1448. Map: (#0{a} + #1{b})
  1449. →Indexed materialize.public.t (using materialize.public.t_a_idx_1)
  1450. Used Indexes:
  1451. - materialize.public.t_a_idx_1 (fast path limit)
  1452. Target cluster: quickstart
  1453. EOF
  1454. # Same query without a LIMIT, so full scan
  1455. query T multiline
  1456. EXPLAIN WITH(humanized expressions)
  1457. SELECT a+b as x
  1458. FROM t
  1459. WHERE a < 7;
  1460. ----
  1461. Explained Query (fast path):
  1462. →Map/Filter/Project
  1463. Project: #2
  1464. Filter: (#0{a} < 7)
  1465. Map: (#0{a} + #1{b})
  1466. →Indexed materialize.public.t (using materialize.public.t_a_idx_1)
  1467. Used Indexes:
  1468. - materialize.public.t_a_idx_1 (*** full scan ***)
  1469. Target cluster: quickstart
  1470. EOF
  1471. # Same query with a LIMIT + ORDER BY, so full scan
  1472. query T multiline
  1473. EXPLAIN WITH(humanized expressions)
  1474. SELECT a+b as x
  1475. FROM t
  1476. WHERE a < 7
  1477. ORDER BY x
  1478. LIMIT 3;
  1479. ----
  1480. Explained Query (fast path):
  1481. Finish order_by=[#0 asc nulls_last] limit=3 output=[#0]
  1482. →Map/Filter/Project
  1483. Project: #2
  1484. Filter: (#0{a} < 7)
  1485. Map: (#0{a} + #1{b})
  1486. →Indexed materialize.public.t (using materialize.public.t_a_idx_1)
  1487. Used Indexes:
  1488. - materialize.public.t_a_idx_1 (*** full scan ***)
  1489. Target cluster: quickstart
  1490. EOF
  1491. # We should choose an index whose key is a unique key (if exists)
  1492. statement ok
  1493. CREATE TABLE t4(
  1494. a int,
  1495. b int primary key,
  1496. c int
  1497. );
  1498. statement ok
  1499. CREATE INDEX t4_idx_a ON t4(a);
  1500. statement ok
  1501. CREATE INDEX t4_idx_b ON t4(b);
  1502. statement ok
  1503. CREATE INDEX t4_idx_c ON t4(c);
  1504. query T multiline
  1505. EXPLAIN WITH(humanized expressions)
  1506. SELECT * FROM t4;
  1507. ----
  1508. Explained Query (fast path):
  1509. →Map/Filter/Project
  1510. Project: #1, #0, #2
  1511. →Indexed materialize.public.t4 (using materialize.public.t4_idx_b)
  1512. Used Indexes:
  1513. - materialize.public.t4_idx_b (*** full scan ***)
  1514. Target cluster: quickstart
  1515. EOF
  1516. # EXPLAIN should work even if there are no replicas.
  1517. statement ok
  1518. CREATE CLUSTER no_replicas (SIZE '1', REPLICATION FACTOR 0);
  1519. statement ok
  1520. SET CLUSTER = no_replicas;
  1521. query T multiline
  1522. EXPLAIN WITH (humanized expressions)
  1523. SELECT * FROM t4;
  1524. ----
  1525. Explained Query:
  1526. →Stream materialize.public.t4
  1527. Source materialize.public.t4
  1528. Target cluster: no_replicas
  1529. EOF
  1530. statement ok
  1531. CREATE TABLE t5(
  1532. x int,
  1533. y int NOT NULL,
  1534. z int
  1535. );
  1536. statement ok
  1537. CREATE TABLE t6(
  1538. a int NOT NULL,
  1539. b int
  1540. );
  1541. # WITH(EQUIVALENCES)
  1542. query T multiline
  1543. EXPLAIN WITH(EQUIVALENCES, humanized expressions)
  1544. SELECT *
  1545. FROM t5, t6
  1546. WHERE x = a AND b IN (8,9);
  1547. ----
  1548. Explained Query:
  1549. →Differential Join %1 » %0
  1550. Join stage 0 in %0 with lookup key #0{x}
  1551. →Arrange (#0{x})
  1552. →Read materialize.public.t5
  1553. →Arrange (#0{a})
  1554. →Read materialize.public.t6
  1555. Source materialize.public.t5
  1556. filter=((#0{x}) IS NOT NULL)
  1557. Source materialize.public.t6
  1558. filter=(((#1{b} = 8) OR (#1{b} = 9)))
  1559. Target cluster: no_replicas
  1560. EOF
  1561. query T multiline
  1562. EXPLAIN WITH(EQUIVALENCES, HUMANIZED EXPRESSIONS)
  1563. SELECT *
  1564. FROM t5, t6
  1565. WHERE x = a AND b IN (8,9);
  1566. ----
  1567. Explained Query:
  1568. →Differential Join %1 » %0
  1569. Join stage 0 in %0 with lookup key #0{x}
  1570. →Arrange (#0{x})
  1571. →Read materialize.public.t5
  1572. →Arrange (#0{a})
  1573. →Read materialize.public.t6
  1574. Source materialize.public.t5
  1575. filter=((#0{x}) IS NOT NULL)
  1576. Source materialize.public.t6
  1577. filter=(((#1{b} = 8) OR (#1{b} = 9)))
  1578. Target cluster: no_replicas
  1579. EOF
  1580. # `count(*)` is planned as `count(true)`. We take care in EXPLAIN to show `count(true)` as `count(*)` to avoid confusing
  1581. # users.
  1582. query T multiline
  1583. EXPLAIN WITH (humanized expressions)
  1584. SELECT count(*)
  1585. FROM t5;
  1586. ----
  1587. Explained Query:
  1588. →With
  1589. cte l0 =
  1590. →Accumulable GroupAggregate
  1591. Simple aggregates: count(*)
  1592. →Read materialize.public.t5
  1593. →Return
  1594. →Union
  1595. →Unarranged Raw Stream
  1596. →Arranged l0
  1597. →Map/Filter/Project
  1598. Project: #0
  1599. Map: 0
  1600. →Consolidating Union
  1601. →Negate Diffs
  1602. →Fused Map/Filter/Project
  1603. Project: ()
  1604. →Arranged l0
  1605. Key: ()
  1606. →Constant (1 row)
  1607. Source materialize.public.t5
  1608. project=()
  1609. Target cluster: no_replicas
  1610. EOF
  1611. query error DISTINCT \* not supported as function args
  1612. EXPLAIN WITH (humanized expressions)
  1613. SELECT count(distinct *)
  1614. FROM t5;
  1615. # `count(true)` is currently also printed as `count(*)` in EXPLAIN, which I'd say is fine.
  1616. query T multiline
  1617. EXPLAIN WITH (humanized expressions)
  1618. SELECT count(true)
  1619. FROM t5;
  1620. ----
  1621. Explained Query:
  1622. →With
  1623. cte l0 =
  1624. →Accumulable GroupAggregate
  1625. Simple aggregates: count(*)
  1626. →Read materialize.public.t5
  1627. →Return
  1628. →Union
  1629. →Unarranged Raw Stream
  1630. →Arranged l0
  1631. →Map/Filter/Project
  1632. Project: #0
  1633. Map: 0
  1634. →Consolidating Union
  1635. →Negate Diffs
  1636. →Fused Map/Filter/Project
  1637. Project: ()
  1638. →Arranged l0
  1639. Key: ()
  1640. →Constant (1 row)
  1641. Source materialize.public.t5
  1642. project=()
  1643. Target cluster: no_replicas
  1644. EOF
  1645. # But `count(DISTINCT true)` means an entirely different thing, so EXPLAIN shouldn't conflate it with `count(*)`.
  1646. query T multiline
  1647. EXPLAIN WITH (humanized expressions)
  1648. SELECT count(DISTINCT true)
  1649. FROM t5;
  1650. ----
  1651. Explained Query:
  1652. →With
  1653. cte l0 =
  1654. →Accumulable GroupAggregate
  1655. Distinct aggregates: count(distinct true)
  1656. →Read materialize.public.t5
  1657. →Return
  1658. →Union
  1659. →Unarranged Raw Stream
  1660. →Arranged l0
  1661. →Map/Filter/Project
  1662. Project: #0
  1663. Map: 0
  1664. →Consolidating Union
  1665. →Negate Diffs
  1666. →Fused Map/Filter/Project
  1667. Project: ()
  1668. →Arranged l0
  1669. Key: ()
  1670. →Constant (1 row)
  1671. Source materialize.public.t5
  1672. project=()
  1673. Target cluster: no_replicas
  1674. EOF
  1675. # OFFSET clause in RowSetFinishing
  1676. query T multiline
  1677. EXPLAIN WITH (humanized expressions)
  1678. SELECT a+b
  1679. FROM t4
  1680. OFFSET 1;
  1681. ----
  1682. Explained Query:
  1683. Finish offset=1 output=[#0]
  1684. →Read materialize.public.t4
  1685. Source materialize.public.t4
  1686. project=(#3)
  1687. map=((#0{a} + #1{b}))
  1688. Target cluster: no_replicas
  1689. EOF
  1690. # OFFSET clause in TopK
  1691. query T multiline
  1692. EXPLAIN
  1693. SELECT a+b, (SELECT a*b FROM t4 OFFSET 1)
  1694. FROM t4;
  1695. ----
  1696. Explained Query:
  1697. →With
  1698. cte l0 =
  1699. →Non-monotonic TopK
  1700. Offset 1
  1701. →Fused Map/Filter/Project
  1702. Project: #2
  1703. Map: (#0{a} * #1{b})
  1704. →Read materialize.public.t4
  1705. cte l1 =
  1706. →Union
  1707. →Stream l0
  1708. →Table Function guard_subquery_size(#0)
  1709. →Accumulable GroupAggregate
  1710. Simple aggregates: count(*)
  1711. →Fused Map/Filter/Project
  1712. Project: ()
  1713. →Read l0
  1714. →Return
  1715. →Differential Join %0 » %1
  1716. Join stage 0 in %1
  1717. project=(#3, #2)
  1718. map=((#0{a} + #1{b}))
  1719. →Arrange (empty key)
  1720. →Read materialize.public.t4
  1721. →Arrange (empty key)
  1722. →Union
  1723. →Stream l1
  1724. →Map/Filter/Project
  1725. Project: #0
  1726. Map: null
  1727. →Consolidating Union
  1728. →Negate Diffs
  1729. →Unarranged Raw Stream
  1730. →Distinct GroupAggregate
  1731. →Fused Map/Filter/Project
  1732. Project: ()
  1733. →Read l1
  1734. →Constant (1 row)
  1735. Source materialize.public.t4
  1736. project=(#0, #1)
  1737. Target cluster: no_replicas
  1738. EOF
  1739. # distinct input keys
  1740. query T multiline
  1741. EXPLAIN
  1742. WITH
  1743. t_as AS (SELECT DISTINCT a from t),
  1744. t_bs AS (SELECT DISTINCT b from t)
  1745. SELECT a, b, a = b FROM t_as, t_bs
  1746. ----
  1747. Explained Query:
  1748. →Differential Join %0 » %1
  1749. Join stage 0 in %1
  1750. project=(#0..=#2)
  1751. map=((#0{a} = #1{b}))
  1752. →Arrange (empty key)
  1753. →Distinct GroupAggregate
  1754. →Fused Map/Filter/Project
  1755. Project: #0
  1756. →Read materialize.public.t
  1757. →Arrange (empty key)
  1758. →Distinct GroupAggregate
  1759. →Fused Map/Filter/Project
  1760. Project: #1
  1761. →Read materialize.public.t
  1762. Target cluster: no_replicas
  1763. EOF