(
(let $1 (DataType 'String))
(let $2 '('"key" $1))
(let $3 '('"subkey" $1))
(let $4 '('"value" $1))
(let $5 (StructType $2 $3 $4))
(let $6 '('('"_logical_id" '5222) '('"_id" '"48111511-42e35a88-dc67a0de-b7c8a6d3") '('"_wide_channels" $5)))
(let $7 (DqPhyStage '() (lambda '() (block '(
  (let $22 '@@["StructType";[["value";["DataType";"String"]];["subkey";["DataType";"String"]];["key";["DataType";"String"]]]]@@)
  (let $23 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $22)))
  (let $24 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('HasRLS '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $25 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $26 (YtTable '"Input" $23 $24 $25 '() (Void) (Void) '"/Root/plato"))
  (let $27 '('"key" '"subkey" '"value"))
  (let $28 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $26 $27 (Void) (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $28 '())))
))) $6))
(let $8 (DqCnHashShuffle (TDqOutput $7 '0) '('0) '0 '"HashV2"))
(let $9 '('"zz" $1))
(let $10 (StructType $2 $3 $4 $9))
(let $11 '('('"_logical_id" '5285) '('"_id" '"23a4b7d0-fd9c21f3-eca2c5e8-982f7b63") '('"_partition_mode" '"aggregate") '('"_wide_channels" $10)))
(let $12 (DqPhyStage '($8) (lambda '($29) (block '(
  (let $30 (NarrowSqueezeToDict (ToFlow $29) (lambda '($33 $34 $35) $33) (lambda '($36 $37 $38) (AsStruct '('"key" $36) '('"subkey" $37) '('"value" $38))) '('Auto 'Many)))
  (let $31 (Chopper (OrderedFlatMap $30 (lambda '($39) (OrderedFlatMap (DictPayloads $39) (lambda '($40) $40)))) (lambda '($41) (Member $41 '"key")) (lambda '($42 $43) (AggrNotEquals $42 (Member $43 '"key"))) (lambda '($44 $45) (block '(
    (let $46 (Chain1Map $45 (lambda '($50) (block '(
      (let $51 (Member $50 '"subkey"))
      (let $52 '('"zz" $51))
      (let $53 (AsStruct '('"key" (Member $50 '"key")) '('"subkey" $51) '('"value" (Member $50 '"value")) $52))
      (return '($53 (AsStruct $52)))
    ))) (lambda '($54 $55) (block '(
      (let $56 (Member $54 '"subkey"))
      (let $57 '('"zz" (AggrMin $56 (Member (Nth $55 '1) '"zz"))))
      (let $58 (AsStruct '('"key" (Member $54 '"key")) '('"subkey" $56) '('"value" (Member $54 '"value")) $57))
      (return '($58 (AsStruct $57)))
    )))))
    (let $47 (ListType $10))
    (let $48 (VariantType (StructType '('group $47) '('singleRow $10))))
    (let $49 (Condense1 $46 (lambda '($59) (block '(
      (let $60 (Variant (Nth $59 '0) 'singleRow $48))
      (return '((Void) $60))
    ))) (lambda '($61 $62) (Bool 'false)) (lambda '($63 $64) (block '(
      (let $65 (Nth $63 '0))
      (let $66 (Visit (Nth $64 '1) 'group (lambda '($67) (Variant (Insert $67 $65) 'group $48)) 'singleRow (lambda '($68) (Variant (AsList $68 $65) 'group $48))))
      (return '((Nth $64 '0) $66))
    )))))
    (return (OrderedFlatMap $49 (lambda '($69) (Visit (Nth $69 '1) 'group (lambda '($70) (IfPresent (Last $70) (lambda '($71) (OrderedMap (Collect (Map $70 (lambda '($72) (AsStruct '('"key" (Member $72 '"key")) '('"subkey" (Member $72 '"subkey")) '('"value" (Member $72 '"value")))))) (lambda '($73) (AsStruct '('"key" (Member $73 '"key")) '('"subkey" (Member $73 '"subkey")) '('"value" (Member $73 '"value")) '('"zz" (Member $71 '"zz")))))) (List $47))) 'singleRow (lambda '($74) (AsList $74))))))
  )))))
  (let $32 (lambda '($75) (Member $75 '"key") (Member $75 '"subkey") (Member $75 '"value") (Member $75 '"zz")))
  (return (FromFlow (ExpandMap $31 $32)))
))) $11))
(let $13 (DqCnUnionAll (TDqOutput $12 '0)))
(let $14 (StructType $2 $3 $4 '('"z" (DataType 'Uint64)) $9))
(let $15 '('('"_logical_id" '5875) '('"_id" '"c9e37ce5-91b63aa5-1f0f2ce-d349feb0") '('"_wide_channels" $14)))
(let $16 (DqPhyStage '($13) (lambda '($76) (block '(
  (let $77 (Bool 'true))
  (let $78 (Chain1Map (NarrowMap (WideSort (ToFlow $76) '('('0 $77) '('1 $77))) (lambda '($81 $82 $83 $84) (AsStruct '('"key" $81) '('"subkey" $82) '('"value" $83) '('"zz" $84)))) (lambda '($85) (block '(
    (let $86 '('"z" (Uint64 '1)))
    (let $87 (AsStruct '('"key" (Member $85 '"key")) '('"subkey" (Member $85 '"subkey")) '('"value" (Member $85 '"value")) $86 '('"zz" (Member $85 '"zz"))))
    (return '($87 (AsStruct $86)))
  ))) (lambda '($88 $89) (block '(
    (let $90 '('"z" (Inc (Member (Nth $89 '1) '"z"))))
    (let $91 (AsStruct '('"key" (Member $88 '"key")) '('"subkey" (Member $88 '"subkey")) '('"value" (Member $88 '"value")) $90 '('"zz" (Member $88 '"zz"))))
    (return '($91 (AsStruct $90)))
  )))))
  (let $79 (AssumeSorted (OrderedMap $78 (lambda '($92) (Nth $92 '0))) '($77 $77) (lambda '($93) '((Member $93 '"key") (Member $93 '"subkey")))))
  (let $80 (lambda '($94) (Member $94 '"key") (Member $94 '"subkey") (Member $94 '"value") (Member $94 '"z") (Member $94 '"zz")))
  (return (FromFlow (ExpandMap $79 $80)))
))) $15))
(let $17 (DqCnMerge (TDqOutput $16 '0) '('('0 '"Asc") '('1 '"Asc"))))
(let $18 (DqPhyStage '($17) (lambda '($95) (FromFlow (NarrowMap (ToFlow $95) (lambda '($96 $97 $98 $99 $100) (AsStruct '('"key" $96) '('"subkey" $97) '('"value" $98) '('"z" $99) '('"zz" $100)))))) '('('"_logical_id" '5887) '('"_id" '"aa00f0d3-8a9d3cfa-cad2fc1f-21393f0e"))))
(let $19 '($7 $12 $16 $18))
(let $20 '('"zz" '"z" '"value" '"subkey" '"key"))
(let $21 (DqCnResult (TDqOutput $18 '0) $20))
(return (KqpPhysicalQuery '((KqpPhysicalTx $19 '($21) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $14) '0 '0)) '('('"type" '"query"))))
)
