(
(declare %kqp%tx_result_binding_0_0 (OptionalType (StructType '('Sum0 (DataType 'Double)) '('Sum1 (DataType 'Double)))))
(let $1 (DataSource '"yt" '"/Root/plato"))
(let $2 '('StrictSchema '1))
(let $3 '('UniqueKeys '0))
(let $4 (Bool 'true))
(let $5 '('"p_partkey"))
(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 '('('"_logical_id" '2751) '('"_id" '"db5fd0b4-54eec9b4-4152e8ce-ea669460") '('"_wide_channels" (StructType '('"p_partkey" $6) '('"p_type" (DataType 'String))))))
(let $13 (DqPhyStage '() (lambda '() (block '(
  (let $31 '@@["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 $32 (YqlRowSpec '('NativeYtTypeFlags '0) $2 $3 '('Type $31) '('SortDirections '($4)) '('SortMembers $5) '('SortedBy $5) '('SortedByTypes '($6))))
  (let $33 (YtStat '('Id '"part") $8 '('DataSize '"239") $9 $10 $11))
  (let $34 (YtTable '"part" $32 $7 $33 '() (Void) (Void) '"/Root/plato"))
  (let $35 (YtReadTable! world $1 '((YtSection '((YtPath $34 '('"p_partkey" '"p_type") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $35 '())))
))) $12))
(let $14 (DqCnBroadcast (TDqOutput $13 '0)))
(let $15 (Bool 'false))
(let $16 (DataType 'Double))
(let $17 '('('"_logical_id" '2953) '('"_id" '"e39c1cfa-d794d126-fe267a3a-949308b0") '('"_wide_channels" (StructType '('_yql_agg_0 $16) '('_yql_agg_1 $16)))))
(let $18 (DqPhyStage '($14) (lambda '($36) (block '(
  (let $37 '('Many 'Hashed 'Compact))
  (let $38 (NarrowSqueezeToDict (ToFlow $36) (lambda '($44 $45) $44) (lambda '($46 $47) (AsStruct '('"p_partkey" $46) '('"p_type" $47))) $37))
  (let $39 (String '"PROMO"))
  (let $40 (Int32 '1))
  (let $41 (Convert (Int32 '0) $16))
  (let $42 (lambda '($69 $70 $71) (block '(
    (let $72 (* $70 (- $40 $69)))
    (let $73 (If (StartsWith $71 $39) $72 $41))
    (return $73 $72)
  ))))
  (let $43 (lambda '($79 $80 $81 $82 $83) (block '(
    (let $84 (* $80 (- $40 $79)))
    (let $85 (If (StartsWith $81 $39) $84 $41))
    (return (AggrAdd $85 $82) (AggrAdd $84 $83))
  ))))
  (return (FromFlow (WideCondense1 (FlatMap $38 (lambda '($48) (block '(
    (let $49 '@@["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 $50 '('"l_orderkey" '"l_linenumber"))
    (let $51 (YqlRowSpec '('NativeYtTypeFlags '2) $2 $3 '('Type $49) '('SortDirections '($4 $4)) '('SortMembers $50) '('SortedBy $50) '('SortedByTypes '($6 $6))))
    (let $52 (YtStat '('Id '"lineitem") $8 '('DataSize '"343") $9 $10 $11))
    (let $53 (YtTable '"lineitem" $51 $7 $52 '() (Void) (Void) '"/Root/plato"))
    (let $54 '('"l_discount" '"l_extendedprice" '"l_partkey" '"l_shipdate"))
    (let $55 (YtReadTable! world $1 '((YtSection '((YtPath $53 $54 (Void) (Void))) '('('"unordered"))))))
    (let $56 (lambda '($65 $66 $67 $68) $65 $66 $67))
    (let $57 '('0 '0 '1 '1))
    (return (MapJoinCore (WideMap (WideFilter (DqReadWideWrap $55 '()) (lambda '($58 $59 $60 $61) (block '(
      (let $62 (DataType 'Timestamp))
      (let $63 (IfPresent $61 (lambda '($64) (Just (SafeCast $64 $62))) (Nothing (OptionalType $62))))
      (return (And (Coalesce (>= $63 (Date '"8978")) $15) (Coalesce (< $63 (Just (Date '"9009"))) $15)))
    )))) $56) $48 'Inner '('2) $5 $57 '('"p_type" '2) '('"l.l_partkey") '('"p.p_partkey")))
  )))) $42 (lambda '($74 $75 $76 $77 $78) $15) $43)))
))) $17))
(let $19 (DqCnUnionAll (TDqOutput $18 '0)))
(let $20 (OptionalType (StructType '('Sum0 $16) '('Sum1 $16))))
(let $21 (DqPhyStage '($19) (lambda '($86) (block '(
  (let $87 (lambda '($90 $91) $90 $91))
  (let $88 (lambda '($96 $97 $98 $99) (AggrAdd $96 $98) (AggrAdd $97 $99)))
  (let $89 (WideCondense1 (ToFlow $86) $87 (lambda '($92 $93 $94 $95) $15) $88))
  (return (FromFlow (Condense (NarrowMap (Take $89 (Uint64 '1)) (lambda '($100 $101) (AsStruct '('Sum0 $100) '('Sum1 $101)))) (Nothing $20) (lambda '($102 $103) $15) (lambda '($104 $105) (Just $104)))))
))) '('('"_logical_id" '4862) '('"_id" '"1a91f209-30898183-3eb26873-edcb39f6"))))
(let $22 '($13 $18 $21))
(let $23 (DqCnValue (TDqOutput $21 '0)))
(let $24 (KqpPhysicalTx $22 '($23) '() '('('"type" '"compute"))))
(let $25 '"%kqp%tx_result_binding_0_0")
(let $26 '('('"_logical_id" '4974) '('"_id" '"cf58aead-81252c21-909c0934-7c6e0c55") '('"_partition_mode" '"single")))
(let $27 (DqPhyStage '() (lambda '() (block '(
  (let $106 %kqp%tx_result_binding_0_0)
  (return (Iterator (AsList (AsStruct '('"promo_revenue" (/ (* (Double '"100.00") (Member $106 'Sum0)) (Member $106 'Sum1)))))))
))) $26))
(let $28 (DqCnResult (TDqOutput $27 '0) '('"promo_revenue")))
(let $29 (KqpTxResultBinding $20 '0 '0))
(let $30 (KqpPhysicalTx '($27) '($28) '('($25 $29)) '('('"type" '"generic"))))
(return (KqpPhysicalQuery '($24 $30) '((KqpTxResultBinding (ListType (StructType '('"promo_revenue" (OptionalType $16)))) '1 '0)) '('('"type" '"query"))))
)
