(
(let $1 (DataSource '"yt" '"/Root/plato"))
(let $2 '('NativeYtTypeFlags '0))
(let $3 '('StrictSchema '1))
(let $4 '('UniqueKeys '0))
(let $5 (Bool 'true))
(let $6 '('SortDirections '($5)))
(let $7 '('"n_nationkey"))
(let $8 (DataType 'Int32))
(let $9 '('SortedByTypes '($8)))
(let $10 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0)))
(let $11 '('RecordsCount '1))
(let $12 '('ChunkCount '1))
(let $13 '('ModifyTime '0))
(let $14 '('Revision '0))
(let $15 '('('"unordered")))
(let $16 (String '"PERU"))
(let $17 (String '"MOZAMBIQUE"))
(let $18 (lambda '() (block '(
  (let $84 '@@["StructType";[["n_nationkey";["DataType";"Int32"]];["n_regionkey";["DataType";"Int32"]];["n_name";["DataType";"String"]];["n_comment";["DataType";"String"]]]]@@)
  (let $85 (YqlRowSpec $2 $3 $4 '('Type $84) $6 '('SortMembers $7) '('SortedBy $7) $9))
  (let $86 (YtStat '('Id '"nation") $11 '('DataSize '"121") $12 $13 $14))
  (let $87 (YtTable '"nation" $85 $10 $86 '() (Void) (Void) '"/Root/plato"))
  (let $88 (YtReadTable! world $1 '((YtSection '((YtPath $87 '('"n_name" '"n_nationkey") (Void) (Void))) $15))))
  (return (FromFlow (WideFilter (DqReadWideWrap $88 '()) (lambda '($89 $90) (Or (== $89 $16) (== $89 $17))))))
))))
(let $19 '('"_logical_id" '7388))
(let $20 (DataType 'String))
(let $21 '('"_wide_channels" (StructType '('"n_name" $20) '('"n_nationkey" $8))))
(let $22 '($19 '('"_id" '"d31c1efc-df904fd-dc10ac8a-25da2449") $21))
(let $23 (DqPhyStage '() $18 $22))
(let $24 (DqCnBroadcast (TDqOutput $23 '0)))
(let $25 (lambda '($93 $94) $94))
(let $26 (lambda '($95 $96) (AsStruct '('"n_name" $95) '('"n_nationkey" $96))))
(let $27 '('Many 'Hashed 'Compact))
(let $28 '"customer_1.c_nationkey")
(let $29 '"customer_1.c_custkey")
(let $30 '($29 $8))
(let $31 '($28 $8))
(let $32 '('"n2.n_name" $20))
(let $33 '('"n2.n_nationkey" $8))
(let $34 (StructType $30 $31 $32 $33))
(let $35 '('('"_logical_id" '7452) '('"_id" '"53923ef2-1478c9c1-871079be-36537abc") '('"_wide_channels" $34)))
(let $36 (DqPhyStage '($24) (lambda '($91) (block '(
  (let $92 (NarrowSqueezeToDict (ToFlow $91) $25 $26 $27))
  (return (FromFlow (FlatMap $92 (lambda '($97) (block '(
    (let $98 '@@["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 $99 '('"c_custkey"))
    (let $100 (YqlRowSpec $2 $3 $4 '('Type $98) $6 '('SortMembers $99) '('SortedBy $99) $9))
    (let $101 (YtStat '('Id '"customer") $11 '('DataSize '"247") $12 $13 $14))
    (let $102 (YtTable '"customer" $100 $10 $101 '() (Void) (Void) '"/Root/plato"))
    (let $103 (YtReadTable! world $1 '((YtSection '((YtPath $102 '('"c_custkey" '"c_nationkey") (Void) (Void))) '()))))
    (let $104 '('0 '0 '1 '1))
    (let $105 '('"n_name" '2 '"n_nationkey" '3))
    (return (MapJoinCore (DqReadWideWrap $103 '()) $97 'Inner '('1) $7 $104 $105 '($28) '('"n2.n_nationkey")))
  ))))))
))) $35))
(let $37 (DqCnBroadcast (TDqOutput $36 '0)))
(let $38 '('NativeYtTypeFlags '2))
(let $39 '('0))
(let $40 '"orders_1.o_custkey")
(let $41 '($40 $8))
(let $42 '"orders_1.o_orderkey")
(let $43 '($42 $8))
(let $44 (StructType $30 $31 $32 $33 $41 $43))
(let $45 '('('"_logical_id" '7499) '('"_id" '"be124b04-e99b08c-37fe48ff-50e2325b") '('"_wide_channels" $44)))
(let $46 (DqPhyStage '($37) (lambda '($106) (block '(
  (let $107 (NarrowSqueezeToDict (ToFlow $106) (lambda '($108 $109 $110 $111) $108) (lambda '($112 $113 $114 $115) (AsStruct '($29 $112) '($28 $113) '('"n2.n_name" $114) '('"n2.n_nationkey" $115))) $27))
  (return (FromFlow (FlatMap $107 (lambda '($116) (block '(
    (let $117 '@@["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 $118 '('"o_orderkey"))
    (let $119 (YqlRowSpec $38 $3 $4 '('Type $117) $6 '('SortMembers $118) '('SortedBy $118) $9))
    (let $120 (YtStat '('Id '"orders") $11 '('DataSize '"224") $12 $13 $14))
    (let $121 (YtTable '"orders" $119 $10 $120 '() (Void) (Void) '"/Root/plato"))
    (let $122 (YtReadTable! world $1 '((YtSection '((YtPath $121 '('"o_custkey" '"o_orderkey") (Void) (Void))) '()))))
    (let $123 '($29))
    (let $124 '('0 '4 '1 '5))
    (let $125 '($29 '0 $28 '1 '"n2.n_name" '2 '"n2.n_nationkey" '3))
    (return (MapJoinCore (DqReadWideWrap $122 '()) $116 'Inner $39 $123 $124 $125 '($40) $123))
  ))))))
))) $45))
(let $47 (DqCnBroadcast (TDqOutput $46 '0)))
(let $48 (DataType 'Uint16))
(let $49 (OptionalType $48))
(let $50 '"lineitem_1.l_orderkey")
(let $51 '"lineitem_1.l_suppkey")
(let $52 (DataType 'Double))
(let $53 (StructType $30 $31 '($50 $8) '($51 $8) '('"lineitem_1.l_year" $49) '('"lineitem_1.volume" $52) $32 $33 $41 $43))
(let $54 '('('"_logical_id" '7545) '('"_id" '"5cb7d73c-6e900412-bd913e3a-454a539f") '('"_wide_channels" $53)))
(let $55 (DqPhyStage '($47) (lambda '($126) (block '(
  (let $127 (NarrowSqueezeToDict (ToFlow $126) (lambda '($128 $129 $130 $131 $132 $133) $133) (lambda '($134 $135 $136 $137 $138 $139) (AsStruct '($29 $134) '($28 $135) '('"n2.n_name" $136) '('"n2.n_nationkey" $137) '($40 $138) '($42 $139))) $27))
  (return (FromFlow (FlatMap $127 (lambda '($140) (block '(
    (let $141 '@@["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 $142 '('"l_orderkey" '"l_linenumber"))
    (let $143 (YqlRowSpec $38 $3 $4 '('Type $141) '('SortDirections '($5 $5)) '('SortMembers $142) '('SortedBy $142) '('SortedByTypes '($8 $8))))
    (let $144 (YtStat '('Id '"lineitem") $11 '('DataSize '"343") $12 $13 $14))
    (let $145 (YtTable '"lineitem" $143 $10 $144 '() (Void) (Void) '"/Root/plato"))
    (let $146 '('"l_discount" '"l_extendedprice" '"l_orderkey" '"l_shipdate" '"l_suppkey"))
    (let $147 (YtReadTable! world $1 '((YtSection '((YtPath $145 $146 (Void) (Void))) $15))))
    (let $148 (DataType 'Timestamp))
    (let $149 (lambda '($162 $163 $164 $165 $166) (block '(
      (let $167 (IfPresent $165 (lambda '($168) (block '(
        (let $169 (TupleType (TupleType (OptionalType $148)) (StructType) (TupleType)))
        (let $170 (ResourceType '"DateTime2.TM"))
        (let $171 '($170 '"" '1))
        (let $172 (CallableType '() '($48) $171))
        (let $173 '('"strict"))
        (let $174 (Udf '"DateTime2.GetYear" (Void) $169 '"" $172 (VoidType) '"" '($173)))
        (let $175 (TupleType (TupleType $148) (StructType) (TupleType)))
        (let $176 '($148 '"" '1))
        (let $177 (CallableType '() '($170) $176))
        (let $178 (Udf '"DateTime2.Split" (Void) $175 '"" $177 (VoidType) '"" '('('"blocks") $173)))
        (return (Just (Apply $174 (Apply $178 (SafeCast $168 $148)))))
      ))) (Nothing $49)))
      (return $164 $166 $167 (* $163 (- (Int32 '1) $162)))
    ))))
    (let $150 '($42))
    (let $151 '('0 '2 '1 '3 '2 '4 '3 '5))
    (let $152 '($29 '0 $28 '1 '"n2.n_name" '6 '"n2.n_nationkey" '7 $40 '8 $42 '9))
    (return (MapJoinCore (WideMap (WideFilter (DqReadWideWrap $147 '()) (lambda '($153 $154 $155 $156 $157) (block '(
      (let $158 (DataType 'Date))
      (let $159 (IfPresent $156 (lambda '($161) (Just (SafeCast (SafeCast $161 $148) $158))) (Nothing (OptionalType $158))))
      (let $160 (Bool 'false))
      (return (And (Coalesce (>= $159 (Date '"9131")) $160) (Coalesce (<= $159 (Date '"9861")) $160)))
    )))) $149) $140 'Inner $39 $150 $151 $152 '($50) $150))
  ))))))
))) $54))
(let $56 '($19 '('"_id" '"fcc5b6b0-51440fa8-c8b0ea10-843fbffa") $21))
(let $57 (DqPhyStage '() $18 $56))
(let $58 (DqCnBroadcast (TDqOutput $57 '0)))
(let $59 '"supplier_1.s_nationkey")
(let $60 '"supplier_1.s_suppkey")
(let $61 (StructType '('"n1.n_name" $20) '('"n1.n_nationkey" $8) '($59 $8) '($60 $8)))
(let $62 '('('"_logical_id" '7590) '('"_id" '"5990a7ce-f5a56e4d-5c57346f-a0599cff") '('"_wide_channels" $61)))
(let $63 (DqPhyStage '($58) (lambda '($179) (block '(
  (let $180 (NarrowSqueezeToDict (ToFlow $179) $25 $26 $27))
  (return (FromFlow (FlatMap $180 (lambda '($181) (block '(
    (let $182 '@@["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 $183 '('"s_suppkey"))
    (let $184 (YqlRowSpec $2 $3 $4 '('Type $182) $6 '('SortMembers $183) '('SortedBy $183) $9))
    (let $185 (YtStat '('Id '"supplier") $11 '('DataSize '"206") $12 $13 $14))
    (let $186 (YtTable '"supplier" $184 $10 $185 '() (Void) (Void) '"/Root/plato"))
    (let $187 (YtReadTable! world $1 '((YtSection '((YtPath $186 '('"s_nationkey" '"s_suppkey") (Void) (Void))) '()))))
    (let $188 '('0 '2 '1 '3))
    (let $189 '('"n_name" '0 '"n_nationkey" '1))
    (return (MapJoinCore (DqReadWideWrap $187 '()) $181 'Inner $39 $7 $188 $189 '($59) '('"n1.n_nationkey")))
  ))))))
))) $62))
(let $64 (DqCnMap (TDqOutput $55 '0)))
(let $65 (DqCnBroadcast (TDqOutput $63 '0)))
(let $66 (lambda '($239 $240 $241 $242) $242 $239 $240 $241))
(let $67 '('"cust_nation" $20))
(let $68 '('"l_year" $49))
(let $69 '('"supp_nation" $20))
(let $70 (StructType '('_yql_agg_0 $52) $67 $68 $69))
(let $71 '('('"_logical_id" '7831) '('"_id" '"d82f2be2-a2772918-34af2ee0-bcaa337f") '('"_wide_channels" $70)))
(let $72 (DqPhyStage '($64 $65) (lambda '($190 $191) (block '(
  (let $192 (NarrowSqueezeToDict (ToFlow $191) (lambda '($194 $195 $196 $197) $197) (lambda '($198 $199 $200 $201) (AsStruct '('"n1.n_name" $198) '('"n1.n_nationkey" $199) '($59 $200) '($60 $201))) $27))
  (let $193 (lambda '($220 $221 $222 $223) $223 $220 $222))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (WideFilter (FlatMap $192 (lambda '($202) (block '(
    (let $203 (lambda '($206 $207 $208 $209 $210 $211 $212 $213 $214 $215) $209 $210 $211 $212))
    (let $204 '($60))
    (let $205 '('1 '0 '2 '1 '3 '3))
    (return (MapJoinCore (WideMap (ToFlow $190) $203) $202 'Inner $39 $204 $205 '('"n1.n_name" '2) '($51) $204))
  )))) (lambda '($216 $217 $218 $219) (Or (And (== $218 $16) (== $219 $17)) (And (== $218 $17) (== $219 $16))))))) '-1073741824 $193 (lambda '($224 $225 $226 $227 $228 $229 $230) $228) (lambda '($231 $232 $233 $234 $235 $236 $237 $238) (AggrAdd $235 $238)) $66))
))) $71))
(let $73 '('1 '2 '3))
(let $74 (DqCnHashShuffle (TDqOutput $72 '0) $73 '0 '"HashV2"))
(let $75 (StructType $67 $68 '('"revenue" $52) $69))
(let $76 '('('"_logical_id" '7967) '('"_id" '"980bdde-eb6ae326-d2d36257-fa6372b5") '('"_wide_channels" $75)))
(let $77 (DqPhyStage '($74) (lambda '($243) (block '(
  (let $244 (lambda '($248 $249 $250 $251) $249 $250 $251))
  (let $245 (WideCombiner (ToFlow (WideFromBlocks $243)) '"" $244 (lambda '($252 $253 $254 $255 $256 $257 $258) $255) (lambda '($259 $260 $261 $262 $263 $264 $265 $266) (AggrAdd $262 $266)) $66))
  (let $246 '('('3 $5) '('1 $5) '('2 $5)))
  (let $247 (lambda '($267 $268 $269 $270) $268 $269 $267 $270))
  (return (FromFlow (WideMap (WideSort $245 $246) $247)))
))) $76))
(let $78 '('('3 '"Asc") '('0 '"Asc") '('1 '"Asc")))
(let $79 (DqCnMerge (TDqOutput $77 '0) $78))
(let $80 (DqPhyStage '($79) (lambda '($271) (FromFlow (NarrowMap (ToFlow $271) (lambda '($272 $273 $274 $275) (AsStruct '('"cust_nation" $272) '('"l_year" $273) '('"revenue" $274) '('"supp_nation" $275)))))) '('('"_logical_id" '7979) '('"_id" '"31436d4a-8946deb7-ef09ad31-c74ea32"))))
(let $81 '($23 $36 $46 $55 $57 $63 $72 $77 $80))
(let $82 '('"supp_nation" '"cust_nation" '"l_year" '"revenue"))
(let $83 (DqCnResult (TDqOutput $80 '0) $82))
(return (KqpPhysicalQuery '((KqpPhysicalTx $81 '($83) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $75) '0 '0)) '('('"type" '"query"))))
)
