(
(let $1 (lambda '($23) $23))
(let $2 '('"key" (DataType 'String)))
(let $3 '('"_wide_channels" (StructType $2)))
(let $4 '('('"_logical_id" '2996) '('"_id" '"71b7e63c-52ba7ca-2ddddb4c-141c3bde") $3))
(let $5 (DqPhyStage '() (lambda '() (block '(
  (let $17 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $18 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $17)))
  (let $19 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $20 (YtStat '('Id '"Input") '('RecordsCount '"14") '('DataSize '"614") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $21 (YtTable '"Input" $18 $19 $20 '() (Void) (Void) '"/Root/plato"))
  (let $22 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $21 '('"key") (Void) (Void))) '()))))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (DqReadWideWrap $22 '()))) '-1073741824 $1 (lambda '($24 $25) $24) (lambda '($26 $27 $28) $28) (lambda '($29 $30) $30)))
))) $4))
(let $6 (DqCnHashShuffle (TDqOutput $5 '0) '('0) '0 '"HashV2"))
(let $7 '('('"_logical_id" '3071) '('"_id" '"49c9eaee-bc7d053c-7f53e68a-e78cff5f") '('"_partition_mode" '"aggregate") $3))
(let $8 (DqPhyStage '($6) (lambda '($31) (block '(
  (let $32 (NarrowSqueezeToDict (ToFlow (WideFromBlocks $31)) $1 (lambda '($34) (AsStruct '('"key" $34))) '('Auto 'Many)))
  (let $33 (Condense1 (OrderedFlatMap $32 (lambda '($35) (OrderedFlatMap (DictPayloads $35) (lambda '($36) $36)))) (lambda '($37) (Member $37 '"key")) (lambda '($38 $39) (AggrNotEquals (Member $38 '"key") $39)) (lambda '($40 $41) $41)))
  (return (FromFlow (ExpandMap $33 $1)))
))) $7))
(let $9 (DqCnUnionAll (TDqOutput $8 '0)))
(let $10 (StructType '('"column1" (DataType 'Uint64)) $2))
(let $11 '('('"_logical_id" '3520) '('"_id" '"dcff0997-9d76dc08-d2c1087d-21fdc669") '('"_wide_channels" $10)))
(let $12 (DqPhyStage '($9) (lambda '($42) (block '(
  (let $43 (Bool 'true))
  (let $44 (Chain1Map (NarrowMap (WideSort (ToFlow $42) '('('0 $43))) (lambda '($47) (AsStruct '('"key" $47)))) (lambda '($48) (block '(
    (let $49 (Uint64 '1))
    (let $50 (Member $48 '"key"))
    (let $51 '($49 $49 $50))
    (return '((AsStruct '('_yql_Rank0 $49) '('"key" $50)) (AsStruct '('_yql_Rank0 $51))))
  ))) (lambda '($52 $53) (block '(
    (let $54 (Member $52 '"key"))
    (let $55 (Member (Nth $53 '1) '_yql_Rank0))
    (let $56 (Inc (Nth $55 '1)))
    (let $57 (If (AggrEquals $54 (Nth $55 '"2")) (Nth $55 '0) $56))
    (let $58 '($57 $56 $54))
    (return '((AsStruct '('_yql_Rank0 $57) '('"key" $54)) (AsStruct '('_yql_Rank0 $58))))
  )))))
  (let $45 (Sort (Map $44 (lambda '($59) (block '(
    (let $60 (Nth $59 '0))
    (return (AsStruct '('"column1" (Member $60 '_yql_Rank0)) '('"key" (Member $60 '"key"))))
  )))) $43 (lambda '($61) (Member $61 '"key"))))
  (let $46 (lambda '($62) (Member $62 '"column1") (Member $62 '"key")))
  (return (FromFlow (ExpandMap $45 $46)))
))) $11))
(let $13 (DqCnMerge (TDqOutput $12 '0) '('('1 '"Asc"))))
(let $14 (DqPhyStage '($13) (lambda '($63) (FromFlow (NarrowMap (ToFlow $63) (lambda '($64 $65) (AsStruct '('"column1" $64) '('"key" $65)))))) '('('"_logical_id" '3532) '('"_id" '"f0008fed-6b6b2856-8c1deb55-f68f3112"))))
(let $15 '($5 $8 $12 $14))
(let $16 (DqCnResult (TDqOutput $14 '0) '('"key" '"column1")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $15 '($16) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $10) '0 '0)) '('('"type" '"query"))))
)
