(
(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 (DataType 'Timestamp))
(let $16 (lambda '($66) (Just (SafeCast $66 $15))))
(let $17 (Nothing (OptionalType $15)))
(let $18 (Date '"9197"))
(let $19 (Bool 'false))
(let $20 (OptionalType (DataType 'Date)))
(let $21 '('"o_orderdate" $20))
(let $22 (DataType 'Int64))
(let $23 '('"o_shippriority" $22))
(let $24 (StructType '('"o_custkey" $7) $21 '('"o_orderkey" $7) $23))
(let $25 '('('"_logical_id" '4790) '('"_id" '"a2d2acad-39101dd8-218c9011-51bb9578") '('"_wide_channels" $24)))
(let $26 (DqPhyStage '() (lambda '() (block '(
  (let $54 '@@["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 $55 '('"o_orderkey"))
  (let $56 (YqlRowSpec $2 $3 $4 '('Type $54) $6 '('SortMembers $55) '('SortedBy $55) $8))
  (let $57 (YtStat '('Id '"orders") $10 '('DataSize '"224") $11 $12 $13))
  (let $58 (YtTable '"orders" $56 $9 $57 '() (Void) (Void) '"/Root/plato"))
  (let $59 '('"o_custkey" '"o_orderdate" '"o_orderkey" '"o_shippriority"))
  (let $60 (YtReadTable! world $1 '((YtSection '((YtPath $58 $59 (Void) (Void))) $14))))
  (return (FromFlow (WideFilter (DqReadWideWrap $60 '()) (lambda '($61 $62 $63 $64) (block '(
    (let $65 (IfPresent $62 $16 $17))
    (return (Coalesce (< $65 $18) $19))
  ))))))
))) $25))
(let $27 (DqCnBroadcast (TDqOutput $26 '0)))
(let $28 '('Many 'Hashed 'Compact))
(let $29 (StructType '('"c.c_custkey" $7) '('"o.o_custkey" $7) '('"o.o_orderdate" $20) '('"o.o_orderkey" $7) '('"o.o_shippriority" $22)))
(let $30 '('('"_logical_id" '4907) '('"_id" '"390799ae-387e92f-7cfe97da-9266d7aa") '('"_wide_channels" $29)))
(let $31 (DqPhyStage '($27) (lambda '($67) (block '(
  (let $68 (NarrowSqueezeToDict (ToFlow $67) (lambda '($69 $70 $71 $72) $69) (lambda '($73 $74 $75 $76) (AsStruct '('"o_custkey" $73) '('"o_orderdate" $74) '('"o_orderkey" $75) '('"o_shippriority" $76))) $28))
  (return (FromFlow (FlatMap $68 (lambda '($77) (block '(
    (let $78 '@@["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 $79 '('"c_custkey"))
    (let $80 (YqlRowSpec '('NativeYtTypeFlags '0) $3 $4 '('Type $78) $6 '('SortMembers $79) '('SortedBy $79) $8))
    (let $81 (YtStat '('Id '"customer") $10 '('DataSize '"247") $11 $12 $13))
    (let $82 (YtTable '"customer" $80 $9 $81 '() (Void) (Void) '"/Root/plato"))
    (let $83 (YtReadTable! world $1 '((YtSection '((YtPath $82 '('"c_custkey" '"c_mktsegment") (Void) (Void))) $14))))
    (let $84 '('"o_custkey" '1 '"o_orderdate" '2 '"o_orderkey" '3 '"o_shippriority" '4))
    (return (MapJoinCore (WideMap (WideFilter (DqReadWideWrap $83 '()) (lambda '($85 $86) (== $86 (String '"MACHINERY")))) (lambda '($87 $88) $87)) $77 'Inner '('0) '('"o_custkey") '('0 '0) $84 '('"c.c_custkey") '('"o.o_custkey")))
  ))))))
))) $30))
(let $32 (DataType 'Double))
(let $33 '('"l_orderkey" $7))
(let $34 (StructType '('"l_discount" $32) '('"l_extendedprice" $32) $33))
(let $35 '('('"_logical_id" '4824) '('"_id" '"81487614-26dcfcdf-2559c158-3e442167") '('"_wide_channels" $34)))
(let $36 (DqPhyStage '() (lambda '() (block '(
  (let $89 '@@["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 $90 '('"l_orderkey" '"l_linenumber"))
  (let $91 (YqlRowSpec $2 $3 $4 '('Type $89) '('SortDirections '($5 $5)) '('SortMembers $90) '('SortedBy $90) '('SortedByTypes '($7 $7))))
  (let $92 (YtStat '('Id '"lineitem") $10 '('DataSize '"343") $11 $12 $13))
  (let $93 (YtTable '"lineitem" $91 $9 $92 '() (Void) (Void) '"/Root/plato"))
  (let $94 '('"l_discount" '"l_extendedprice" '"l_orderkey" '"l_shipdate"))
  (let $95 (YtReadTable! world $1 '((YtSection '((YtPath $93 $94 (Void) (Void))) $14))))
  (let $96 (lambda '($102 $103 $104 $105) $102 $103 $104))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $95 '()) (lambda '($97 $98 $99 $100) (block '(
    (let $101 (IfPresent $100 $16 $17))
    (return (Coalesce (> $101 $18) $19))
  )))) $96)))
))) $35))
(let $37 (DqCnMap (TDqOutput $31 '0)))
(let $38 (DqCnBroadcast (TDqOutput $36 '0)))
(let $39 (lambda '($148 $149 $150 $151) $151 $148 $149 $150))
(let $40 (StructType '('_yql_agg_0 $32) $33 $21 $23))
(let $41 '('('"_logical_id" '5100) '('"_id" '"783b3207-1b4a1ab8-ba275613-30428381") '('"_wide_channels" $40)))
(let $42 (DqPhyStage '($37 $38) (lambda '($106 $107) (block '(
  (let $108 (NarrowSqueezeToDict (ToFlow $107) (lambda '($111 $112 $113) $113) (lambda '($114 $115 $116) (AsStruct '('"l_discount" $114) '('"l_extendedprice" $115) '('"l_orderkey" $116))) $28))
  (let $109 (lambda '($126 $127 $128 $129 $130) $128 $129 $130))
  (let $110 (Int32 '1))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (FlatMap $108 (lambda '($117) (block '(
    (let $118 (lambda '($121 $122 $123 $124 $125) $123 $124 $125))
    (let $119 '('0 '3 '2 '4))
    (let $120 '('"l_discount" '0 '"l_extendedprice" '1 '"l_orderkey" '2))
    (return (MapJoinCore (WideMap (ToFlow $106) $118) $117 'Inner '('1) '('"l_orderkey") $119 $120 '('"o.o_orderkey") '('"l.l_orderkey")))
  )))))) '-1073741824 $109 (lambda '($131 $132 $133 $134 $135 $136 $137 $138) (* $135 (- $110 $134))) (lambda '($139 $140 $141 $142 $143 $144 $145 $146 $147) (AggrAdd (* $143 (- $110 $142)) $147)) $39))
))) $41))
(let $43 '('1 '2 '3))
(let $44 (DqCnHashShuffle (TDqOutput $42 '0) $43 '0 '"HashV2"))
(let $45 (Uint64 '10))
(let $46 (StructType '('Sum0 $32) $33 $21 $23))
(let $47 '('('"_logical_id" '6369) '('"_id" '"36aee5fb-dc0f8a6f-f3dbf4b2-313b9325") '('"_wide_channels" $46)))
(let $48 (DqPhyStage '($44) (lambda '($152) (block '(
  (let $153 (lambda '($155 $156 $157 $158) $156 $157 $158))
  (let $154 (WideCombiner (ToFlow (WideFromBlocks $152)) '"" $153 (lambda '($159 $160 $161 $162 $163 $164 $165) $162) (lambda '($166 $167 $168 $169 $170 $171 $172 $173) (AggrAdd $169 $173)) $39))
  (return (FromFlow (WideTopSort $154 $45 '('('0 $19) '('2 $5)))))
))) $47))
(let $49 (DqCnMerge (TDqOutput $48 '0) '('('0 '"Desc") '('2 '"Asc"))))
(let $50 (DqPhyStage '($49) (lambda '($174) (FromFlow (NarrowMap (Take (ToFlow $174) $45) (lambda '($175 $176 $177 $178) (AsStruct '('"l_orderkey" $176) '('"o_orderdate" $177) '('"o_shippriority" $178) '('"revenue" $175)))))) '('('"_logical_id" '6476) '('"_id" '"be118305-7a973b52-cd218d93-e358b1b2"))))
(let $51 '($26 $31 $36 $42 $48 $50))
(let $52 '('"l_orderkey" '"revenue" '"o_orderdate" '"o_shippriority"))
(let $53 (DqCnResult (TDqOutput $50 '0) $52))
(return (KqpPhysicalQuery '((KqpPhysicalTx $51 '($53) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType (StructType $33 $21 $23 '('"revenue" $32))) '0 '0)) '('('"type" '"query"))))
)
