(
(let $1 (Bool 'false))
(let $2 (Bool 'true))
(let $3 (OptionalType (TupleType (DataType 'Int32) (OptionalType (OptionalType (DataType 'Double))))))
(let $4 '('"key" (DataType 'Uint32)))
(let $5 (StructType '('_yql_agg_0 $3) '('_yql_agg_1 $3) $4))
(let $6 '('('"_logical_id" '1634) '('"_id" '"2c815e2d-94bd32-aff84acc-40700f81") '('"_wide_channels" $5)))
(let $7 (DqPhyStage '() (lambda '() (block '(
  (let $17 '@@["StructType";[["key";["DataType";"Uint32"]];["subkey";["DataType";"Uint32"]];["value";["OptionalType";["TupleType";[["DataType";"Int32"];["OptionalType";["OptionalType";["DataType";"Double"]]]]]]]]]@@)
  (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 '"600") '('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" '"value") (Void) (Void))) '()))))
  (let $23 (lambda '($28 $29 $30) $30 $30))
  (let $24 (lambda '($31 $32 $33 $34 $35) (block '(
    (let $36 (IfPresent $33 (lambda '($38) (IfPresent $34 (lambda '($39) (block '(
      (let $40 (Nth $38 '0))
      (let $41 (Nth $39 '0))
      (let $42 (IfPresent (Nth $39 '1) (lambda '($44) (IfPresent (Nth $38 '1) (lambda '($45) (AggrGreaterOrEqual $45 $44)) $1)) $2))
      (let $43 (If (AggrEquals $40 $41) $42 (AggrGreater $40 $41)))
      (return (Just (If $43 $38 $39)))
    ))) $33)) $34))
    (let $37 (IfPresent $33 (lambda '($46) (IfPresent $35 (lambda '($47) (block '(
      (let $48 (Nth $46 '0))
      (let $49 (Nth $47 '0))
      (let $50 (IfPresent (Nth $46 '1) (lambda '($52) (IfPresent (Nth $47 '1) (lambda '($53) (AggrLessOrEqual $52 $53)) $1)) $2))
      (let $51 (If (AggrEquals $48 $49) $50 (AggrLess $48 $49)))
      (return (Just (If $51 $46 $47)))
    ))) $33)) $35))
    (return $36 $37)
  ))))
  (let $25 (lambda '($54 $55 $56) $55 $56 $54))
  (return (DqPhyHashCombine (WideToBlocks (FromFlow (DqReadWideWrap $22 '()))) '-1073741824 (lambda '($26 $27) $26) $23 $24 $25))
))) $6))
(let $8 (DqCnHashShuffle (TDqOutput $7 '0) '('"2") '0 '"HashV2"))
(let $9 (StructType '('"column1" $3) '('"column2" $3) $4))
(let $10 '('('"_logical_id" '1887) '('"_id" '"6c732b05-dda31e8c-4e63cd0c-77e8c4e3") '('"_wide_channels" $9)))
(let $11 (DqPhyStage '($8) (lambda '($57) (block '(
  (let $58 (NarrowSqueezeToDict (ToFlow (WideFromBlocks $57)) (lambda '($62 $63 $64) $64) (lambda '($65 $66 $67) (AsStruct '('_yql_agg_0 $65) '('_yql_agg_1 $66) '('"key" $67))) '('Auto 'Many)))
  (let $59 (Condense1 (OrderedFlatMap $58 (lambda '($68) (OrderedFlatMap (DictPayloads $68) (lambda '($69) $69)))) (lambda '($70) $70) (lambda '($71 $72) (AggrNotEquals (Member $71 '"key") (Member $72 '"key"))) (lambda '($73 $74) (block '(
    (let $75 (Member $73 '_yql_agg_0))
    (let $76 (Member $74 '_yql_agg_0))
    (let $77 (IfPresent $75 (lambda '($81) (IfPresent $76 (lambda '($82) (block '(
      (let $83 (Nth $81 '0))
      (let $84 (Nth $82 '0))
      (let $85 (IfPresent (Nth $82 '1) (lambda '($87) (IfPresent (Nth $81 '1) (lambda '($88) (AggrGreaterOrEqual $88 $87)) $1)) $2))
      (let $86 (If (AggrEquals $83 $84) $85 (AggrGreater $83 $84)))
      (return (Just (If $86 $81 $82)))
    ))) $75)) $76))
    (let $78 (Member $73 '_yql_agg_1))
    (let $79 (Member $74 '_yql_agg_1))
    (let $80 (IfPresent $78 (lambda '($89) (IfPresent $79 (lambda '($90) (block '(
      (let $91 (Nth $89 '0))
      (let $92 (Nth $90 '0))
      (let $93 (IfPresent (Nth $89 '1) (lambda '($95) (IfPresent (Nth $90 '1) (lambda '($96) (AggrLessOrEqual $95 $96)) $1)) $2))
      (let $94 (If (AggrEquals $91 $92) $93 (AggrLess $91 $92)))
      (return (Just (If $94 $89 $90)))
    ))) $78)) $79))
    (return (AsStruct '('_yql_agg_0 $77) '('_yql_agg_1 $80) '('"key" (Member $74 '"key"))))
  )))))
  (let $60 (Sort (Map $59 (lambda '($97) (AsStruct '('"column1" (Member $97 '_yql_agg_1)) '('"column2" (Member $97 '_yql_agg_0)) '('"key" (Member $97 '"key"))))) $2 (lambda '($98) (Member $98 '"key"))))
  (let $61 (lambda '($99) (Member $99 '"column1") (Member $99 '"column2") (Member $99 '"key")))
  (return (FromFlow (ExpandMap $60 $61)))
))) $10))
(let $12 (DqCnMerge (TDqOutput $11 '0) '('('"2" '"Asc"))))
(let $13 (DqPhyStage '($12) (lambda '($100) (FromFlow (NarrowMap (ToFlow $100) (lambda '($101 $102 $103) (AsStruct '('"column1" $101) '('"column2" $102) '('"key" $103)))))) '('('"_logical_id" '1899) '('"_id" '"c5889448-fd413094-70bc87ea-c4c4a600"))))
(let $14 '($7 $11 $13))
(let $15 '('"key" '"column1" '"column2"))
(let $16 (DqCnResult (TDqOutput $13 '0) $15))
(return (KqpPhysicalQuery '((KqpPhysicalTx $14 '($16) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $9) '0 '0)) '('('"type" '"query"))))
)
