(
(let $1 (DataSource '"yt" '"/Root/plato"))
(let $2 '('NativeYtTypeFlags '2))
(let $3 '('StrictSchema '1))
(let $4 '('UniqueKeys '0))
(let $5 (Bool 'true))
(let $6 (DataType 'Int32))
(let $7 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0)))
(let $8 '('RecordsCount '1))
(let $9 '('ChunkCount '1))
(let $10 '('ModifyTime '0))
(let $11 '('Revision '0))
(let $12 (DataType 'Double))
(let $13 (StructType '('"l_discount" $12) '('"l_extendedprice" $12) '('"l_orderkey" $6) '('"l_partkey" $6) '('"l_suppkey" $6)))
(let $14 '('('"_logical_id" '15624) '('"_id" '"b3200210-70c15dd7-91f73245-c83ca81e") '('"_wide_channels" $13)))
(let $15 (DqPhyStage '() (lambda '() (block '(
  (let $77 '@@["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 $78 '('"l_orderkey" '"l_linenumber"))
  (let $79 (YqlRowSpec $2 $3 $4 '('Type $77) '('SortDirections '($5 $5)) '('SortMembers $78) '('SortedBy $78) '('SortedByTypes '($6 $6))))
  (let $80 (YtStat '('Id '"lineitem") $8 '('DataSize '"343") $9 $10 $11))
  (let $81 (YtTable '"lineitem" $79 $7 $80 '() (Void) (Void) '"/Root/plato"))
  (let $82 '('"l_discount" '"l_extendedprice" '"l_orderkey" '"l_partkey" '"l_suppkey"))
  (let $83 (YtReadTable! world $1 '((YtSection '((YtPath $81 $82 (Void) (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $83 '())))
))) $14))
(let $16 (DqCnBroadcast (TDqOutput $15 '0)))
(let $17 '('Many 'Hashed 'Compact))
(let $18 '('NativeYtTypeFlags '0))
(let $19 '('SortDirections '($5)))
(let $20 '('SortedByTypes '($6)))
(let $21 '('('"unordered")))
(let $22 '('0))
(let $23 (StructType '('"l.l_discount" $12) '('"l.l_extendedprice" $12) '('"l.l_orderkey" $6) '('"l.l_partkey" $6) '('"l.l_suppkey" $6) '('"p.p_partkey" $6)))
(let $24 '('('"_logical_id" '16042) '('"_id" '"da9cf8bc-38ecfd16-80e2ddcf-f4aaefa6") '('"_wide_channels" $23)))
(let $25 (DqPhyStage '($16) (lambda '($84) (block '(
  (let $85 (NarrowSqueezeToDict (ToFlow $84) (lambda '($86 $87 $88 $89 $90) $89) (lambda '($91 $92 $93 $94 $95) (AsStruct '('"l_discount" $91) '('"l_extendedprice" $92) '('"l_orderkey" $93) '('"l_partkey" $94) '('"l_suppkey" $95))) $17))
  (return (FromFlow (FlatMap $85 (lambda '($96) (block '(
    (let $97 '@@["StructType";[["p_partkey";["DataType";"Int32"]];["p_name";["DataType";"String"]];["p_container";["DataType";"String"]];["p_size";["DataType";"Int64"]];["p_type";["DataType";"String"]];["p_comment";["DataType";"String"]];["p_retailprice";["DataType";"Double"]];["p_mfgr";["DataType";"String"]];["p_brand";["DataType";"String"]]]]@@)
    (let $98 '('"p_partkey"))
    (let $99 (YqlRowSpec $18 $3 $4 '('Type $97) $19 '('SortMembers $98) '('SortedBy $98) $20))
    (let $100 (YtStat '('Id '"part") $8 '('DataSize '"239") $9 $10 $11))
    (let $101 (YtTable '"part" $99 $7 $100 '() (Void) (Void) '"/Root/plato"))
    (let $102 (YtReadTable! world $1 '((YtSection '((YtPath $101 '('"p_partkey" '"p_type") (Void) (Void) (Void))) $21))))
    (let $103 '('"l_discount" '0 '"l_extendedprice" '1 '"l_orderkey" '2 '"l_partkey" '3 '"l_suppkey" '4))
    (return (MapJoinCore (WideMap (WideFilter (DqReadWideWrap $102 '()) (lambda '($104 $105) (== $105 (String '"ECONOMY PLATED COPPER")))) (lambda '($106 $107) $106)) $96 'Inner $22 '('"l_partkey") '('0 '5) $103 '('"p.p_partkey") '('"l.l_partkey")))
  ))))))
))) $24))
(let $26 '('"s_suppkey"))
(let $27 '('('"_logical_id" '15648) '('"_id" '"e291b66d-416ee41b-7a60a08e-65423692") '('"_wide_channels" (StructType '('"s_nationkey" $6) '('"s_suppkey" $6)))))
(let $28 (DqPhyStage '() (lambda '() (block '(
  (let $108 '@@["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 $109 (YqlRowSpec $18 $3 $4 '('Type $108) $19 '('SortMembers $26) '('SortedBy $26) $20))
  (let $110 (YtStat '('Id '"supplier") $8 '('DataSize '"206") $9 $10 $11))
  (let $111 (YtTable '"supplier" $109 $7 $110 '() (Void) (Void) '"/Root/plato"))
  (let $112 (YtReadTable! world $1 '((YtSection '((YtPath $111 '('"s_nationkey" '"s_suppkey") (Void) (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $112 '())))
))) $27))
(let $29 '@@["StructType";[["n_nationkey";["DataType";"Int32"]];["n_regionkey";["DataType";"Int32"]];["n_name";["DataType";"String"]];["n_comment";["DataType";"String"]]]]@@)
(let $30 '('"n_nationkey"))
(let $31 (YqlRowSpec $18 $3 $4 '('Type $29) $19 '('SortMembers $30) '('SortedBy $30) $20))
(let $32 (YtStat '('Id '"nation") $8 '('DataSize '"121") $9 $10 $11))
(let $33 (YtTable '"nation" $31 $7 $32 '() (Void) (Void) '"/Root/plato"))
(let $34 '('"n_nationkey" $6))
(let $35 '('('"_logical_id" '15672) '('"_id" '"368e45fc-3831f58b-72448de8-293a1503") '('"_wide_channels" (StructType '('"n_name" (DataType 'String)) $34))))
(let $36 (DqPhyStage '() (lambda '() (block '(
  (let $113 (YtReadTable! world $1 '((YtSection '((YtPath $33 '('"n_name" '"n_nationkey") (Void) (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $113 '())))
))) $35))
(let $37 '('"o_orderkey"))
(let $38 (DataType 'Timestamp))
(let $39 (DataType 'Date))
(let $40 (OptionalType $39))
(let $41 (StructType '('"o_custkey" $6) '('"o_orderdate" $40) '('"o_orderkey" $6)))
(let $42 '('('"_logical_id" '15931) '('"_id" '"9e7be642-73776581-a79e728f-345a9ec2") '('"_wide_channels" $41)))
(let $43 (DqPhyStage '() (lambda '() (block '(
  (let $114 '@@["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 $115 (YqlRowSpec $2 $3 $4 '('Type $114) $19 '('SortMembers $37) '('SortedBy $37) $20))
  (let $116 (YtStat '('Id '"orders") $8 '('DataSize '"224") $9 $10 $11))
  (let $117 (YtTable '"orders" $115 $7 $116 '() (Void) (Void) '"/Root/plato"))
  (let $118 '('"o_custkey" '"o_orderdate" '"o_orderkey"))
  (let $119 (YtReadTable! world $1 '((YtSection '((YtPath $117 $118 (Void) (Void) (Void))) $21))))
  (return (FromFlow (WideFilter (DqReadWideWrap $119 '()) (lambda '($120 $121 $122) (block '(
    (let $123 (IfPresent $121 (lambda '($125) (Just (SafeCast (SafeCast $125 $38) $39))) (Nothing $40)))
    (let $124 (Bool 'false))
    (return (And (Coalesce (>= $123 (Date '"9131")) $124) (Coalesce (<= $123 (Date '"9861")) $124)))
  ))))))
))) $42))
(let $44 '('"c_custkey"))
(let $45 '('('"_logical_id" '15724) '('"_id" '"7b3a7959-2573b7f6-8e8d9072-1668612") '('"_wide_channels" (StructType '('"c_custkey" $6) '('"c_nationkey" $6)))))
(let $46 (DqPhyStage '() (lambda '() (block '(
  (let $126 '@@["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 $127 (YqlRowSpec $18 $3 $4 '('Type $126) $19 '('SortMembers $44) '('SortedBy $44) $20))
  (let $128 (YtStat '('Id '"customer") $8 '('DataSize '"247") $9 $10 $11))
  (let $129 (YtTable '"customer" $127 $7 $128 '() (Void) (Void) '"/Root/plato"))
  (let $130 (YtReadTable! world $1 '((YtSection '((YtPath $129 '('"c_custkey" '"c_nationkey") (Void) (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $130 '())))
))) $45))
(let $47 '('('"_logical_id" '15748) '('"_id" '"ca055493-d357c7a9-a2777c0f-d20b49a4") '('"_wide_channels" (StructType $34 '('"n_regionkey" $6)))))
(let $48 (DqPhyStage '() (lambda '() (block '(
  (let $131 (YtReadTable! world $1 '((YtSection '((YtPath $33 '('"n_nationkey" '"n_regionkey") (Void) (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $131 '())))
))) $47))
(let $49 '('"r_regionkey"))
(let $50 (lambda '($139 $140) $140))
(let $51 '('('"_logical_id" '15961) '('"_id" '"70a6f240-3e6c3d4f-5c1b78b3-e65677d6") '('"_wide_channels" (StructType '('"r_regionkey" $6)))))
(let $52 (DqPhyStage '() (lambda '() (block '(
  (let $132 '@@["StructType";[["r_regionkey";["DataType";"Int32"]];["r_comment";["DataType";"String"]];["r_name";["DataType";"String"]]]]@@)
  (let $133 (YqlRowSpec $18 $3 $4 '('Type $132) $19 '('SortMembers $49) '('SortedBy $49) $20))
  (let $134 (YtStat '('Id '"region") $8 '('DataSize '"168") $9 $10 $11))
  (let $135 (YtTable '"region" $133 $7 $134 '() (Void) (Void) '"/Root/plato"))
  (let $136 (YtReadTable! world $1 '((YtSection '((YtPath $135 '('"r_name" '"r_regionkey") (Void) (Void) (Void))) $21))))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $136 '()) (lambda '($137 $138) (== $137 (String '"AFRICA")))) $50)))
))) $51))
(let $53 (DqCnMap (TDqOutput $25 '0)))
(let $54 (DqCnBroadcast (TDqOutput $28 '0)))
(let $55 (DqCnBroadcast (TDqOutput $36 '0)))
(let $56 (DqCnBroadcast (TDqOutput $43 '0)))
(let $57 (DqCnBroadcast (TDqOutput $46 '0)))
(let $58 (DqCnBroadcast (TDqOutput $48 '0)))
(let $59 (DqCnBroadcast (TDqOutput $52 '0)))
(let $60 '($53 $54 $55 $56 $57 $58 $59))
(let $61 '('2))
(let $62 (DataType 'Uint16))
(let $63 (OptionalType $62))
(let $64 (lambda '($231 $232 $233) $232 $233 $231))
(let $65 '('"o_year" $63))
(let $66 (StructType '('_yql_agg_0 $12) '('_yql_agg_1 $12) $65))
(let $67 '('('"_logical_id" '16677) '('"_id" '"1a2b80c9-4d08dc97-19176f36-57af67f1") '('"_wide_channels" $66)))
(let $68 (DqPhyStage $60 (lambda '($141 $142 $143 $144 $145 $146 $147) (block '(
  (let $148 (NarrowSqueezeToDict (ToFlow $147) (lambda '($154) $154) (lambda '($155) (AsStruct '('"r_regionkey" $155))) $17))
  (let $149 (String '"MOZAMBIQUE"))
  (let $150 (Int32 '1))
  (let $151 (Convert (Int32 '0) $12))
  (let $152 (lambda '($215 $216 $217 $218 $219) (block '(
    (let $220 (* $217 (- $150 $216)))
    (let $221 (If (== $218 $149) $220 $151))
    (return $221 $220)
  ))))
  (let $153 (lambda '($222 $223 $224 $225 $226 $227 $228) (block '(
    (let $229 (* $224 (- $150 $223)))
    (let $230 (If (== $225 $149) $229 $151))
    (return (AggrAdd $230 $227) (AggrAdd $229 $228))
  ))))
  (return (DqPhyHashCombine (FromFlow (FlatMap $148 (lambda '($156) (block '(
    (let $157 (lambda '($160 $161) $160))
    (let $158 (NarrowSqueezeToDict (ToFlow $146) $157 (lambda '($162 $163) (AsStruct '('"n_nationkey" $162) '('"n_regionkey" $163))) $17))
    (let $159 '('0 '0 '1 '1 '3 '2 '4 '3))
    (return (MapJoinCore (FlatMap $158 (lambda '($164) (block '(
      (let $165 (NarrowSqueezeToDict (ToFlow $145) $157 (lambda '($167 $168) (AsStruct '('"c_custkey" $167) '('"c_nationkey" $168))) $17))
      (let $166 '('1 '0 '2 '1 '3 '3 '4 '4))
      (return (MapJoinCore (FlatMap $165 (lambda '($169) (block '(
        (let $170 (NarrowSqueezeToDict (ToFlow $144) (lambda '($173 $174 $175) $175) (lambda '($176 $177 $178) (AsStruct '('"o_custkey" $176) '('"o_orderdate" $177) '('"o_orderkey" $178))) $17))
        (let $171 '('3))
        (let $172 '('0 '1 '1 '2 '2 '3 '4 '4))
        (return (MapJoinCore (FlatMap $170 (lambda '($179) (block '(
          (let $180 (NarrowSqueezeToDict (ToFlow $143) $50 (lambda '($183 $184) (AsStruct '('"n_name" $183) '('"n_nationkey" $184))) $17))
          (let $181 '('0 '0 '1 '1 '3 '2))
          (let $182 '('"o_custkey" '3 '"o_orderdate" '4))
          (return (MapJoinCore (FlatMap $180 (lambda '($185) (block '(
            (let $186 (NarrowSqueezeToDict (ToFlow $142) (lambda '($188 $189) $189) (lambda '($190 $191) (AsStruct '('"s_nationkey" $190) '('"s_suppkey" $191))) $17))
            (let $187 '('0 '0 '1 '1 '2 '2))
            (return (MapJoinCore (FlatMap $186 (lambda '($192) (block '(
              (let $193 (lambda '($194 $195 $196 $197 $198 $199) $194 $195 $196 $198))
              (return (MapJoinCore (WideMap (ToFlow $141) $193) $192 'Inner $171 $26 $187 '('"s_nationkey" '3) '('"l.l_suppkey") '('"s.s_suppkey")))
            )))) $185 'Inner $171 $30 $187 '('"n_name" '3) '('"s.s_nationkey") '('"n_1.n_nationkey")))
          )))) $179 'Inner $61 $37 $181 $182 '('"l.l_orderkey") '('"o.o_orderkey")))
        )))) $169 'Inner $171 $44 $172 '('"c_nationkey" '0) '('"o.o_custkey") '('"c.c_custkey")))
      )))) $164 'Inner $22 $30 $166 '('"n_regionkey" '2) '('"c.c_nationkey") '('"n.n_nationkey")))
    )))) $156 'Inner $61 $49 $159 '() '('"n.n_regionkey") '('"r.r_regionkey")))
  ))))) '-1073741824 (lambda '($200 $201 $202 $203) (IfPresent $203 (lambda '($204) (block '(
    (let $205 (TupleType (TupleType (OptionalType $38)) (StructType) (TupleType)))
    (let $206 (ResourceType '"DateTime2.TM"))
    (let $207 '($206 '"" '1))
    (let $208 (CallableType '() '($62) $207))
    (let $209 '('"strict"))
    (let $210 (Udf '"DateTime2.GetYear" (Void) $205 '"" $208 (VoidType) '"" '($209)))
    (let $211 (TupleType (TupleType $38) (StructType) (TupleType)))
    (let $212 '($38 '"" '1))
    (let $213 (CallableType '() '($206) $212))
    (let $214 (Udf '"DateTime2.Split" (Void) $211 '"" $213 (VoidType) '"" '('('"blocks") $209)))
    (return (Just (Apply $210 (Apply $214 (SafeCast $204 $38)))))
  ))) (Nothing $63))) $152 $153 $64))
))) $67))
(let $69 (DqCnHashShuffle (TDqOutput $68 '0) $61 '0 '"HashV2"))
(let $70 (StructType '('"mkt_share" $12) $65))
(let $71 '('('"_logical_id" '18587) '('"_id" '"fc0700f2-f89c9773-63b6bb68-d05fb545") '('"_wide_channels" $70)))
(let $72 (DqPhyStage '($69) (lambda '($234) (block '(
  (let $235 (lambda '($242 $243 $244 $245) $243 $244))
  (let $236 (lambda '($246 $247 $248 $249 $250 $251) (AggrAdd $247 $250) (AggrAdd $248 $251)))
  (let $237 (WideCombiner (ToFlow $234) '"" (lambda '($239 $240 $241) $241) $235 $236 $64))
  (let $238 (lambda '($252 $253 $254) (/ $252 $253) $254))
  (return (FromFlow (WideMap (WideSort $237 '('('2 $5))) $238)))
))) $71))
(let $73 (DqCnMerge (TDqOutput $72 '0) '('('1 '"Asc"))))
(let $74 (DqPhyStage '($73) (lambda '($255) (FromFlow (NarrowMap (ToFlow $255) (lambda '($256 $257) (AsStruct '('"mkt_share" $256) '('"o_year" $257)))))) '('('"_logical_id" '18599) '('"_id" '"4d3dd95d-13ff1ff3-7b764233-fd22cb6"))))
(let $75 '($15 $25 $28 $36 $43 $46 $48 $52 $68 $72 $74))
(let $76 (DqCnResult (TDqOutput $74 '0) '('"o_year" '"mkt_share")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $75 '($76) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $70) '0 '0)) '('('"type" '"query"))))
)
