(
(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" '8190) '('"_id" '"fc664dea-8f82792a-21daab58-2913b63") '('"_wide_channels" (StructType '('"o_custkey" $7) '('"o_orderkey" $7)))))
(let $17 (DqPhyStage '() (lambda '() (block '(
  (let $56 '@@["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 $57 '('"o_orderkey"))
  (let $58 (YqlRowSpec $2 $3 $4 '('Type $56) $6 '('SortMembers $57) '('SortedBy $57) $8))
  (let $59 (YtStat '('Id '"orders") $10 '('DataSize '"224") $11 $12 $13))
  (let $60 (YtTable '"orders" $58 $9 $59 '() (Void) (Void) '"/Root/plato"))
  (let $61 '('"o_custkey" '"o_orderdate" '"o_orderkey"))
  (let $62 (YtReadTable! world $1 '((YtSection '((YtPath $60 $61 (Void) (Void))) $14))))
  (let $63 (lambda '($70 $71 $72) $70 $72))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $62 '()) (lambda '($64 $65 $66) (block '(
    (let $67 (DataType 'Timestamp))
    (let $68 (IfPresent $65 (lambda '($69) (Just (SafeCast $69 $67))) (Nothing (OptionalType $67))))
    (return (And (Coalesce (>= $68 (Date '"9131")) $15) (Coalesce (< $68 (Just (Date '"9496"))) $15)))
  )))) $63)))
))) $16))
(let $18 (DqCnBroadcast (TDqOutput $17 '0)))
(let $19 '('Many 'Hashed 'Compact))
(let $20 '('NativeYtTypeFlags '0))
(let $21 (StructType '('"c.c_custkey" $7) '('"c.c_nationkey" $7) '('"o.o_custkey" $7) '('"o.o_orderkey" $7)))
(let $22 '('('"_logical_id" '8295) '('"_id" '"62f1ced5-b2415de8-77c044-fa97ca08") '('"_wide_channels" $21)))
(let $23 (DqPhyStage '($18) (lambda '($73) (block '(
  (let $74 (NarrowSqueezeToDict (ToFlow $73) (lambda '($75 $76) $75) (lambda '($77 $78) (AsStruct '('"o_custkey" $77) '('"o_orderkey" $78))) $19))
  (return (FromFlow (FlatMap $74 (lambda '($79) (block '(
    (let $80 '@@["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 $81 '('"c_custkey"))
    (let $82 (YqlRowSpec $20 $3 $4 '('Type $80) $6 '('SortMembers $81) '('SortedBy $81) $8))
    (let $83 (YtStat '('Id '"customer") $10 '('DataSize '"247") $11 $12 $13))
    (let $84 (YtTable '"customer" $82 $9 $83 '() (Void) (Void) '"/Root/plato"))
    (let $85 (YtReadTable! world $1 '((YtSection '((YtPath $84 '('"c_custkey" '"c_nationkey") (Void) (Void))) '()))))
    (let $86 '('0 '0 '1 '1))
    (let $87 '('"o_custkey" '2 '"o_orderkey" '3))
    (return (MapJoinCore (DqReadWideWrap $85 '()) $79 'Inner '('0) '('"o_custkey") $86 $87 '('"c.c_custkey") '('"o.o_custkey")))
  ))))))
))) $22))
(let $24 (DataType 'Double))
(let $25 (StructType '('"l_discount" $24) '('"l_extendedprice" $24) '('"l_orderkey" $7) '('"l_suppkey" $7)))
(let $26 '('('"_logical_id" '8002) '('"_id" '"dfc1e4e3-e7f0d57b-fdbdd96b-9d2ee61d") '('"_wide_channels" $25)))
(let $27 (DqPhyStage '() (lambda '() (block '(
  (let $88 '@@["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 $89 '('"l_orderkey" '"l_linenumber"))
  (let $90 (YqlRowSpec $2 $3 $4 '('Type $88) '('SortDirections '($5 $5)) '('SortMembers $89) '('SortedBy $89) '('SortedByTypes '($7 $7))))
  (let $91 (YtStat '('Id '"lineitem") $10 '('DataSize '"343") $11 $12 $13))
  (let $92 (YtTable '"lineitem" $90 $9 $91 '() (Void) (Void) '"/Root/plato"))
  (let $93 '('"l_discount" '"l_extendedprice" '"l_orderkey" '"l_suppkey"))
  (let $94 (YtReadTable! world $1 '((YtSection '((YtPath $92 $93 (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $94 '())))
))) $26))
(let $28 '('"s_suppkey"))
(let $29 '('('"_logical_id" '8026) '('"_id" '"dd1e3c75-3ad5c31a-fe2faf98-78ecc033") '('"_wide_channels" (StructType '('"s_nationkey" $7) '('"s_suppkey" $7)))))
(let $30 (DqPhyStage '() (lambda '() (block '(
  (let $95 '@@["StructType";[["s_suppkey";["DataType";"Int32"]];["s_comment";["DataType";"String"]];["s_address";["DataType";"String"]];["s_acctbal";["DataType";"Double"]];["s_nationkey";["DataType";"Int32"]];["s_name";["DataType";"String"]];["s_phone";["DataType";"String"]]]]@@)
  (let $96 (YqlRowSpec $20 $3 $4 '('Type $95) $6 '('SortMembers $28) '('SortedBy $28) $8))
  (let $97 (YtStat '('Id '"supplier") $10 '('DataSize '"206") $11 $12 $13))
  (let $98 (YtTable '"supplier" $96 $9 $97 '() (Void) (Void) '"/Root/plato"))
  (let $99 (YtReadTable! world $1 '((YtSection '((YtPath $98 '('"s_nationkey" '"s_suppkey") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $99 '())))
))) $29))
(let $31 '('"n_name" (DataType 'String)))
(let $32 (StructType $31 '('"n_nationkey" $7) '('"n_regionkey" $7)))
(let $33 '('('"_logical_id" '8053) '('"_id" '"caf21810-4713a471-d4c73288-70f3594") '('"_wide_channels" $32)))
(let $34 (DqPhyStage '() (lambda '() (block '(
  (let $100 '@@["StructType";[["n_nationkey";["DataType";"Int32"]];["n_regionkey";["DataType";"Int32"]];["n_name";["DataType";"String"]];["n_comment";["DataType";"String"]]]]@@)
  (let $101 '('"n_nationkey"))
  (let $102 (YqlRowSpec $20 $3 $4 '('Type $100) $6 '('SortMembers $101) '('SortedBy $101) $8))
  (let $103 (YtStat '('Id '"nation") $10 '('DataSize '"121") $11 $12 $13))
  (let $104 (YtTable '"nation" $102 $9 $103 '() (Void) (Void) '"/Root/plato"))
  (let $105 '('"n_name" '"n_nationkey" '"n_regionkey"))
  (let $106 (YtReadTable! world $1 '((YtSection '((YtPath $104 $105 (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $106 '())))
))) $33))
(let $35 '('"r_regionkey"))
(let $36 '('('"_logical_id" '8221) '('"_id" '"8fa6d05c-2ebdce6b-953b053d-4a40db4b") '('"_wide_channels" (StructType '('"r_regionkey" $7)))))
(let $37 (DqPhyStage '() (lambda '() (block '(
  (let $107 '@@["StructType";[["r_regionkey";["DataType";"Int32"]];["r_comment";["DataType";"String"]];["r_name";["DataType";"String"]]]]@@)
  (let $108 (YqlRowSpec $20 $3 $4 '('Type $107) $6 '('SortMembers $35) '('SortedBy $35) $8))
  (let $109 (YtStat '('Id '"region") $10 '('DataSize '"168") $11 $12 $13))
  (let $110 (YtTable '"region" $108 $9 $109 '() (Void) (Void) '"/Root/plato"))
  (let $111 (YtReadTable! world $1 '((YtSection '((YtPath $110 '('"r_name" '"r_regionkey") (Void) (Void))) $14))))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $111 '()) (lambda '($112 $113) (== $112 (String '"AFRICA")))) (lambda '($114 $115) $115))))
))) $36))
(let $38 (DqCnMap (TDqOutput $23 '0)))
(let $39 (DqCnBroadcast (TDqOutput $27 '0)))
(let $40 (DqCnBroadcast (TDqOutput $30 '0)))
(let $41 (DqCnBroadcast (TDqOutput $34 '0)))
(let $42 (DqCnBroadcast (TDqOutput $37 '0)))
(let $43 '($38 $39 $40 $41 $42))
(let $44 '('1))
(let $45 (lambda '($172 $173) $173 $172))
(let $46 '('('"_logical_id" '8729) '('"_id" '"d0681ce0-70298ce3-bbd20c48-408b1798") '('"_wide_channels" (StructType '('_yql_agg_0 $24) $31))))
(let $47 (DqPhyStage $43 (lambda '($116 $117 $118 $119 $120) (block '(
  (let $121 (NarrowSqueezeToDict (ToFlow $120) (lambda '($123) $123) (lambda '($124) (AsStruct '('"r_regionkey" $124))) $19))
  (let $122 (Int32 '1))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (FlatMap $121 (lambda '($125) (block '(
    (let $126 (NarrowSqueezeToDict (ToFlow $119) (lambda '($129 $130 $131) '($130 $130)) (lambda '($132 $133 $134) (AsStruct '('"n_name" $132) '('"n_nationkey" $133) '('"n_regionkey" $134))) $19))
    (let $127 '('3))
    (let $128 '('0 '0 '1 '1 '2 '2))
    (return (MapJoinCore (FlatMap $126 (lambda '($135) (block '(
      (let $136 (NarrowSqueezeToDict (ToFlow $118) (lambda '($139 $140) $140) (lambda '($141 $142) (AsStruct '('"s_nationkey" $141) '('"s_suppkey" $142))) $19))
      (let $137 '('1 '0 '2 '1))
      (let $138 '('"n_name" '2 '"n_regionkey" '3))
      (return (MapJoinCore (FlatMap $136 (lambda '($143) (block '(
        (let $144 (NarrowSqueezeToDict (ToFlow $117) (lambda '($145 $146 $147 $148) $147) (lambda '($149 $150 $151 $152) (AsStruct '('"l_discount" $149) '('"l_extendedprice" $150) '('"l_orderkey" $151) '('"l_suppkey" $152))) $19))
        (return (MapJoinCore (FlatMap $144 (lambda '($153) (block '(
          (let $154 (lambda '($156 $157 $158 $159) $157 $159))
          (let $155 '('"l_discount" '1 '"l_extendedprice" '2 '"l_suppkey" '3))
          (return (MapJoinCore (WideMap (ToFlow $116) $154) $153 'Inner $44 '('"l_orderkey") '('0 '0) $155 '('"o.o_orderkey") '('"l.l_orderkey")))
        )))) $143 'Inner $127 $28 $128 '('"s_nationkey" '3) '('"l.l_suppkey") '('"s.s_suppkey")))
      )))) $135 'Inner '('3 '0) '('"n_nationkey" '"n_nationkey") $137 $138 '('"s.s_nationkey" '"c.c_nationkey") '('"n.n_nationkey" '"n.n_nationkey")))
    )))) $125 'Inner $127 $35 $128 '() '('"n.n_regionkey") '('"r.r_regionkey")))
  )))))) '-1073741824 (lambda '($160 $161 $162) $162) (lambda '($163 $164 $165 $166) (* $165 (- $122 $164))) (lambda '($167 $168 $169 $170 $171) (AggrAdd (* $169 (- $122 $168)) $171)) $45))
))) $46))
(let $48 (DqCnHashShuffle (TDqOutput $47 '0) $44 '0 '"HashV2"))
(let $49 (StructType $31 '('"revenue" $24)))
(let $50 '('('"_logical_id" '9996) '('"_id" '"3740fd9e-ec0408eb-db1ddeb3-fd67d90f") '('"_wide_channels" $49)))
(let $51 (DqPhyStage '($48) (lambda '($174) (block '(
  (let $175 (WideCombiner (ToFlow (WideFromBlocks $174)) '"" (lambda '($177 $178) $178) (lambda '($179 $180 $181) $180) (lambda '($182 $183 $184 $185) (AggrAdd $183 $185)) $45))
  (let $176 (lambda '($186 $187) $187 $186))
  (return (FromFlow (WideMap (WideSort $175 '('('0 $15))) $176)))
))) $50))
(let $52 (DqCnMerge (TDqOutput $51 '0) '('('1 '"Desc"))))
(let $53 (DqPhyStage '($52) (lambda '($188) (FromFlow (NarrowMap (ToFlow $188) (lambda '($189 $190) (AsStruct '('"n_name" $189) '('"revenue" $190)))))) '('('"_logical_id" '10008) '('"_id" '"7ecf091c-845915ec-11bf2667-e71537d8"))))
(let $54 '($17 $23 $27 $30 $34 $37 $47 $51 $53))
(let $55 (DqCnResult (TDqOutput $53 '0) '('"n_name" '"revenue")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $54 '($55) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $49) '0 '0)) '('('"type" '"query"))))
)
