(
(declare %kqp%tx_result_binding_0_0 (OptionalType (StructType '('Count0 (DataType 'Uint64)))))
(let $1 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
(let $2 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $1)))
(let $3 '('('"native_strict_schema" 'false) '('"_yql_read_udf" '"Dsv.ReadRecord") '('"_yql_read_udf_run_config" '"@@")))
(let $4 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs $3)))
(let $5 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"193") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
(let $6 (YtTable '"Input" $2 $4 $5 '() (Void) (Void) '"/Root/plato"))
(let $7 '('"key" '"subkey" '"value"))
(let $8 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $6 $7 (Void) (Void))) '()))))
(let $9 (DqReadWideWrap $8 '()))
(let $10 (Uint64 '1))
(let $11 (Bool 'false))
(let $12 (lambda '($59) $59))
(let $13 '('"_logical_id" '3558))
(let $14 (DataType 'Uint64))
(let $15 '('_yql_agg_0 $14))
(let $16 '($13 '('"_id" '"7711aa43-f2256fab-e546c198-f031ec77") '('"_wide_channels" (StructType $15))))
(let $17 (DqPhyStage '() (lambda '() (block '(
  (let $50 (Condense1 (NarrowMap $9 (lambda '($51 $52 $53) (AsStruct))) (lambda '($54) $10) (lambda '($55 $56) $11) (lambda '($57 $58) (AggrAdd $58 $10))))
  (return (FromFlow (ExpandMap $50 $12)))
))) $16))
(let $18 (DqCnUnionAll (TDqOutput $17 '0)))
(let $19 (OptionalType (StructType '('Count0 $14))))
(let $20 (DqPhyStage '($18) (lambda '($60) (block '(
  (let $61 (WideCondense1 (ToFlow $60) $12 (lambda '($62 $63) $11) (lambda '($64 $65) (AggrAdd $64 $65))))
  (return (FromFlow (Condense (NarrowMap (Take $61 $10) (lambda '($66) (AsStruct '('Count0 $66)))) (Nothing $19) (lambda '($67 $68) $11) (lambda '($69 $70) (Just $69)))))
))) '('('"_logical_id" '3704) '('"_id" '"8e284ba9-e9e8dca-f73b512-37518796"))))
(let $21 (DqCnValue (TDqOutput $20 '0)))
(let $22 (KqpPhysicalTx '($17 $20) '($21) '() '('('"type" '"compute"))))
(let $23 (DataType 'String))
(let $24 (OptionalType $23))
(let $25 (lambda '($88 $89) $89 $88))
(let $26 '('val $24))
(let $27 '($13 '('"_id" '"8fbac5c4-7fc974eb-1daf0788-e5f0e92f") '('"_wide_channels" (StructType $15 $26))))
(let $28 (DqPhyStage '() (lambda '() (DqPhyHashCombine (WideToBlocks (FromFlow $9)) '-1073741824 (lambda '($71 $72 $73) (block '(
  (let $74 '('"key" $23))
  (let $75 '('"subkey" $23))
  (let $76 (CallableType '() '((StructType '('"dict" (DictType $23 $23)) $74 $75)) '((StructType $74 $75 '('"value" $23)))))
  (let $77 (Udf '"Dsv.ReadRecord" (Just (String '"@@")) (VoidType) '"" $76 $24 '"" '('('"strict"))))
  (let $78 (AsStruct '('"key" $71) '('"subkey" $72) '('"value" $73)))
  (return (Lookup (Member (Apply $77 $78) '"dict") (String '"c")))
))) (lambda '($79 $80 $81 $82) $10) (lambda '($83 $84 $85 $86 $87) (AggrAdd $87 $10)) $25)) $27))
(let $29 (DqCnHashShuffle (TDqOutput $28 '0) '('1) '0 '"HashV2"))
(let $30 (Uint64 '0))
(let $31 (StructType '('"cnt" $14) '('"grouping" $14) $26))
(let $32 '('"_wide_channels" $31))
(let $33 '('('"_logical_id" '3428) '('"_id" '"b0d344e4-745d1729-81cbc4fd-ee3c80e2") '('"_partition_mode" '"aggregate") $32))
(let $34 (DqPhyStage '($29) (lambda '($90) (block '(
  (let $91 (WideCombiner (ToFlow (WideFromBlocks $90)) '"" (lambda '($93 $94) $94) (lambda '($95 $96 $97) $96) (lambda '($98 $99 $100 $101) (AggrAdd $99 $101)) $25))
  (let $92 (lambda '($102 $103) $102 $30 $103))
  (return (FromFlow (WideMap $91 $92)))
))) $33))
(let $35 '"%kqp%tx_result_binding_0_0")
(let $36 '('('"_logical_id" '3828) '('"_id" '"42ff4c36-87fc2063-12b7c29a-72a18728") $32))
(let $37 (DqPhyStage '() (lambda '() (block '(
  (let $104 (lambda '($105) (Member $105 '"cnt") (Member $105 '"grouping") (Member $105 'val)))
  (return (FromFlow (ExpandMap (ToFlow (AsList (AsStruct '('"cnt" (Coalesce (Member %kqp%tx_result_binding_0_0 'Count0) $30)) '('"grouping" $10) '('val (Nothing $24))))) $104)))
))) $36))
(let $38 (DqCnParallelUnionAll (TDqOutput $34 '0)))
(let $39 (DqCnParallelUnionAll (TDqOutput $37 '0)))
(let $40 (lambda '($111 $112 $113) (AsStruct '('"cnt" $111) '('"grouping" $112) '('val $113))))
(let $41 '('('"_logical_id" '3918) '('"_id" '"9f962563-da3daa70-e8a05f56-4500440c") $32))
(let $42 (DqPhyStage '($38 $39) (lambda '($106 $107) (block '(
  (let $108 (Bool 'true))
  (let $109 (Sort (Extend (NarrowMap (ToFlow $106) $40) (NarrowMap (ToFlow $107) $40)) '($108 $108) (lambda '($114) '((Member $114 'val) (Member $114 '"cnt")))))
  (let $110 (lambda '($115) (Member $115 '"cnt") (Member $115 '"grouping") (Member $115 'val)))
  (return (FromFlow (ExpandMap $109 $110)))
))) $41))
(let $43 (DqCnMerge (TDqOutput $42 '0) '('('"2" '"Asc") '('0 '"Asc"))))
(let $44 (DqPhyStage '($43) (lambda '($116) (FromFlow (NarrowMap (ToFlow $116) $40))) '('('"_logical_id" '3930) '('"_id" '"d3dc2bc3-1c61c8e4-ac676add-e5ab07f5"))))
(let $45 '($28 $34 $37 $42 $44))
(let $46 '('val '"cnt" '"grouping"))
(let $47 (DqCnResult (TDqOutput $44 '0) $46))
(let $48 (KqpTxResultBinding $19 '0 '0))
(let $49 (KqpPhysicalTx $45 '($47) '('($35 $48)) '('('"type" '"generic"))))
(return (KqpPhysicalQuery '($22 $49) '((KqpTxResultBinding (ListType $31) '1 '0)) '('('"type" '"query"))))
)
