(
(let $1 (Bool 'true))
(let $2 (DataType 'String))
(let $3 '('"key" $2))
(let $4 '('('"_logical_id" '2699) '('"_id" '"c0bdffe9-4c68c0c0-f01ce3a8-ffe713a8") '('"_wide_channels" (StructType $3 '('"value" $2)))))
(let $5 (DqPhyStage '() (lambda '() (block '(
  (let $15 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $16 '('"key" '"subkey"))
  (let $17 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $15) '('SortDirections '($1 $1)) '('SortMembers $16) '('SortedBy $16) '('SortedByTypes '($2 $2))))
  (let $18 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" '"false")))))
  (let $19 (YtStat '('Id '"Input") '('RecordsCount '"6") '('DataSize '"252") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $20 (YtTable '"Input" $17 $18 $19 '() (Void) (Void) '"/Root/plato"))
  (let $21 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $20 '('"key" '"value") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $21 '())))
))) $4))
(let $6 (DqCnHashShuffle (TDqOutput $5 '0) '('0) '0 '"HashV2"))
(let $7 (StructType '('"cnt" (DataType 'Uint64)) $3 '('"lst" (ListType $2)) '('max $2) '('min $2)))
(let $8 '('('"_logical_id" '2920) '('"_id" '"cd16ad8e-6457905d-73375f54-35c55f94") '('"_wide_channels" $7)))
(let $9 (DqPhyStage '($6) (lambda '($22) (block '(
  (let $23 (NarrowSqueezeToDict (ToFlow $22) (lambda '($31 $32) $31) (lambda '($33 $34) (AsStruct '('"key" $33) '('"value" $34))) '('Auto 'Many)))
  (let $24 (ResourceType '"Set.SetResource.String"))
  (let $25 '($24))
  (let $26 '($2))
  (let $27 '('('"strict")))
  (let $28 (Condense1 (OrderedFlatMap $23 (lambda '($35) (OrderedFlatMap (DictPayloads $35) (lambda '($36) $36)))) (lambda '($37) (block '(
    (let $38 (DataType 'Uint32))
    (let $39 (TupleType (TupleType $2 $38) (StructType) $2))
    (let $40 (CallableType '() $25 $26 '($38)))
    (let $41 (Udf '"Set.Create" (Void) $39 '"" $40 (VoidType) '"" $27))
    (let $42 (Member $37 '"value"))
    (let $43 (NamedApply $41 '($42 (Uint32 '0)) (AsStruct) (DependsOn (String '"value"))))
    (return (AsStruct '('_yql_agg_0 '($43 (AsList $42))) '('_yql_agg_1 (Uint64 '1)) '('_yql_agg_2 $42) '('_yql_agg_3 $42) '('"key" (Member $37 '"key"))))
  ))) (lambda '($44 $45) (AggrNotEquals (Member $44 '"key") (Member $45 '"key"))) (lambda '($46 $47) (block '(
    (let $48 (TupleType (TupleType $24) (StructType) $2))
    (let $49 (CallableType '() '((DataType 'Bool)) $25))
    (let $50 (Udf '"Set.WasChanged" (Void) $48 '"" $49 (VoidType) '"" $27))
    (let $51 (TupleType (TupleType $24 $2) (StructType) $2))
    (let $52 (CallableType '() $25 $25 $26))
    (let $53 (Udf '"Set.AddValue" (Void) $51 '"" $52 (VoidType) '"" $27))
    (let $54 (Member $47 '_yql_agg_0))
    (let $55 (Member $46 '"value"))
    (let $56 (NamedApply $53 '((Nth $54 '0) $55) (AsStruct)))
    (let $57 (NamedApply $50 '($56) (AsStruct)))
    (let $58 (If $57 '($56 (Insert (Nth $54 '1) $55)) $54))
    (let $59 (Member $47 '_yql_agg_1))
    (let $60 (If $57 (Inc $59) $59))
    (return (AsStruct '('_yql_agg_0 $58) '('_yql_agg_1 $60) '('_yql_agg_2 (AggrMax $55 (Member $47 '_yql_agg_2))) '('_yql_agg_3 (AggrMin $55 (Member $47 '_yql_agg_3))) '('"key" (Member $47 '"key"))))
  )))))
  (let $29 (Sort (Map $28 (lambda '($61) (block '(
    (let $62 (Sort (Nth (Member $61 '_yql_agg_0) '1) $1 (lambda '($63) $63)))
    (return (AsStruct '('"cnt" (Member $61 '_yql_agg_1)) '('"key" (Member $61 '"key")) '('"lst" $62) '('max (Member $61 '_yql_agg_2)) '('min (Member $61 '_yql_agg_3))))
  )))) $1 (lambda '($64) (Member $64 '"key"))))
  (let $30 (lambda '($65) (Member $65 '"cnt") (Member $65 '"key") (Member $65 '"lst") (Member $65 'max) (Member $65 'min)))
  (return (FromFlow (ExpandMap $29 $30)))
))) $8))
(let $10 (DqCnMerge (TDqOutput $9 '0) '('('1 '"Asc"))))
(let $11 (DqPhyStage '($10) (lambda '($66) (FromFlow (NarrowMap (ToFlow $66) (lambda '($67 $68 $69 $70 $71) (AsStruct '('"cnt" $67) '('"key" $68) '('"lst" $69) '('max $70) '('min $71)))))) '('('"_logical_id" '2932) '('"_id" '"942723d1-1deaa7f7-5bc5e440-d116aa0"))))
(let $12 '($5 $9 $11))
(let $13 '('"key" '"cnt" '"lst" 'min 'max))
(let $14 (DqCnResult (TDqOutput $11 '0) $13))
(return (KqpPhysicalQuery '((KqpPhysicalTx $12 '($14) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $7) '0 '0)) '('('"type" '"query"))))
)
