aoc_1207.slt 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076
  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. # https://github.com/MaterializeInc/advent-of-code-2023/blob/main/week1/aoc_1207.md
  10. mode cockroach
  11. statement ok
  12. CREATE TABLE input (input TEXT);
  13. statement ok
  14. INSERT INTO input VALUES (
  15. '67AJ5 568
  16. 79Q36 923
  17. 99325 894
  18. 8JK7Q 177
  19. 5J663 919
  20. 82574 158
  21. 229T2 817
  22. 355A6 917
  23. K43K3 767
  24. 92765 525
  25. 8QKT8 129
  26. 35J28 541
  27. 4967J 132
  28. 784T9 621
  29. 6A6A9 327
  30. 9KAJ4 643
  31. 9T479 463
  32. 6QT5K 932
  33. Q7T66 738
  34. 4333T 611
  35. 8TJ29 215
  36. 7TT7Q 472
  37. 9T8J6 275
  38. 66Q85 835
  39. KTA66 697
  40. TA876 326
  41. 27858 512
  42. 79Q99 749
  43. AA5QA 457
  44. 792K6 762
  45. KK6TA 635
  46. 5KT55 349
  47. TQ495 158
  48. 5J2TK 432');
  49. query II
  50. WITH MUTUALLY RECURSIVE
  51. lines(line TEXT) AS ( SELECT regexp_split_to_table(input, '\n') FROM input ),
  52. hands(hand TEXT, bid INT) as (
  53. SELECT regexp_split_to_array(line, ' ')[1],
  54. regexp_split_to_array(line, ' ')[2]::INT
  55. FROM lines
  56. ),
  57. cards(hand TEXT, value TEXT, position INT) AS (
  58. SELECT hand, substring(hand, pos, 1), pos
  59. FROM hands, generate_series(1, 5) pos
  60. ),
  61. -- Part1
  62. counts(hand TEXT, value TEXT, count INT) AS (
  63. SELECT hand, value, COUNT(*)
  64. FROM cards
  65. GROUP BY hand, value
  66. ),
  67. ranked(hand TEXT, bid INT, rank INT, score TEXT) AS (
  68. SELECT
  69. hand,
  70. bid,
  71. CASE WHEN hand IN (SELECT hand FROM counts WHERE count = 5) THEN 1
  72. WHEN hand IN (SELECT hand FROM counts WHERE count = 4) THEN 2
  73. WHEN hand IN (SELECT hand FROM counts WHERE count = 3)
  74. AND hand IN (SELECT hand FROM counts WHERE count = 2) THEN 3
  75. WHEN hand IN (SELECT hand FROM counts WHERE count = 3) THEN 4
  76. WHEN hand IN (SELECT hand FROM (SELECT hand FROM counts WHERE count = 2) GROUP BY hand HAVING COUNT(*) = 2) THEN 5
  77. WHEN hand IN (SELECT hand FROM counts WHERE count = 2) THEN 6
  78. ELSE 7
  79. END,
  80. translate(hand, 'AKQJT98765432', 'ABCDEFGHIJKLM')
  81. FROM
  82. hands
  83. ),
  84. part1(part1 INT) AS (
  85. SELECT SUM(r1.bid)
  86. FROM ranked r1, ranked r2
  87. WHERE r1.rank < r2.rank OR (r1.rank = r2.rank AND r1.score <= r2.score)
  88. ),
  89. -- Part2: J are now wild for determining rank, but last for score.
  90. wild(hand TEXT, value TEXT, position INT) AS (
  91. SELECT * FROM cards
  92. UNION
  93. SELECT c1.hand, c2.value, c1.position
  94. FROM cards c1, cards c2
  95. WHERE c1.hand = c2.hand
  96. AND c1.value = 'J'
  97. ),
  98. wild_hands(hand TEXT, new_hand TEXT) AS (
  99. SELECT DISTINCT w1.hand, w1.value || w2.value || w3.value || w4.value || w5.value
  100. FROM (SELECT * FROM wild w1 WHERE position = 1) w1,
  101. (SELECT * FROM wild w2 WHERE position = 2) w2,
  102. (SELECT * FROM wild w3 WHERE position = 3) w3,
  103. (SELECT * FROM wild w4 WHERE position = 4) w4,
  104. (SELECT * FROM wild w5 WHERE position = 5) w5
  105. WHERE w1.hand = w2.hand
  106. AND w1.hand = w3.hand
  107. AND w1.hand = w4.hand
  108. AND w1.hand = w5.hand
  109. ),
  110. wild_cards(hand TEXT, value TEXT, position INT) AS (
  111. SELECT DISTINCT new_hand, substring(new_hand, pos, 1), pos
  112. FROM wild_hands, generate_series(1, 5) pos
  113. ),
  114. wild_counts(hand TEXT, value TEXT, count INT) AS (
  115. SELECT hand, value, COUNT(*)
  116. FROM wild_cards
  117. GROUP BY hand, value
  118. ),
  119. wild_ranked(hand TEXT, new_hand TEXT, rank INT, score TEXT) AS (
  120. SELECT
  121. hand,
  122. new_hand,
  123. CASE WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 5) THEN 1
  124. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 4) THEN 2
  125. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 3)
  126. AND new_hand IN (SELECT hand FROM wild_counts WHERE count = 2) THEN 3
  127. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 3) THEN 4
  128. WHEN new_hand IN (SELECT hand FROM (SELECT hand FROM wild_counts WHERE count = 2) GROUP BY hand HAVING COUNT(*) = 2) THEN 5
  129. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 2) THEN 6
  130. ELSE 7
  131. END,
  132. translate(hand, 'AKQT98765432J', 'ABCDEFGHIJKLM')
  133. FROM
  134. wild_hands
  135. ),
  136. best_hands(hand TEXT, new_hand TEXT, rank INT, score TEXT) AS (
  137. SELECT DISTINCT ON (hand) hand, new_hand, rank, score
  138. FROM wild_ranked
  139. ORDER BY hand, rank, score
  140. ),
  141. wild_bids(hand TEXT, bid INT, rank INT, score TEXT) AS (
  142. SELECT hands.hand, hands.bid, rank, score
  143. FROM hands, best_hands
  144. WHERE hands.hand = best_hands.hand
  145. ),
  146. part2(part2 INT) AS (
  147. SELECT SUM(r1.bid)
  148. FROM wild_bids r1, wild_bids r2
  149. WHERE r1.rank < r2.rank OR (r1.rank = r2.rank AND r1.score <= r2.score)
  150. )
  151. SELECT * FROM part1, part2;
  152. ----
  153. 340665 332531
  154. query T multiline
  155. EXPLAIN OPTIMIZED PLAN WITH(humanized expressions, arity, join implementations) AS VERBOSE TEXT FOR
  156. WITH MUTUALLY RECURSIVE
  157. lines(line TEXT) AS ( SELECT regexp_split_to_table(input, '\n') FROM input ),
  158. hands(hand TEXT, bid INT) as (
  159. SELECT regexp_split_to_array(line, ' ')[1],
  160. regexp_split_to_array(line, ' ')[2]::INT
  161. FROM lines
  162. ),
  163. cards(hand TEXT, value TEXT, position INT) AS (
  164. SELECT hand, substring(hand, pos, 1), pos
  165. FROM hands, generate_series(1, 5) pos
  166. ),
  167. -- Part1
  168. counts(hand TEXT, value TEXT, count INT) AS (
  169. SELECT hand, value, COUNT(*)
  170. FROM cards
  171. GROUP BY hand, value
  172. ),
  173. ranked(hand TEXT, bid INT, rank INT, score TEXT) AS (
  174. SELECT
  175. hand,
  176. bid,
  177. CASE WHEN hand IN (SELECT hand FROM counts WHERE count = 5) THEN 1
  178. WHEN hand IN (SELECT hand FROM counts WHERE count = 4) THEN 2
  179. WHEN hand IN (SELECT hand FROM counts WHERE count = 3)
  180. AND hand IN (SELECT hand FROM counts WHERE count = 2) THEN 3
  181. WHEN hand IN (SELECT hand FROM counts WHERE count = 3) THEN 4
  182. WHEN hand IN (SELECT hand FROM (SELECT hand FROM counts WHERE count = 2) GROUP BY hand HAVING COUNT(*) = 2) THEN 5
  183. WHEN hand IN (SELECT hand FROM counts WHERE count = 2) THEN 6
  184. ELSE 7
  185. END,
  186. translate(hand, 'AKQJT98765432', 'ABCDEFGHIJKLM')
  187. FROM
  188. hands
  189. ),
  190. part1(part1 INT) AS (
  191. SELECT SUM(r1.bid)
  192. FROM ranked r1, ranked r2
  193. WHERE r1.rank < r2.rank OR (r1.rank = r2.rank AND r1.score <= r2.score)
  194. ),
  195. -- Part2: J are now wild for determining rank, but last for score.
  196. wild(hand TEXT, value TEXT, position INT) AS (
  197. SELECT * FROM cards
  198. UNION
  199. SELECT c1.hand, c2.value, c1.position
  200. FROM cards c1, cards c2
  201. WHERE c1.hand = c2.hand
  202. AND c1.value = 'J'
  203. ),
  204. wild_hands(hand TEXT, new_hand TEXT) AS (
  205. SELECT DISTINCT w1.hand, w1.value || w2.value || w3.value || w4.value || w5.value
  206. FROM (SELECT * FROM wild w1 WHERE position = 1) w1,
  207. (SELECT * FROM wild w2 WHERE position = 2) w2,
  208. (SELECT * FROM wild w3 WHERE position = 3) w3,
  209. (SELECT * FROM wild w4 WHERE position = 4) w4,
  210. (SELECT * FROM wild w5 WHERE position = 5) w5
  211. WHERE w1.hand = w2.hand
  212. AND w1.hand = w3.hand
  213. AND w1.hand = w4.hand
  214. AND w1.hand = w5.hand
  215. ),
  216. wild_cards(hand TEXT, value TEXT, position INT) AS (
  217. SELECT DISTINCT new_hand, substring(new_hand, pos, 1), pos
  218. FROM wild_hands, generate_series(1, 5) pos
  219. ),
  220. wild_counts(hand TEXT, value TEXT, count INT) AS (
  221. SELECT hand, value, COUNT(*)
  222. FROM wild_cards
  223. GROUP BY hand, value
  224. ),
  225. wild_ranked(hand TEXT, new_hand TEXT, rank INT, score TEXT) AS (
  226. SELECT
  227. hand,
  228. new_hand,
  229. CASE WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 5) THEN 1
  230. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 4) THEN 2
  231. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 3)
  232. AND new_hand IN (SELECT hand FROM wild_counts WHERE count = 2) THEN 3
  233. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 3) THEN 4
  234. WHEN new_hand IN (SELECT hand FROM (SELECT hand FROM wild_counts WHERE count = 2) GROUP BY hand HAVING COUNT(*) = 2) THEN 5
  235. WHEN new_hand IN (SELECT hand FROM wild_counts WHERE count = 2) THEN 6
  236. ELSE 7
  237. END,
  238. translate(hand, 'AKQT98765432J', 'ABCDEFGHIJKLM')
  239. FROM
  240. wild_hands
  241. ),
  242. best_hands(hand TEXT, new_hand TEXT, rank INT, score TEXT) AS (
  243. SELECT DISTINCT ON (hand) hand, new_hand, rank, score
  244. FROM wild_ranked
  245. ORDER BY hand, rank, score
  246. ),
  247. wild_bids(hand TEXT, bid INT, rank INT, score TEXT) AS (
  248. SELECT hands.hand, hands.bid, rank, score
  249. FROM hands, best_hands
  250. WHERE hands.hand = best_hands.hand
  251. ),
  252. part2(part2 INT) AS (
  253. SELECT SUM(r1.bid)
  254. FROM wild_bids r1, wild_bids r2
  255. WHERE r1.rank < r2.rank OR (r1.rank = r2.rank AND r1.score <= r2.score)
  256. )
  257. SELECT * FROM part1, part2;
  258. ----
  259. Explained Query:
  260. With
  261. cte l0 =
  262. Project (#3, #4) // { arity: 2 }
  263. Map (regexp_split_to_array[" ", case_insensitive=false](#1{line}), array_index(#2, 1), text_to_integer(array_index(#2, 2))) // { arity: 5 }
  264. FlatMap unnest_array(regexp_split_to_array["\n", case_insensitive=false](#0{input})) // { arity: 2 }
  265. ReadStorage materialize.public.input // { arity: 1 }
  266. cte l1 =
  267. Project (#0) // { arity: 1 }
  268. Get l0 // { arity: 2 }
  269. cte l2 =
  270. ArrangeBy keys=[[]] // { arity: 1 }
  271. Constant // { arity: 1 }
  272. - (1)
  273. - (2)
  274. - (3)
  275. - (4)
  276. - (5)
  277. cte l3 =
  278. Map (substr(#0{hand}, #1{pos}, 1)) // { arity: 3 }
  279. CrossJoin type=differential // { arity: 2 }
  280. implementation
  281. %0:l1[×] » %1:l2[×]
  282. ArrangeBy keys=[[]] // { arity: 1 }
  283. Get l1 // { arity: 1 }
  284. Get l2 // { arity: 1 }
  285. cte l4 =
  286. Project (#0, #3) // { arity: 2 }
  287. Map (bigint_to_integer(#2{count})) // { arity: 4 }
  288. Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 }
  289. Project (#0, #2) // { arity: 2 }
  290. Get l3 // { arity: 3 }
  291. cte l5 =
  292. Distinct project=[#0] // { arity: 1 }
  293. Get l1 // { arity: 1 }
  294. cte l6 =
  295. Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_0}))] // { arity: 2 }
  296. CrossJoin type=differential // { arity: 2 }
  297. implementation
  298. %1:l4[×]ef » %0:l5[×]ef
  299. ArrangeBy keys=[[]] // { arity: 1 }
  300. Get l5 // { arity: 1 }
  301. ArrangeBy keys=[[]] // { arity: 1 }
  302. Project (#0) // { arity: 1 }
  303. Filter (#1{count} = 5) // { arity: 2 }
  304. Get l4 // { arity: 2 }
  305. cte l7 =
  306. Union // { arity: 2 }
  307. Get l6 // { arity: 2 }
  308. Map (false) // { arity: 2 }
  309. Union // { arity: 1 }
  310. Negate // { arity: 1 }
  311. Project (#0) // { arity: 1 }
  312. Get l6 // { arity: 2 }
  313. Get l5 // { arity: 1 }
  314. cte l8 =
  315. Project (#0, #1, #3{any}) // { arity: 3 }
  316. Join on=(#0 = #2) type=differential // { arity: 4 }
  317. implementation
  318. %1[#0]UK » %0:l0[#0]K
  319. ArrangeBy keys=[[#0]] // { arity: 2 }
  320. Get l0 // { arity: 2 }
  321. ArrangeBy keys=[[#0]] // { arity: 2 }
  322. Union // { arity: 2 }
  323. Get l7 // { arity: 2 }
  324. Map (null) // { arity: 2 }
  325. Union // { arity: 1 }
  326. Negate // { arity: 1 }
  327. Project (#0) // { arity: 1 }
  328. Get l7 // { arity: 2 }
  329. Get l5 // { arity: 1 }
  330. cte l9 =
  331. Project (#0, #1) // { arity: 2 }
  332. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  333. Get l8 // { arity: 3 }
  334. cte l10 =
  335. Distinct project=[#0] // { arity: 1 }
  336. Project (#0) // { arity: 1 }
  337. Get l9 // { arity: 2 }
  338. cte l11 =
  339. Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_2}))] // { arity: 2 }
  340. CrossJoin type=differential // { arity: 2 }
  341. implementation
  342. %1:l4[×]ef » %0:l10[×]ef
  343. ArrangeBy keys=[[]] // { arity: 1 }
  344. Get l10 // { arity: 1 }
  345. ArrangeBy keys=[[]] // { arity: 1 }
  346. Project (#0) // { arity: 1 }
  347. Filter (#1{count} = 4) // { arity: 2 }
  348. Get l4 // { arity: 2 }
  349. cte l12 =
  350. Union // { arity: 2 }
  351. Get l11 // { arity: 2 }
  352. Map (false) // { arity: 2 }
  353. Union // { arity: 1 }
  354. Negate // { arity: 1 }
  355. Project (#0) // { arity: 1 }
  356. Get l11 // { arity: 2 }
  357. Get l10 // { arity: 1 }
  358. cte l13 =
  359. Project (#0, #1, #3{any}) // { arity: 3 }
  360. Join on=(#0 = #2) type=differential // { arity: 4 }
  361. implementation
  362. %1[#0]UK » %0:l9[#0]Kenf
  363. ArrangeBy keys=[[#0]] // { arity: 2 }
  364. Get l9 // { arity: 2 }
  365. ArrangeBy keys=[[#0]] // { arity: 2 }
  366. Union // { arity: 2 }
  367. Get l12 // { arity: 2 }
  368. Map (null) // { arity: 2 }
  369. Union // { arity: 1 }
  370. Negate // { arity: 1 }
  371. Project (#0) // { arity: 1 }
  372. Get l12 // { arity: 2 }
  373. Get l10 // { arity: 1 }
  374. cte l14 =
  375. Project (#0, #1) // { arity: 2 }
  376. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  377. Get l13 // { arity: 3 }
  378. cte l15 =
  379. Distinct project=[#0] // { arity: 1 }
  380. Project (#0) // { arity: 1 }
  381. Get l14 // { arity: 2 }
  382. cte l16 =
  383. ArrangeBy keys=[[]] // { arity: 1 }
  384. Project (#0) // { arity: 1 }
  385. Filter (#1{count} = 3) // { arity: 2 }
  386. Get l4 // { arity: 2 }
  387. cte l17 =
  388. Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_4}))] // { arity: 2 }
  389. CrossJoin type=differential // { arity: 2 }
  390. implementation
  391. %1:l16[×]ef » %0:l15[×]ef
  392. ArrangeBy keys=[[]] // { arity: 1 }
  393. Get l15 // { arity: 1 }
  394. Get l16 // { arity: 1 }
  395. cte l18 =
  396. Union // { arity: 2 }
  397. Get l17 // { arity: 2 }
  398. Map (false) // { arity: 2 }
  399. Union // { arity: 1 }
  400. Negate // { arity: 1 }
  401. Project (#0) // { arity: 1 }
  402. Get l17 // { arity: 2 }
  403. Get l15 // { arity: 1 }
  404. cte l19 =
  405. Project (#0, #1, #3{any}) // { arity: 3 }
  406. Join on=(#0 = #2) type=differential // { arity: 4 }
  407. implementation
  408. %1[#0]UK » %0:l14[#0]Kenf
  409. ArrangeBy keys=[[#0]] // { arity: 2 }
  410. Get l14 // { arity: 2 }
  411. ArrangeBy keys=[[#0]] // { arity: 2 }
  412. Union // { arity: 2 }
  413. Get l18 // { arity: 2 }
  414. Map (null) // { arity: 2 }
  415. Union // { arity: 1 }
  416. Negate // { arity: 1 }
  417. Project (#0) // { arity: 1 }
  418. Get l18 // { arity: 2 }
  419. Get l15 // { arity: 1 }
  420. cte l20 =
  421. Distinct project=[#0] // { arity: 1 }
  422. Project (#0) // { arity: 1 }
  423. Get l19 // { arity: 3 }
  424. cte l21 =
  425. ArrangeBy keys=[[]] // { arity: 1 }
  426. Project (#0) // { arity: 1 }
  427. Filter (#1{count} = 2) // { arity: 2 }
  428. Get l4 // { arity: 2 }
  429. cte l22 =
  430. Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_6}))] // { arity: 2 }
  431. CrossJoin type=differential // { arity: 2 }
  432. implementation
  433. %1:l21[×]ef » %0:l20[×]ef
  434. ArrangeBy keys=[[]] // { arity: 1 }
  435. Get l20 // { arity: 1 }
  436. Get l21 // { arity: 1 }
  437. cte l23 =
  438. Union // { arity: 2 }
  439. Get l22 // { arity: 2 }
  440. Map (false) // { arity: 2 }
  441. Union // { arity: 1 }
  442. Negate // { arity: 1 }
  443. Project (#0) // { arity: 1 }
  444. Get l22 // { arity: 2 }
  445. Get l20 // { arity: 1 }
  446. cte l24 =
  447. Project (#0..=#2{any}, #4{any}) // { arity: 4 }
  448. Join on=(#0 = #3) type=differential // { arity: 5 }
  449. implementation
  450. %1[#0]UK » %0:l19[#0]K
  451. ArrangeBy keys=[[#0]] // { arity: 3 }
  452. Get l19 // { arity: 3 }
  453. ArrangeBy keys=[[#0]] // { arity: 2 }
  454. Union // { arity: 2 }
  455. Get l23 // { arity: 2 }
  456. Map (null) // { arity: 2 }
  457. Union // { arity: 1 }
  458. Negate // { arity: 1 }
  459. Project (#0) // { arity: 1 }
  460. Get l23 // { arity: 2 }
  461. Get l20 // { arity: 1 }
  462. cte l25 =
  463. Project (#0, #1) // { arity: 2 }
  464. Filter ((#4) IS NULL OR (#4 = false)) // { arity: 5 }
  465. Map ((#2{any} AND #3{any})) // { arity: 5 }
  466. Get l24 // { arity: 4 }
  467. cte l26 =
  468. Distinct project=[#0] // { arity: 1 }
  469. Project (#0) // { arity: 1 }
  470. Get l25 // { arity: 2 }
  471. cte l27 =
  472. Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_8}))] // { arity: 2 }
  473. CrossJoin type=differential // { arity: 2 }
  474. implementation
  475. %1:l16[×]ef » %0:l26[×]ef
  476. ArrangeBy keys=[[]] // { arity: 1 }
  477. Get l26 // { arity: 1 }
  478. Get l16 // { arity: 1 }
  479. cte l28 =
  480. Union // { arity: 2 }
  481. Get l27 // { arity: 2 }
  482. Map (false) // { arity: 2 }
  483. Union // { arity: 1 }
  484. Negate // { arity: 1 }
  485. Project (#0) // { arity: 1 }
  486. Get l27 // { arity: 2 }
  487. Get l26 // { arity: 1 }
  488. cte l29 =
  489. Project (#0, #1, #3{any}) // { arity: 3 }
  490. Join on=(#0 = #2) type=differential // { arity: 4 }
  491. implementation
  492. %1[#0]UK » %0:l25[#0]Kenf
  493. ArrangeBy keys=[[#0]] // { arity: 2 }
  494. Get l25 // { arity: 2 }
  495. ArrangeBy keys=[[#0]] // { arity: 2 }
  496. Union // { arity: 2 }
  497. Get l28 // { arity: 2 }
  498. Map (null) // { arity: 2 }
  499. Union // { arity: 1 }
  500. Negate // { arity: 1 }
  501. Project (#0) // { arity: 1 }
  502. Get l28 // { arity: 2 }
  503. Get l26 // { arity: 1 }
  504. cte l30 =
  505. Project (#0, #1) // { arity: 2 }
  506. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  507. Get l29 // { arity: 3 }
  508. cte l31 =
  509. Distinct project=[#0] // { arity: 1 }
  510. Project (#0) // { arity: 1 }
  511. Get l30 // { arity: 2 }
  512. cte l32 =
  513. Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_10}))] // { arity: 2 }
  514. Project (#0, #1) // { arity: 2 }
  515. Filter (#2{count} = 2) // { arity: 3 }
  516. Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 }
  517. CrossJoin type=differential // { arity: 2 }
  518. implementation
  519. %1:l21[×]ef » %0:l31[×]ef
  520. ArrangeBy keys=[[]] // { arity: 1 }
  521. Get l31 // { arity: 1 }
  522. Get l21 // { arity: 1 }
  523. cte l33 =
  524. Union // { arity: 2 }
  525. Get l32 // { arity: 2 }
  526. Map (false) // { arity: 2 }
  527. Union // { arity: 1 }
  528. Negate // { arity: 1 }
  529. Project (#0) // { arity: 1 }
  530. Get l32 // { arity: 2 }
  531. Get l31 // { arity: 1 }
  532. cte l34 =
  533. Project (#0, #1, #3{any}) // { arity: 3 }
  534. Join on=(#0 = #2) type=differential // { arity: 4 }
  535. implementation
  536. %1[#0]UK » %0:l30[#0]Kenf
  537. ArrangeBy keys=[[#0]] // { arity: 2 }
  538. Get l30 // { arity: 2 }
  539. ArrangeBy keys=[[#0]] // { arity: 2 }
  540. Union // { arity: 2 }
  541. Get l33 // { arity: 2 }
  542. Map (null) // { arity: 2 }
  543. Union // { arity: 1 }
  544. Negate // { arity: 1 }
  545. Project (#0) // { arity: 1 }
  546. Get l33 // { arity: 2 }
  547. Get l31 // { arity: 1 }
  548. cte l35 =
  549. Project (#0, #1) // { arity: 2 }
  550. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  551. Get l34 // { arity: 3 }
  552. cte l36 =
  553. Distinct project=[#0] // { arity: 1 }
  554. Project (#0) // { arity: 1 }
  555. Get l35 // { arity: 2 }
  556. cte l37 =
  557. Reduce group_by=[#0] aggregates=[any((#0{hand} = #1{right_col0_12}))] // { arity: 2 }
  558. CrossJoin type=differential // { arity: 2 }
  559. implementation
  560. %1:l21[×]ef » %0:l36[×]ef
  561. ArrangeBy keys=[[]] // { arity: 1 }
  562. Get l36 // { arity: 1 }
  563. Get l21 // { arity: 1 }
  564. cte l38 =
  565. Union // { arity: 2 }
  566. Get l37 // { arity: 2 }
  567. Map (false) // { arity: 2 }
  568. Union // { arity: 1 }
  569. Negate // { arity: 1 }
  570. Project (#0) // { arity: 1 }
  571. Get l37 // { arity: 2 }
  572. Get l36 // { arity: 1 }
  573. cte l39 =
  574. Project (#1..=#3) // { arity: 3 }
  575. Map (translate(#0{hand}, "AKQJT98765432", "ABCDEFGHIJKLM")) // { arity: 4 }
  576. Union // { arity: 3 }
  577. Project (#0, #1, #3) // { arity: 3 }
  578. Filter #2{any} // { arity: 4 }
  579. Map (1) // { arity: 4 }
  580. Get l8 // { arity: 3 }
  581. Project (#0, #1, #3) // { arity: 3 }
  582. Filter #2{any} // { arity: 4 }
  583. Map (2) // { arity: 4 }
  584. Get l13 // { arity: 3 }
  585. Project (#0, #1, #4) // { arity: 3 }
  586. Filter #2{any} AND #3{any} // { arity: 5 }
  587. Map (3) // { arity: 5 }
  588. Get l24 // { arity: 4 }
  589. Project (#0, #1, #3) // { arity: 3 }
  590. Filter #2{any} // { arity: 4 }
  591. Map (4) // { arity: 4 }
  592. Get l29 // { arity: 3 }
  593. Project (#0, #1, #3) // { arity: 3 }
  594. Filter #2{any} // { arity: 4 }
  595. Map (5) // { arity: 4 }
  596. Get l34 // { arity: 3 }
  597. Project (#0, #1, #4) // { arity: 3 }
  598. Map (case when #3{any} then 6 else 7 end) // { arity: 5 }
  599. Join on=(#0 = #2) type=differential // { arity: 4 }
  600. implementation
  601. %1[#0]UK » %0:l35[#0]Kenf
  602. ArrangeBy keys=[[#0]] // { arity: 2 }
  603. Get l35 // { arity: 2 }
  604. ArrangeBy keys=[[#0]] // { arity: 2 }
  605. Union // { arity: 2 }
  606. Get l38 // { arity: 2 }
  607. Map (null) // { arity: 2 }
  608. Union // { arity: 1 }
  609. Negate // { arity: 1 }
  610. Project (#0) // { arity: 1 }
  611. Get l38 // { arity: 2 }
  612. Get l36 // { arity: 1 }
  613. cte l40 =
  614. Reduce aggregates=[sum(#0{bid})] // { arity: 1 }
  615. Project (#0) // { arity: 1 }
  616. Filter ((#1{rank} < #3{rank}) OR ((#1{rank} = #3{rank}) AND (#2{score} <= #4{score}))) // { arity: 5 }
  617. CrossJoin type=differential // { arity: 5 }
  618. implementation
  619. %0:l39[×] » %1:l39[×]
  620. ArrangeBy keys=[[]] // { arity: 3 }
  621. Get l39 // { arity: 3 }
  622. ArrangeBy keys=[[]] // { arity: 2 }
  623. Project (#1, #2) // { arity: 2 }
  624. Get l39 // { arity: 3 }
  625. cte l41 =
  626. Filter (#0) IS NOT NULL // { arity: 3 }
  627. Get l3 // { arity: 3 }
  628. cte l42 =
  629. Distinct project=[#0..=#2] // { arity: 3 }
  630. Union // { arity: 3 }
  631. Project (#0, #2, #1) // { arity: 3 }
  632. Get l41 // { arity: 3 }
  633. Project (#0, #3, #1) // { arity: 3 }
  634. Join on=(#0{hand} = #2{hand}) type=differential // { arity: 4 }
  635. implementation
  636. %0:l3[#0{hand}]Kef » %1:l41[#0{hand}]Kef
  637. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  638. Project (#0, #1) // { arity: 2 }
  639. Filter (#2{value} = "J") AND (#0{hand}) IS NOT NULL // { arity: 3 }
  640. Get l3 // { arity: 3 }
  641. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  642. Project (#0, #2) // { arity: 2 }
  643. Get l41 // { arity: 3 }
  644. cte l43 =
  645. Distinct project=[#0, ((((#1{value} || #2{value}) || #3{value}) || #4{value}) || #5{value})] // { arity: 2 }
  646. Project (#0, #1, #3, #5, #7, #9) // { arity: 6 }
  647. Join on=(#0{hand} = #2{hand} = #4{hand} = #6{hand} = #8{hand}) type=delta // { arity: 10 }
  648. implementation
  649. %0:l42 » %1:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef
  650. %1:l42 » %0:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef
  651. %2:l42 » %0:l42[#0{hand}]Kef » %1:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef
  652. %3:l42 » %0:l42[#0{hand}]Kef » %1:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %4:l42[#0{hand}]Kef
  653. %4:l42 » %0:l42[#0{hand}]Kef » %1:l42[#0{hand}]Kef » %2:l42[#0{hand}]Kef » %3:l42[#0{hand}]Kef
  654. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  655. Project (#0, #1) // { arity: 2 }
  656. Filter (#2{position} = 1) // { arity: 3 }
  657. Get l42 // { arity: 3 }
  658. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  659. Project (#0, #1) // { arity: 2 }
  660. Filter (#2{position} = 2) // { arity: 3 }
  661. Get l42 // { arity: 3 }
  662. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  663. Project (#0, #1) // { arity: 2 }
  664. Filter (#2{position} = 3) // { arity: 3 }
  665. Get l42 // { arity: 3 }
  666. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  667. Project (#0, #1) // { arity: 2 }
  668. Filter (#2{position} = 4) // { arity: 3 }
  669. Get l42 // { arity: 3 }
  670. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  671. Project (#0, #1) // { arity: 2 }
  672. Filter (#2{position} = 5) // { arity: 3 }
  673. Get l42 // { arity: 3 }
  674. cte l44 =
  675. Project (#1) // { arity: 1 }
  676. Get l43 // { arity: 2 }
  677. cte l45 =
  678. Project (#0, #3) // { arity: 2 }
  679. Map (bigint_to_integer(#2{count})) // { arity: 4 }
  680. Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 }
  681. Project (#0, #1) // { arity: 2 }
  682. Distinct project=[#0, substr(#0{new_hand}, #1{pos}, 1), #1] // { arity: 3 }
  683. CrossJoin type=differential // { arity: 2 }
  684. implementation
  685. %0:l44[×] » %1:l2[×]
  686. ArrangeBy keys=[[]] // { arity: 1 }
  687. Get l44 // { arity: 1 }
  688. Get l2 // { arity: 1 }
  689. cte l46 =
  690. Distinct project=[#0] // { arity: 1 }
  691. Get l44 // { arity: 1 }
  692. cte l47 =
  693. Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_14}))] // { arity: 2 }
  694. CrossJoin type=differential // { arity: 2 }
  695. implementation
  696. %1:l45[×]ef » %0:l46[×]ef
  697. ArrangeBy keys=[[]] // { arity: 1 }
  698. Get l46 // { arity: 1 }
  699. ArrangeBy keys=[[]] // { arity: 1 }
  700. Project (#0) // { arity: 1 }
  701. Filter (#1{count} = 5) // { arity: 2 }
  702. Get l45 // { arity: 2 }
  703. cte l48 =
  704. Union // { arity: 2 }
  705. Get l47 // { arity: 2 }
  706. Map (false) // { arity: 2 }
  707. Union // { arity: 1 }
  708. Negate // { arity: 1 }
  709. Project (#0) // { arity: 1 }
  710. Get l47 // { arity: 2 }
  711. Get l46 // { arity: 1 }
  712. cte l49 =
  713. Project (#0, #1, #3{any}) // { arity: 3 }
  714. Join on=(#1 = #2) type=differential // { arity: 4 }
  715. implementation
  716. %1[#0]UK » %0:l43[#1]K
  717. ArrangeBy keys=[[#1]] // { arity: 2 }
  718. Get l43 // { arity: 2 }
  719. ArrangeBy keys=[[#0]] // { arity: 2 }
  720. Union // { arity: 2 }
  721. Get l48 // { arity: 2 }
  722. Map (null) // { arity: 2 }
  723. Union // { arity: 1 }
  724. Negate // { arity: 1 }
  725. Project (#0) // { arity: 1 }
  726. Get l48 // { arity: 2 }
  727. Get l46 // { arity: 1 }
  728. cte l50 =
  729. Project (#0, #1) // { arity: 2 }
  730. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  731. Get l49 // { arity: 3 }
  732. cte l51 =
  733. Distinct project=[#0] // { arity: 1 }
  734. Project (#1) // { arity: 1 }
  735. Get l50 // { arity: 2 }
  736. cte l52 =
  737. Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_16}))] // { arity: 2 }
  738. CrossJoin type=differential // { arity: 2 }
  739. implementation
  740. %1:l45[×]ef » %0:l51[×]ef
  741. ArrangeBy keys=[[]] // { arity: 1 }
  742. Get l51 // { arity: 1 }
  743. ArrangeBy keys=[[]] // { arity: 1 }
  744. Project (#0) // { arity: 1 }
  745. Filter (#1{count} = 4) // { arity: 2 }
  746. Get l45 // { arity: 2 }
  747. cte l53 =
  748. Union // { arity: 2 }
  749. Get l52 // { arity: 2 }
  750. Map (false) // { arity: 2 }
  751. Union // { arity: 1 }
  752. Negate // { arity: 1 }
  753. Project (#0) // { arity: 1 }
  754. Get l52 // { arity: 2 }
  755. Get l51 // { arity: 1 }
  756. cte l54 =
  757. Project (#0, #1, #3{any}) // { arity: 3 }
  758. Join on=(#1 = #2) type=differential // { arity: 4 }
  759. implementation
  760. %1[#0]UK » %0:l50[#1]Kenf
  761. ArrangeBy keys=[[#1]] // { arity: 2 }
  762. Get l50 // { arity: 2 }
  763. ArrangeBy keys=[[#0]] // { arity: 2 }
  764. Union // { arity: 2 }
  765. Get l53 // { arity: 2 }
  766. Map (null) // { arity: 2 }
  767. Union // { arity: 1 }
  768. Negate // { arity: 1 }
  769. Project (#0) // { arity: 1 }
  770. Get l53 // { arity: 2 }
  771. Get l51 // { arity: 1 }
  772. cte l55 =
  773. Project (#0, #1) // { arity: 2 }
  774. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  775. Get l54 // { arity: 3 }
  776. cte l56 =
  777. Distinct project=[#0] // { arity: 1 }
  778. Project (#1) // { arity: 1 }
  779. Get l55 // { arity: 2 }
  780. cte l57 =
  781. ArrangeBy keys=[[]] // { arity: 1 }
  782. Project (#0) // { arity: 1 }
  783. Filter (#1{count} = 3) // { arity: 2 }
  784. Get l45 // { arity: 2 }
  785. cte l58 =
  786. Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_18}))] // { arity: 2 }
  787. CrossJoin type=differential // { arity: 2 }
  788. implementation
  789. %1:l57[×]ef » %0:l56[×]ef
  790. ArrangeBy keys=[[]] // { arity: 1 }
  791. Get l56 // { arity: 1 }
  792. Get l57 // { arity: 1 }
  793. cte l59 =
  794. Union // { arity: 2 }
  795. Get l58 // { arity: 2 }
  796. Map (false) // { arity: 2 }
  797. Union // { arity: 1 }
  798. Negate // { arity: 1 }
  799. Project (#0) // { arity: 1 }
  800. Get l58 // { arity: 2 }
  801. Get l56 // { arity: 1 }
  802. cte l60 =
  803. Project (#0, #1, #3{any}) // { arity: 3 }
  804. Join on=(#1 = #2) type=differential // { arity: 4 }
  805. implementation
  806. %1[#0]UK » %0:l55[#1]Kenf
  807. ArrangeBy keys=[[#1]] // { arity: 2 }
  808. Get l55 // { arity: 2 }
  809. ArrangeBy keys=[[#0]] // { arity: 2 }
  810. Union // { arity: 2 }
  811. Get l59 // { arity: 2 }
  812. Map (null) // { arity: 2 }
  813. Union // { arity: 1 }
  814. Negate // { arity: 1 }
  815. Project (#0) // { arity: 1 }
  816. Get l59 // { arity: 2 }
  817. Get l56 // { arity: 1 }
  818. cte l61 =
  819. Distinct project=[#0] // { arity: 1 }
  820. Project (#1) // { arity: 1 }
  821. Get l60 // { arity: 3 }
  822. cte l62 =
  823. ArrangeBy keys=[[]] // { arity: 1 }
  824. Project (#0) // { arity: 1 }
  825. Filter (#1{count} = 2) // { arity: 2 }
  826. Get l45 // { arity: 2 }
  827. cte l63 =
  828. Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_20}))] // { arity: 2 }
  829. CrossJoin type=differential // { arity: 2 }
  830. implementation
  831. %1:l62[×]ef » %0:l61[×]ef
  832. ArrangeBy keys=[[]] // { arity: 1 }
  833. Get l61 // { arity: 1 }
  834. Get l62 // { arity: 1 }
  835. cte l64 =
  836. Union // { arity: 2 }
  837. Get l63 // { arity: 2 }
  838. Map (false) // { arity: 2 }
  839. Union // { arity: 1 }
  840. Negate // { arity: 1 }
  841. Project (#0) // { arity: 1 }
  842. Get l63 // { arity: 2 }
  843. Get l61 // { arity: 1 }
  844. cte l65 =
  845. Project (#0..=#2{any}, #4{any}) // { arity: 4 }
  846. Join on=(#1 = #3) type=differential // { arity: 5 }
  847. implementation
  848. %1[#0]UK » %0:l60[#1]K
  849. ArrangeBy keys=[[#1]] // { arity: 3 }
  850. Get l60 // { arity: 3 }
  851. ArrangeBy keys=[[#0]] // { arity: 2 }
  852. Union // { arity: 2 }
  853. Get l64 // { arity: 2 }
  854. Map (null) // { arity: 2 }
  855. Union // { arity: 1 }
  856. Negate // { arity: 1 }
  857. Project (#0) // { arity: 1 }
  858. Get l64 // { arity: 2 }
  859. Get l61 // { arity: 1 }
  860. cte l66 =
  861. Project (#0, #1) // { arity: 2 }
  862. Filter ((#4) IS NULL OR (#4 = false)) // { arity: 5 }
  863. Map ((#2{any} AND #3{any})) // { arity: 5 }
  864. Get l65 // { arity: 4 }
  865. cte l67 =
  866. Distinct project=[#0] // { arity: 1 }
  867. Project (#1) // { arity: 1 }
  868. Get l66 // { arity: 2 }
  869. cte l68 =
  870. Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_22}))] // { arity: 2 }
  871. CrossJoin type=differential // { arity: 2 }
  872. implementation
  873. %1:l57[×]ef » %0:l67[×]ef
  874. ArrangeBy keys=[[]] // { arity: 1 }
  875. Get l67 // { arity: 1 }
  876. Get l57 // { arity: 1 }
  877. cte l69 =
  878. Union // { arity: 2 }
  879. Get l68 // { arity: 2 }
  880. Map (false) // { arity: 2 }
  881. Union // { arity: 1 }
  882. Negate // { arity: 1 }
  883. Project (#0) // { arity: 1 }
  884. Get l68 // { arity: 2 }
  885. Get l67 // { arity: 1 }
  886. cte l70 =
  887. Project (#0, #1, #3{any}) // { arity: 3 }
  888. Join on=(#1 = #2) type=differential // { arity: 4 }
  889. implementation
  890. %1[#0]UK » %0:l66[#1]Kenf
  891. ArrangeBy keys=[[#1]] // { arity: 2 }
  892. Get l66 // { arity: 2 }
  893. ArrangeBy keys=[[#0]] // { arity: 2 }
  894. Union // { arity: 2 }
  895. Get l69 // { arity: 2 }
  896. Map (null) // { arity: 2 }
  897. Union // { arity: 1 }
  898. Negate // { arity: 1 }
  899. Project (#0) // { arity: 1 }
  900. Get l69 // { arity: 2 }
  901. Get l67 // { arity: 1 }
  902. cte l71 =
  903. Project (#0, #1) // { arity: 2 }
  904. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  905. Get l70 // { arity: 3 }
  906. cte l72 =
  907. Distinct project=[#0] // { arity: 1 }
  908. Project (#1) // { arity: 1 }
  909. Get l71 // { arity: 2 }
  910. cte l73 =
  911. Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_24}))] // { arity: 2 }
  912. Project (#0, #1) // { arity: 2 }
  913. Filter (#2{count} = 2) // { arity: 3 }
  914. Reduce group_by=[#0, #1] aggregates=[count(*)] // { arity: 3 }
  915. CrossJoin type=differential // { arity: 2 }
  916. implementation
  917. %1:l62[×]ef » %0:l72[×]ef
  918. ArrangeBy keys=[[]] // { arity: 1 }
  919. Get l72 // { arity: 1 }
  920. Get l62 // { arity: 1 }
  921. cte l74 =
  922. Union // { arity: 2 }
  923. Get l73 // { arity: 2 }
  924. Map (false) // { arity: 2 }
  925. Union // { arity: 1 }
  926. Negate // { arity: 1 }
  927. Project (#0) // { arity: 1 }
  928. Get l73 // { arity: 2 }
  929. Get l72 // { arity: 1 }
  930. cte l75 =
  931. Project (#0, #1, #3{any}) // { arity: 3 }
  932. Join on=(#1 = #2) type=differential // { arity: 4 }
  933. implementation
  934. %1[#0]UK » %0:l71[#1]Kenf
  935. ArrangeBy keys=[[#1]] // { arity: 2 }
  936. Get l71 // { arity: 2 }
  937. ArrangeBy keys=[[#0]] // { arity: 2 }
  938. Union // { arity: 2 }
  939. Get l74 // { arity: 2 }
  940. Map (null) // { arity: 2 }
  941. Union // { arity: 1 }
  942. Negate // { arity: 1 }
  943. Project (#0) // { arity: 1 }
  944. Get l74 // { arity: 2 }
  945. Get l72 // { arity: 1 }
  946. cte l76 =
  947. Project (#0, #1) // { arity: 2 }
  948. Filter ((#2{any}) IS NULL OR (#2{any} = false)) // { arity: 3 }
  949. Get l75 // { arity: 3 }
  950. cte l77 =
  951. Distinct project=[#0] // { arity: 1 }
  952. Project (#1) // { arity: 1 }
  953. Get l76 // { arity: 2 }
  954. cte l78 =
  955. Reduce group_by=[#0] aggregates=[any((#0{new_hand} = #1{right_col0_26}))] // { arity: 2 }
  956. CrossJoin type=differential // { arity: 2 }
  957. implementation
  958. %1:l62[×]ef » %0:l77[×]ef
  959. ArrangeBy keys=[[]] // { arity: 1 }
  960. Get l77 // { arity: 1 }
  961. Get l62 // { arity: 1 }
  962. cte l79 =
  963. Union // { arity: 2 }
  964. Get l78 // { arity: 2 }
  965. Map (false) // { arity: 2 }
  966. Union // { arity: 1 }
  967. Negate // { arity: 1 }
  968. Project (#0) // { arity: 1 }
  969. Get l78 // { arity: 2 }
  970. Get l77 // { arity: 1 }
  971. cte l80 =
  972. Project (#1, #3, #4) // { arity: 3 }
  973. Join on=(#0{hand} = #2{hand}) type=differential // { arity: 5 }
  974. implementation
  975. %1[#0{hand}]UK » %0:l0[#0{hand}]K
  976. ArrangeBy keys=[[#0{hand}]] // { arity: 2 }
  977. Filter (#0{hand}) IS NOT NULL // { arity: 2 }
  978. Get l0 // { arity: 2 }
  979. ArrangeBy keys=[[#0{hand}]] // { arity: 3 }
  980. TopK group_by=[#0] order_by=[#1 asc nulls_last, #2 asc nulls_last] limit=1 // { arity: 3 }
  981. Map (translate(#0{hand}, "AKQT98765432J", "ABCDEFGHIJKLM")) // { arity: 3 }
  982. Union // { arity: 2 }
  983. Project (#0, #3) // { arity: 2 }
  984. Filter #2{any} // { arity: 4 }
  985. Map (1) // { arity: 4 }
  986. Get l49 // { arity: 3 }
  987. Project (#0, #3) // { arity: 2 }
  988. Filter #2{any} // { arity: 4 }
  989. Map (2) // { arity: 4 }
  990. Get l54 // { arity: 3 }
  991. Project (#0, #4) // { arity: 2 }
  992. Filter #2{any} AND #3{any} // { arity: 5 }
  993. Map (3) // { arity: 5 }
  994. Get l65 // { arity: 4 }
  995. Project (#0, #3) // { arity: 2 }
  996. Filter #2{any} // { arity: 4 }
  997. Map (4) // { arity: 4 }
  998. Get l70 // { arity: 3 }
  999. Project (#0, #3) // { arity: 2 }
  1000. Filter #2{any} // { arity: 4 }
  1001. Map (5) // { arity: 4 }
  1002. Get l75 // { arity: 3 }
  1003. Project (#0, #4) // { arity: 2 }
  1004. Map (case when #3{any} then 6 else 7 end) // { arity: 5 }
  1005. Join on=(#1 = #2) type=differential // { arity: 4 }
  1006. implementation
  1007. %1[#0]UK » %0:l76[#1]Kenf
  1008. ArrangeBy keys=[[#1]] // { arity: 2 }
  1009. Get l76 // { arity: 2 }
  1010. ArrangeBy keys=[[#0]] // { arity: 2 }
  1011. Union // { arity: 2 }
  1012. Get l79 // { arity: 2 }
  1013. Map (null) // { arity: 2 }
  1014. Union // { arity: 1 }
  1015. Negate // { arity: 1 }
  1016. Project (#0) // { arity: 1 }
  1017. Get l79 // { arity: 2 }
  1018. Get l77 // { arity: 1 }
  1019. cte l81 =
  1020. Reduce aggregates=[sum(#0{bid})] // { arity: 1 }
  1021. Project (#0) // { arity: 1 }
  1022. Filter ((#1{rank} < #3{rank}) OR ((#1{rank} = #3{rank}) AND (#2{score} <= #4{score}))) // { arity: 5 }
  1023. CrossJoin type=differential // { arity: 5 }
  1024. implementation
  1025. %0:l80[×] » %1:l80[×]
  1026. ArrangeBy keys=[[]] // { arity: 3 }
  1027. Get l80 // { arity: 3 }
  1028. ArrangeBy keys=[[]] // { arity: 2 }
  1029. Project (#1, #2) // { arity: 2 }
  1030. Get l80 // { arity: 3 }
  1031. Return // { arity: 2 }
  1032. CrossJoin type=differential // { arity: 2 }
  1033. implementation
  1034. %0[×]U » %1[×]U
  1035. ArrangeBy keys=[[]] // { arity: 1 }
  1036. Project (#1) // { arity: 1 }
  1037. Map (bigint_to_integer(#0{sum})) // { arity: 2 }
  1038. Union // { arity: 1 }
  1039. Get l40 // { arity: 1 }
  1040. Map (null) // { arity: 1 }
  1041. Union // { arity: 0 }
  1042. Negate // { arity: 0 }
  1043. Project () // { arity: 0 }
  1044. Get l40 // { arity: 1 }
  1045. Constant // { arity: 0 }
  1046. - ()
  1047. ArrangeBy keys=[[]] // { arity: 1 }
  1048. Project (#1) // { arity: 1 }
  1049. Map (bigint_to_integer(#0{sum})) // { arity: 2 }
  1050. Union // { arity: 1 }
  1051. Get l81 // { arity: 1 }
  1052. Map (null) // { arity: 1 }
  1053. Union // { arity: 0 }
  1054. Negate // { arity: 0 }
  1055. Project () // { arity: 0 }
  1056. Get l81 // { arity: 1 }
  1057. Constant // { arity: 0 }
  1058. - ()
  1059. Source materialize.public.input
  1060. Target cluster: quickstart
  1061. EOF