(
(declare %kqp%tx_result_binding_0_0 (OptionalType (StructType '('Max0 (DataType 'String)))))
(let $1 (DataSource '"yt" '"/Root/plato"))
(let $2 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
(let $3 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $2)))
(let $4 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
(let $5 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
(let $6 (YtTable '"Input" $3 $4 $5 '() (Void) (Void) '"/Root/plato"))
(let $7 (lambda '($40) (AsStruct '('"key" $40))))
(let $8 (lambda '($41) (Member $41 '"key")))
(let $9 (Bool 'false))
(let $10 (DataType 'String))
(let $11 '('('"_logical_id" '3973) '('"_id" '"37088c64-90a8af6d-f56e851d-63cc665a") '('"_wide_channels" (StructType '('_yql_agg_0 $10)))))
(let $12 (DqPhyStage '() (lambda '() (block '(
  (let $38 (YtReadTable! world $1 '((YtSection '((YtPath $6 '('"key") (Void) (Void))) '()))))
  (let $39 (Condense1 (NarrowMap (DqReadWideWrap $38 '()) $7) $8 (lambda '($42 $43) $9) (lambda '($44 $45) (AggrMax (Member $44 '"key") $45))))
  (return (FromFlow (ExpandMap $39 (lambda '($46) $46))))
))) $11))
(let $13 (DqCnUnionAll (TDqOutput $12 '0)))
(let $14 (OptionalType (StructType '('Max0 $10))))
(let $15 (DqPhyStage '($13) (lambda '($47) (block '(
  (let $48 (Condense1 (NarrowMap (ToFlow $47) (lambda '($49) (AsStruct '('_yql_agg_0 $49)))) (lambda '($50) (Member $50 '_yql_agg_0)) (lambda '($51 $52) $9) (lambda '($53 $54) (AggrMax (Member $53 '_yql_agg_0) $54))))
  (return (FromFlow (Condense (Map (Take $48 (Uint64 '1)) (lambda '($55) (AsStruct '('Max0 $55)))) (Nothing $14) (lambda '($56 $57) $9) (lambda '($58 $59) (Just $58)))))
))) '('('"_logical_id" '4407) '('"_id" '"f0b38084-329b1b59-ce0e56c5-be155de2"))))
(let $16 (DqCnValue (TDqOutput $15 '0)))
(let $17 (KqpPhysicalTx '($12 $15) '($16) '() '('('"type" '"compute"))))
(let $18 '('"key" $10))
(let $19 (StructType $18 '('"value" $10)))
(let $20 '('('"_logical_id" '3784) '('"_id" '"5e3c0fd0-366a3fb4-b4952c9b-fe67b9dd") '('"_wide_channels" $19)))
(let $21 (DqPhyStage '() (lambda '() (block '(
  (let $60 (YtReadTable! world $1 '((YtSection '((YtPath $6 '('"key" '"value") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $60 '())))
))) $20))
(let $22 '('"_wide_channels" (StructType $18)))
(let $23 '('('"_logical_id" '3926) '('"_id" '"5a6a291a-d73b333c-ace57a83-ab31f209") $22))
(let $24 (DqPhyStage '() (lambda '() (block '(
  (let $61 (YtReadTable! world $1 '((YtSection '((YtPath $6 '('"key" '"subkey") (Void) (Void))) '()))))
  (return (FromFlow (WideMap (WideFilter (DqReadWideWrap $61 '()) (lambda '($62 $63) (> $63 (String '1)))) (lambda '($64 $65) $64))))
))) $23))
(let $25 (DqCnUnionAll (TDqOutput $24 '0)))
(let $26 '('('"_logical_id" '4541) '('"_id" '"4a4d51a4-d4980cdf-e4bba197-8ce1dc2") $22))
(let $27 (DqPhyStage '($25) (lambda '($66) $66) $26))
(let $28 (DqCnMap (TDqOutput $21 '0)))
(let $29 (DqCnBroadcast (TDqOutput $27 '0)))
(let $30 '"%kqp%tx_result_binding_0_0")
(let $31 (DqPhyStage '($28 $29) (lambda '($67 $68) (FromFlow (NarrowMap (FlatMap (SqueezeToList (NarrowMap (ToFlow $68) $7) (Uint64 '0)) (lambda '($69) (block '(
  (let $70 (lambda '($71 $72) (block '(
    (let $73 (If (Coalesce (== $71 (Member %kqp%tx_result_binding_0_0 'Max0)) $9) (String 'max) $71))
    (return $72 $73)
  ))))
  (return (WideFilter (WideMap (ToFlow $67) $70) (lambda '($74 $75) (block '(
    (let $76 '('Auto 'One 'Compact))
    (let $77 (ToDict $69 $8 (lambda '($78) (Void)) $76))
    (return (Contains $77 $75))
  )))))
)))) (lambda '($79 $80) (AsStruct '('"key" $80) '('"value" $79)))))) '('('"_logical_id" '4570) '('"_id" '"74c66ce6-d44ce67f-6727bb1d-1f7eb27f"))))
(let $32 (DqCnUnionAll (TDqOutput $31 '0)))
(let $33 (DqPhyStage '($32) (lambda '($81) $81) '('('"_logical_id" '5912) '('"_id" '"67a4c41f-3168933e-1dd58a98-c28812c3"))))
(let $34 '($21 $24 $27 $31 $33))
(let $35 (DqCnResult (TDqOutput $33 '0) '()))
(let $36 (KqpTxResultBinding $14 '0 '0))
(let $37 (KqpPhysicalTx $34 '($35) '('($30 $36)) '('('"type" '"generic"))))
(return (KqpPhysicalQuery '($17 $37) '((KqpTxResultBinding (ListType $19) '1 '0)) '('('"type" '"query"))))
)
