(
(let $1 (DataSource '"yt" '"/Root/plato"))
(let $2 '('NativeYtTypeFlags '2))
(let $3 '('StrictSchema '1))
(let $4 '('UniqueKeys '0))
(let $5 (Bool 'true))
(let $6 '('SortDirections '($5)))
(let $7 (DataType 'Int32))
(let $8 '('SortedByTypes '($7)))
(let $9 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0)))
(let $10 '('RecordsCount '1))
(let $11 '('ChunkCount '1))
(let $12 '('ModifyTime '0))
(let $13 '('Revision '0))
(let $14 '('('"unordered")))
(let $15 (Bool 'false))
(let $16 '('('"_logical_id" '6887) '('"_id" '"6aa3cd2d-294c7c57-573b3e6b-1200936") '('"_wide_channels" (StructType '('"o_custkey" $7) '('"o_orderkey" $7)))))
(let $17 (DqPhyStage '() (lambda '() (block '(
  (let $59 '@@["StructType";[["o_orderkey";["DataType";"Int32"]];["o_orderstatus";["DataType";"String"]];["o_comment";["DataType";"String"]];["o_totalprice";["DataType";"Double"]];["o_clerk";["DataType";"String"]];["o_custkey";["DataType";"Int32"]];["o_orderpriority";["DataType";"String"]];["o_orderdate";["OptionalType";["DataType";"Date"]]];["o_shippriority";["DataType";"Int64"]]]]@@)
  (let $60 '('"o_orderkey"))
  (let $61 (YqlRowSpec $2 $3 $4 '('Type $59) $6 '('SortMembers $60) '('SortedBy $60) $8))
  (let $62 (YtStat '('Id '"orders") $10 '('DataSize '"224") $11 $12 $13))
  (let $63 (YtTable '"orders" $61 $9 $62 '() (Void) (Void) '"/Root/plato"))
  (let $64 '('"o_custkey" '"o_orderdate" '"o_orderkey"))
  (let $65 (YtReadTable! world $1 '((YtSection '((YtPath $63 $64 (Void) (Void))) $14))))
  (let $66 (lambda '($73 $74 $75) $73 $75))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $65 '()) (lambda '($67 $68 $69) (block '(
    (let $70 (DataType 'Timestamp))
    (let $71 (IfPresent $68 (lambda '($72) (Just (SafeCast $72 $70))) (Nothing (OptionalType $70))))
    (return (And (Coalesce (>= $71 (Date '"8735")) $15) (Coalesce (< $71 (Just (Date '"8825"))) $15)))
  )))) $66)))
))) $16))
(let $18 (DqCnBroadcast (TDqOutput $17 '0)))
(let $19 '('Many 'Hashed 'Compact))
(let $20 '('NativeYtTypeFlags '0))
(let $21 '('0 '0 '1 '1 '2 '2 '3 '3 '4 '4 '5 '5 '6 '6))
(let $22 (DataType 'Double))
(let $23 (DataType 'String))
(let $24 (StructType '('"c.c_acctbal" $22) '('"c.c_address" $23) '('"c.c_comment" $23) '('"c.c_custkey" $7) '('"c.c_name" $23) '('"c.c_nationkey" $7) '('"c.c_phone" $23) '('"o.o_custkey" $7) '('"o.o_orderkey" $7)))
(let $25 '('('"_logical_id" '6998) '('"_id" '"53b5033b-2332f21d-90dacf69-94de995e") '('"_wide_channels" $24)))
(let $26 (DqPhyStage '($18) (lambda '($76) (block '(
  (let $77 (NarrowSqueezeToDict (ToFlow $76) (lambda '($78 $79) $78) (lambda '($80 $81) (AsStruct '('"o_custkey" $80) '('"o_orderkey" $81))) $19))
  (return (FromFlow (FlatMap $77 (lambda '($82) (block '(
    (let $83 '@@["StructType";[["c_custkey";["DataType";"Int32"]];["c_acctbal";["DataType";"Double"]];["c_phone";["DataType";"String"]];["c_mktsegment";["DataType";"String"]];["c_nationkey";["DataType";"Int32"]];["c_comment";["DataType";"String"]];["c_name";["DataType";"String"]];["c_address";["DataType";"String"]]]]@@)
    (let $84 '('"c_custkey"))
    (let $85 (YqlRowSpec $20 $3 $4 '('Type $83) $6 '('SortMembers $84) '('SortedBy $84) $8))
    (let $86 (YtStat '('Id '"customer") $10 '('DataSize '"247") $11 $12 $13))
    (let $87 (YtTable '"customer" $85 $9 $86 '() (Void) (Void) '"/Root/plato"))
    (let $88 '('"c_acctbal" '"c_address" '"c_comment" '"c_custkey" '"c_name" '"c_nationkey" '"c_phone"))
    (let $89 (YtReadTable! world $1 '((YtSection '((YtPath $87 $88 (Void) (Void))) '()))))
    (let $90 '('"o_custkey" '7 '"o_orderkey" '8))
    (return (MapJoinCore (DqReadWideWrap $89 '()) $82 'Inner '('3) '('"o_custkey") $21 $90 '('"c.c_custkey") '('"o.o_custkey")))
  ))))))
))) $25))
(let $27 (StructType '('"l_discount" $22) '('"l_extendedprice" $22) '('"l_orderkey" $7)))
(let $28 '('('"_logical_id" '6919) '('"_id" '"ac7f79dd-84fef3a7-3b7b97e9-99f71200") '('"_wide_channels" $27)))
(let $29 (DqPhyStage '() (lambda '() (block '(
  (let $91 '@@["StructType";[["l_orderkey";["DataType";"Int32"]];["l_linenumber";["DataType";"Int32"]];["l_discount";["DataType";"Double"]];["l_extendedprice";["DataType";"Double"]];["l_comment";["DataType";"String"]];["l_shipdate";["OptionalType";["DataType";"Date"]]];["l_returnflag";["DataType";"String"]];["l_partkey";["DataType";"Int32"]];["l_tax";["DataType";"Double"]];["l_shipinstruct";["DataType";"String"]];["l_commitdate";["OptionalType";["DataType";"Date"]]];["l_receiptdate";["OptionalType";["DataType";"Date"]]];["l_quantity";["DataType";"Double"]];["l_suppkey";["DataType";"Int32"]];["l_shipmode";["DataType";"String"]];["l_linestatus";["DataType";"String"]]]]@@)
  (let $92 '('"l_orderkey" '"l_linenumber"))
  (let $93 (YqlRowSpec $2 $3 $4 '('Type $91) '('SortDirections '($5 $5)) '('SortMembers $92) '('SortedBy $92) '('SortedByTypes '($7 $7))))
  (let $94 (YtStat '('Id '"lineitem") $10 '('DataSize '"343") $11 $12 $13))
  (let $95 (YtTable '"lineitem" $93 $9 $94 '() (Void) (Void) '"/Root/plato"))
  (let $96 '('"l_discount" '"l_extendedprice" '"l_orderkey" '"l_returnflag"))
  (let $97 (YtReadTable! world $1 '((YtSection '((YtPath $95 $96 (Void) (Void))) $14))))
  (let $98 (lambda '($103 $104 $105 $106) $103 $104 $105))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $97 '()) (lambda '($99 $100 $101 $102) (== $102 (String '"R")))) $98)))
))) $28))
(let $30 '('"n_nationkey"))
(let $31 '('"n_name" $23))
(let $32 '('('"_logical_id" '6787) '('"_id" '"9cf30640-f7dd6c8a-a10aec23-bb475757") '('"_wide_channels" (StructType $31 '('"n_nationkey" $7)))))
(let $33 (DqPhyStage '() (lambda '() (block '(
  (let $107 '@@["StructType";[["n_nationkey";["DataType";"Int32"]];["n_regionkey";["DataType";"Int32"]];["n_name";["DataType";"String"]];["n_comment";["DataType";"String"]]]]@@)
  (let $108 (YqlRowSpec $20 $3 $4 '('Type $107) $6 '('SortMembers $30) '('SortedBy $30) $8))
  (let $109 (YtStat '('Id '"nation") $10 '('DataSize '"121") $11 $12 $13))
  (let $110 (YtTable '"nation" $108 $9 $109 '() (Void) (Void) '"/Root/plato"))
  (let $111 (YtReadTable! world $1 '((YtSection '((YtPath $110 '('"n_name" '"n_nationkey") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $111 '())))
))) $32))
(let $34 (DqCnMap (TDqOutput $26 '0)))
(let $35 (DqCnBroadcast (TDqOutput $29 '0)))
(let $36 (DqCnBroadcast (TDqOutput $33 '0)))
(let $37 '($34 $35 $36))
(let $38 (lambda '($185 $186 $187 $188 $189 $190 $191 $192) $192 $185 $186 $187 $188 $189 $190 $191))
(let $39 '('"c_acctbal" $22))
(let $40 '('"c_address" $23))
(let $41 '('"c_comment" $23))
(let $42 '('"c_custkey" $7))
(let $43 '('"c_name" $23))
(let $44 '('"c_phone" $23))
(let $45 (StructType '('_yql_agg_0 $22) $39 $40 $41 $42 $43 $44 $31))
(let $46 '('('"_logical_id" '7281) '('"_id" '"e910dcac-ca97da3d-9cc95a03-e125d94d") '('"_wide_channels" $45)))
(let $47 (DqPhyStage $37 (lambda '($112 $113 $114) (block '(
  (let $115 (NarrowSqueezeToDict (ToFlow $114) (lambda '($118 $119) $119) (lambda '($120 $121) (AsStruct '('"n_name" $120) '('"n_nationkey" $121))) $19))
  (let $116 (lambda '($143 $144 $145 $146 $147 $148 $149 $150 $151) $143 $144 $145 $146 $147 $148 $151))
  (let $117 (Int32 '1))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (FlatMap $115 (lambda '($122) (block '(
    (let $123 (NarrowSqueezeToDict (ToFlow $113) (lambda '($125 $126 $127) $127) (lambda '($128 $129 $130) (AsStruct '('"l_discount" $128) '('"l_extendedprice" $129) '('"l_orderkey" $130))) $19))
    (let $124 '('0 '0 '1 '1 '2 '2 '3 '3 '4 '4 '6 '5 '7 '6 '8 '7))
    (return (MapJoinCore (FlatMap $123 (lambda '($131) (block '(
      (let $132 (lambda '($134 $135 $136 $137 $138 $139 $140 $141 $142) $134 $135 $136 $137 $138 $139 $140 $142))
      (let $133 '('"l_discount" '7 '"l_extendedprice" '8))
      (return (MapJoinCore (WideMap (ToFlow $112) $132) $131 'Inner '('7) '('"l_orderkey") $21 $133 '('"o.o_orderkey") '('"l.l_orderkey")))
    )))) $122 'Inner '('5) $30 $124 '('"n_name" '8) '('"c.c_nationkey") '('"n.n_nationkey")))
  )))))) '-1073741824 $116 (lambda '($152 $153 $154 $155 $156 $157 $158 $159 $160 $161 $162 $163 $164 $165 $166 $167) (* $166 (- $117 $165))) (lambda '($168 $169 $170 $171 $172 $173 $174 $175 $176 $177 $178 $179 $180 $181 $182 $183 $184) (AggrAdd (* $182 (- $117 $181)) $184)) $38))
))) $46))
(let $48 '('1 '2 '3 '4 '5 '6 '7))
(let $49 (DqCnHashShuffle (TDqOutput $47 '0) $48 '0 '"HashV2"))
(let $50 (Uint64 '20))
(let $51 (StructType '('Sum0 $22) $39 $40 $41 $42 $43 $44 $31))
(let $52 '('('"_logical_id" '8712) '('"_id" '"2101220d-1295b4cb-283f5f8f-70890947") '('"_wide_channels" $51)))
(let $53 (DqPhyStage '($49) (lambda '($193) (block '(
  (let $194 (lambda '($196 $197 $198 $199 $200 $201 $202 $203) $197 $198 $199 $200 $201 $202 $203))
  (let $195 (WideCombiner (ToFlow (WideFromBlocks $193)) '"" $194 (lambda '($204 $205 $206 $207 $208 $209 $210 $211 $212 $213 $214 $215 $216 $217 $218) $211) (lambda '($219 $220 $221 $222 $223 $224 $225 $226 $227 $228 $229 $230 $231 $232 $233 $234) (AggrAdd $226 $234)) $38))
  (return (FromFlow (WideTopSort $195 $50 '('('0 $15)))))
))) $52))
(let $54 (DqCnMerge (TDqOutput $53 '0) '('('0 '"Desc"))))
(let $55 (DqPhyStage '($54) (lambda '($235) (FromFlow (NarrowMap (Take (ToFlow $235) $50) (lambda '($236 $237 $238 $239 $240 $241 $242 $243) (AsStruct '('"c_acctbal" $237) '('"c_address" $238) '('"c_comment" $239) '('"c_custkey" $240) '('"c_name" $241) '('"c_phone" $242) '('"n_name" $243) '('"revenue" $236)))))) '('('"_logical_id" '8833) '('"_id" '"45931c70-14a5ea76-cc7c3772-a2cb81d1"))))
(let $56 '($17 $26 $29 $33 $47 $53 $55))
(let $57 '('"c_custkey" '"c_name" '"revenue" '"c_acctbal" '"n_name" '"c_address" '"c_phone" '"c_comment"))
(let $58 (DqCnResult (TDqOutput $55 '0) $57))
(return (KqpPhysicalQuery '((KqpPhysicalTx $56 '($58) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType (StructType $39 $40 $41 $42 $43 $44 $31 '('"revenue" $22))) '0 '0)) '('('"type" '"query"))))
)
