(
(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 '('"p_partkey"))
(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 '('('"_logical_id" '7183) '('"_id" '"2b2713e0-973fc250-db159381-5df34309") '('"_wide_channels" (StructType '('"p_partkey" $8)))))
(let $16 (DqPhyStage '() (lambda '() (block '(
  (let $70 '@@["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 $71 (YqlRowSpec $2 $3 $4 '('Type $70) $6 '('SortMembers $7) '('SortedBy $7) $9))
  (let $72 (YtStat '('Id '"part") $11 '('DataSize '"239") $12 $13 $14))
  (let $73 (YtTable '"part" $71 $10 $72 '() (Void) (Void) '"/Root/plato"))
  (let $74 (YtReadTable! world $1 '((YtSection '((YtPath $73 '('"p_name" '"p_partkey") (Void) (Void))) '('('"unordered"))))))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $74 '()) (lambda '($75 $76) (Exists (Find $75 (String '"rose") (Nothing (OptionalType (DataType 'Uint32))))))) (lambda '($77 $78) $78))))
))) $15))
(let $17 (DqCnBroadcast (TDqOutput $16 '0)))
(let $18 '('Many 'Hashed 'Compact))
(let $19 '('SortDirections '($5 $5)))
(let $20 '('SortedByTypes '($8 $8)))
(let $21 '('"p.p_partkey" $8))
(let $22 '('"ps.ps_partkey" $8))
(let $23 '('"ps.ps_suppkey" $8))
(let $24 (DataType 'Double))
(let $25 '('"ps.ps_supplycost" $24))
(let $26 (StructType $21 $22 $23 $25))
(let $27 '('('"_logical_id" '7240) '('"_id" '"a9143821-b2698aa7-70da3ae2-da9f9ee") '('"_wide_channels" $26)))
(let $28 (DqPhyStage '($17) (lambda '($79) (block '(
  (let $80 (NarrowSqueezeToDict (ToFlow $79) (lambda '($81) $81) (lambda '($82) (AsStruct '('"p_partkey" $82))) $18))
  (return (FromFlow (FlatMap $80 (lambda '($83) (block '(
    (let $84 '@@["StructType";[["ps_partkey";["DataType";"Int32"]];["ps_suppkey";["DataType";"Int32"]];["ps_comment";["DataType";"String"]];["ps_supplycost";["DataType";"Double"]];["ps_availqty";["DataType";"Int64"]]]]@@)
    (let $85 '('"ps_partkey" '"ps_suppkey"))
    (let $86 (YqlRowSpec $2 $3 $4 '('Type $84) $19 '('SortMembers $85) '('SortedBy $85) $20))
    (let $87 (YtStat '('Id '"partsupp") $11 '('DataSize '"284") $12 $13 $14))
    (let $88 (YtTable '"partsupp" $86 $10 $87 '() (Void) (Void) '"/Root/plato"))
    (let $89 '('"ps_partkey" '"ps_suppkey" '"ps_supplycost"))
    (let $90 (YtReadTable! world $1 '((YtSection '((YtPath $88 $89 (Void) (Void))) '()))))
    (let $91 '('0 '1 '1 '2 '2 '3))
    (return (MapJoinCore (DqReadWideWrap $90 '()) $83 'Inner '('0) $7 $91 '('"p_partkey" '0) '('"ps.ps_partkey") '('"p.p_partkey")))
  ))))))
))) $27))
(let $29 (DqCnBroadcast (TDqOutput $28 '0)))
(let $30 '('NativeYtTypeFlags '2))
(let $31 '('"l.l_discount" $24))
(let $32 '"l.l_extendedprice")
(let $33 '($32 $24))
(let $34 '('"l.l_orderkey" $8))
(let $35 '('"l.l_partkey" $8))
(let $36 '('"l.l_quantity" $24))
(let $37 '('"l.l_suppkey" $8))
(let $38 (StructType $31 $33 $34 $35 $36 $37 $21 $22 $23 $25))
(let $39 '('('"_logical_id" '7291) '('"_id" '"9bdd87d4-2886043-7164cb8e-b8af5440") '('"_wide_channels" $38)))
(let $40 (DqPhyStage '($29) (lambda '($92) (block '(
  (let $93 (NarrowSqueezeToDict (ToFlow $92) (lambda '($94 $95 $96 $97) '($96 $95)) (lambda '($98 $99 $100 $101) (AsStruct '('"p.p_partkey" $98) '('"ps.ps_partkey" $99) '('"ps.ps_suppkey" $100) '('"ps.ps_supplycost" $101))) $18))
  (return (FromFlow (FlatMap $93 (lambda '($102) (block '(
    (let $103 '@@["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 $104 '('"l_orderkey" '"l_linenumber"))
    (let $105 (YqlRowSpec $30 $3 $4 '('Type $103) $19 '('SortMembers $104) '('SortedBy $104) $20))
    (let $106 (YtStat '('Id '"lineitem") $11 '('DataSize '"343") $12 $13 $14))
    (let $107 (YtTable '"lineitem" $105 $10 $106 '() (Void) (Void) '"/Root/plato"))
    (let $108 '('"l_discount" '"l_extendedprice" '"l_orderkey" '"l_partkey" '"l_quantity" '"l_suppkey"))
    (let $109 (YtReadTable! world $1 '((YtSection '((YtPath $107 $108 (Void) (Void))) '()))))
    (let $110 '('"ps.ps_suppkey" '"ps.ps_partkey"))
    (let $111 '('0 '0 '1 '1 '2 '2 '3 '3 '4 '4 '5 '5))
    (let $112 '('"p.p_partkey" '6 '"ps.ps_partkey" '7 '"ps.ps_suppkey" '8 '"ps.ps_supplycost" '9))
    (return (MapJoinCore (DqReadWideWrap $109 '()) $102 'Inner '('5 '3) $110 $111 $112 '('"l.l_suppkey" '"l.l_partkey") $110))
  ))))))
))) $39))
(let $41 (DqCnBroadcast (TDqOutput $40 '0)))
(let $42 '('1))
(let $43 '('"s.s_nationkey" $8))
(let $44 '('"s.s_suppkey" $8))
(let $45 (StructType $31 $33 $34 $35 $36 $37 $21 $22 $23 $25 $43 $44))
(let $46 '('('"_logical_id" '7343) '('"_id" '"807cd13a-5b25fdc0-2197d27c-f1c2acf3") '('"_wide_channels" $45)))
(let $47 (DqPhyStage '($41) (lambda '($113) (block '(
  (let $114 (NarrowSqueezeToDict (ToFlow $113) (lambda '($115 $116 $117 $118 $119 $120 $121 $122 $123 $124) $120) (lambda '($125 $126 $127 $128 $129 $130 $131 $132 $133 $134) (AsStruct '('"l.l_discount" $125) '($32 $126) '('"l.l_orderkey" $127) '('"l.l_partkey" $128) '('"l.l_quantity" $129) '('"l.l_suppkey" $130) '('"p.p_partkey" $131) '('"ps.ps_partkey" $132) '('"ps.ps_suppkey" $133) '('"ps.ps_supplycost" $134))) $18))
  (return (FromFlow (FlatMap $114 (lambda '($135) (block '(
    (let $136 '@@["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 $137 '('"s_suppkey"))
    (let $138 (YqlRowSpec $2 $3 $4 '('Type $136) $6 '('SortMembers $137) '('SortedBy $137) $9))
    (let $139 (YtStat '('Id '"supplier") $11 '('DataSize '"206") $12 $13 $14))
    (let $140 (YtTable '"supplier" $138 $10 $139 '() (Void) (Void) '"/Root/plato"))
    (let $141 (YtReadTable! world $1 '((YtSection '((YtPath $140 '('"s_nationkey" '"s_suppkey") (Void) (Void))) '()))))
    (let $142 '('"l.l_suppkey"))
    (let $143 '('0 '10 '1 '11))
    (let $144 '('"l.l_discount" '0 $32 '1 '"l.l_orderkey" '2 '"l.l_partkey" '3 '"l.l_quantity" '4 '"l.l_suppkey" '5 '"p.p_partkey" '6 '"ps.ps_partkey" '7 '"ps.ps_suppkey" '8 '"ps.ps_supplycost" '9))
    (return (MapJoinCore (DqReadWideWrap $141 '()) $135 'Inner $42 $142 $143 $144 '('"s.s_suppkey") $142))
  ))))))
))) $46))
(let $48 (DqCnBroadcast (TDqOutput $47 '0)))
(let $49 (StructType $31 $33 $34 $35 $36 $37 '('"o.o_orderdate" (OptionalType (DataType 'Date))) '('"o.o_orderkey" $8) $21 $22 $23 $25 $43 $44))
(let $50 '('('"_logical_id" '7390) '('"_id" '"c879b051-bbc6df0c-bdb26395-97531c79") '('"_wide_channels" $49)))
(let $51 (DqPhyStage '($48) (lambda '($145) (block '(
  (let $146 (NarrowSqueezeToDict (ToFlow $145) (lambda '($147 $148 $149 $150 $151 $152 $153 $154 $155 $156 $157 $158) $149) (lambda '($159 $160 $161 $162 $163 $164 $165 $166 $167 $168 $169 $170) (AsStruct '('"l.l_discount" $159) '($32 $160) '('"l.l_orderkey" $161) '('"l.l_partkey" $162) '('"l.l_quantity" $163) '('"l.l_suppkey" $164) '('"p.p_partkey" $165) '('"ps.ps_partkey" $166) '('"ps.ps_suppkey" $167) '('"ps.ps_supplycost" $168) '('"s.s_nationkey" $169) '('"s.s_suppkey" $170))) $18))
  (return (FromFlow (FlatMap $146 (lambda '($171) (block '(
    (let $172 '@@["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 $173 '('"o_orderkey"))
    (let $174 (YqlRowSpec $30 $3 $4 '('Type $172) $6 '('SortMembers $173) '('SortedBy $173) $9))
    (let $175 (YtStat '('Id '"orders") $11 '('DataSize '"224") $12 $13 $14))
    (let $176 (YtTable '"orders" $174 $10 $175 '() (Void) (Void) '"/Root/plato"))
    (let $177 (YtReadTable! world $1 '((YtSection '((YtPath $176 '('"o_orderdate" '"o_orderkey") (Void) (Void))) '()))))
    (let $178 '('"l.l_orderkey"))
    (let $179 '('0 '6 '1 '7))
    (let $180 '('"l.l_discount" '0 $32 '1 '"l.l_orderkey" '2 '"l.l_partkey" '3 '"l.l_quantity" '4 '"l.l_suppkey" '5 '"p.p_partkey" '8 '"ps.ps_partkey" '9 '"ps.ps_suppkey" '10 '"ps.ps_supplycost" '11 '"s.s_nationkey" '12 '"s.s_suppkey" '13))
    (return (MapJoinCore (DqReadWideWrap $177 '()) $171 'Inner $42 $178 $179 $180 '('"o.o_orderkey") $178))
  ))))))
))) $50))
(let $52 (DqCnBroadcast (TDqOutput $51 '0)))
(let $53 (DataType 'Uint16))
(let $54 (OptionalType $53))
(let $55 (lambda '($258 $259 $260) $260 $258 $259))
(let $56 '('"nation" (DataType 'String)))
(let $57 '('"o_year" $54))
(let $58 (StructType '('_yql_agg_0 $24) $56 $57))
(let $59 '('('"_logical_id" '7591) '('"_id" '"e5e00338-f7dbb534-5be44b81-a23e3a5f") '('"_wide_channels" $58)))
(let $60 (DqPhyStage '($52) (lambda '($181) (block '(
  (let $182 (NarrowSqueezeToDict (ToFlow $181) (lambda '($185 $186 $187 $188 $189 $190 $191 $192 $193 $194 $195 $196 $197 $198) $197) (lambda '($199 $200 $201 $202 $203 $204 $205 $206 $207 $208 $209 $210 $211 $212) (AsStruct '('"l.l_discount" $199) '($32 $200) '('"l.l_orderkey" $201) '('"l.l_partkey" $202) '('"l.l_quantity" $203) '('"l.l_suppkey" $204) '('"o.o_orderdate" $205) '('"o.o_orderkey" $206) '('"p.p_partkey" $207) '('"ps.ps_partkey" $208) '('"ps.ps_suppkey" $209) '('"ps.ps_supplycost" $210) '('"s.s_nationkey" $211) '('"s.s_suppkey" $212))) $18))
  (let $183 (lambda '($222 $223 $224 $225 $226 $227) (block '(
    (let $228 (IfPresent $226 (lambda '($229) (block '(
      (let $230 (DataType 'Timestamp))
      (let $231 (TupleType (TupleType (OptionalType $230)) (StructType) (TupleType)))
      (let $232 (ResourceType '"DateTime2.TM"))
      (let $233 '($232 '"" '1))
      (let $234 (CallableType '() '($53) $233))
      (let $235 '('"strict"))
      (let $236 (Udf '"DateTime2.GetYear" (Void) $231 '"" $234 (VoidType) '"" '($235)))
      (let $237 (TupleType (TupleType $230) (StructType) (TupleType)))
      (let $238 '($230 '"" '1))
      (let $239 (CallableType '() '($232) $238))
      (let $240 (Udf '"DateTime2.Split" (Void) $237 '"" $239 (VoidType) '"" '('('"blocks") $235)))
      (return (Just (Apply $236 (Apply $240 (SafeCast $229 $230)))))
    ))) (Nothing $54)))
    (return $225 $228)
  ))))
  (let $184 (Int32 '1))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (FlatMap $182 (lambda '($213) (block '(
    (let $214 '@@["StructType";[["n_nationkey";["DataType";"Int32"]];["n_regionkey";["DataType";"Int32"]];["n_name";["DataType";"String"]];["n_comment";["DataType";"String"]]]]@@)
    (let $215 '('"n_nationkey"))
    (let $216 (YqlRowSpec $2 $3 $4 '('Type $214) $6 '('SortMembers $215) '('SortedBy $215) $9))
    (let $217 (YtStat '('Id '"nation") $11 '('DataSize '"121") $12 $13 $14))
    (let $218 (YtTable '"nation" $216 $10 $217 '() (Void) (Void) '"/Root/plato"))
    (let $219 (YtReadTable! world $1 '((YtSection '((YtPath $218 '('"n_name" '"n_nationkey") (Void) (Void))) '()))))
    (let $220 '('"s.s_nationkey"))
    (let $221 '('"l.l_discount" '0 $32 '1 '"l.l_quantity" '2 '"o.o_orderdate" '4 '"ps.ps_supplycost" '5))
    (return (MapJoinCore (DqReadWideWrap $219 '()) $213 'Inner $42 $220 '('0 '3) $221 '('"n.n_nationkey") $220))
  )))))) '-1073741824 $183 (lambda '($241 $242 $243 $244 $245 $246 $247 $248) (- (* $244 (- $184 $243)) (* $248 $245))) (lambda '($249 $250 $251 $252 $253 $254 $255 $256 $257) (AggrAdd (- (* $252 (- $184 $251)) (* $256 $253)) $257)) $55))
))) $59))
(let $61 (DqCnHashShuffle (TDqOutput $60 '0) '('1 '2) '0 '"HashV2"))
(let $62 (StructType $56 $57 '('"sum_profit" $24)))
(let $63 '('('"_logical_id" '8764) '('"_id" '"a83ffec0-c490af77-920e6272-cf554881") '('"_wide_channels" $62)))
(let $64 (DqPhyStage '($61) (lambda '($261) (block '(
  (let $262 (lambda '($265 $266 $267) $266 $267))
  (let $263 (WideCombiner (ToFlow (WideFromBlocks $261)) '"" $262 (lambda '($268 $269 $270 $271 $272) $270) (lambda '($273 $274 $275 $276 $277 $278) (AggrAdd $275 $278)) $55))
  (let $264 (lambda '($279 $280 $281) $280 $281 $279))
  (return (FromFlow (WideMap (WideSort $263 '('('1 $5) '('2 (Bool 'false)))) $264)))
))) $63))
(let $65 (DqCnMerge (TDqOutput $64 '0) '('('0 '"Asc") '('1 '"Desc"))))
(let $66 (DqPhyStage '($65) (lambda '($282) (FromFlow (NarrowMap (ToFlow $282) (lambda '($283 $284 $285) (AsStruct '('"nation" $283) '('"o_year" $284) '('"sum_profit" $285)))))) '('('"_logical_id" '8776) '('"_id" '"54d16e23-418c7dc0-48577b81-933b53ac"))))
(let $67 '($16 $28 $40 $47 $51 $60 $64 $66))
(let $68 '('"nation" '"o_year" '"sum_profit"))
(let $69 (DqCnResult (TDqOutput $66 '0) $68))
(return (KqpPhysicalQuery '((KqpPhysicalTx $67 '($69) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $62) '0 '0)) '('('"type" '"query"))))
)
