(
(let $1 (OptionalType (DataType 'Int32)))
(let $2 '('"key" $1))
(let $3 '('"key_hundred" $1))
(let $4 '('"value" (DataType 'String)))
(let $5 (StructType $2 $3 '('"subkey" $1) $4))
(let $6 '('('"_logical_id" '5897) '('"_id" '"f8554fe1-82abd15e-7ed8b52b-c30b1e48") '('"_wide_channels" $5)))
(let $7 (DqPhyStage '() (lambda '() (block '(
  (let $18 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $19 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $18)))
  (let $20 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" '"false")))))
  (let $21 (YtStat '('Id '"Input") '('RecordsCount '"14") '('DataSize '"614") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $22 (YtTable '"Input" $19 $20 $21 '() (Void) (Void) '"/Root/plato"))
  (let $23 '('"key" '"subkey" '"value"))
  (let $24 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $22 $23 (Void) (Void))) '()))))
  (let $25 (lambda '($26 $27 $28) (block '(
    (let $29 (SafeCast $26 $1))
    (return $29 (/ $29 (Int32 '"100")) (SafeCast $27 $1) $28)
  ))))
  (return (FromFlow (WideMap (DqReadWideWrap $24 '()) $25)))
))) $6))
(let $8 (DqCnHashShuffle (TDqOutput $7 '0) '('1) '0 '"HashV2"))
(let $9 (StructType $2 '('"key_diff" $1) $3 '('"row" (DataType 'Uint64)) '('"subkey_diff" $1) $4))
(let $10 '('('"_logical_id" '6973) '('"_id" '"65f63892-a0e81be2-b9499f14-9a0f444a") '('"_wide_channels" $9)))
(let $11 (DqPhyStage '($8) (lambda '($30) (block '(
  (let $31 (NarrowSqueezeToDict (ToFlow $30) (lambda '($37 $38 $39 $40) $38) (lambda '($41 $42 $43 $44) (AsStruct '('"key" $41) '('"key_hundred" $42) '('"subkey" $43) '('"value" $44))) '('Auto 'Many)))
  (let $32 (Bool 'true))
  (let $33 (Chopper (OrderedFlatMap $31 (lambda '($45) (OrderedFlatMap (DictPayloads $45) (lambda '($46) (Sort $46 '($32 $32) (lambda '($47) '((Member $47 '"key") (Member $47 '"value")))))))) (lambda '($48) (Member $48 '"key_hundred")) (lambda '($49 $50) (AggrNotEquals $49 (Member $50 '"key_hundred"))) (lambda '($51 $52) (block '(
    (let $53 (FromFlow $52))
    (let $54 (Uint64 '1))
    (let $55 (QueueCreate $5 (Uint64 '"3") $54 (DependsOn $53)))
    (let $56 (Uint64 '0))
    (let $57 (lambda '($68) (Member $68 '"key")))
    (let $58 (Nothing $1))
    (let $59 (lambda '($69) (Member $69 '"subkey")))
    (let $60 (Chain1Map (ToFlow (PreserveStream $53 $55 $56)) (lambda '($61) (block '(
      (let $62 (QueuePeek $55 $56 (DependsOn $61)))
      (let $63 (IfPresent $62 $57 $58))
      (let $64 (IfPresent $62 $59 $58))
      (let $65 '('_yql_RowNumber0 $54))
      (let $66 (AsStruct '('_yql_Lag0 $63) '('_yql_Lag1 $64) $65 '('"key" (Member $61 '"key")) '('"key_hundred" (Member $61 '"key_hundred")) '('"subkey" (Member $61 '"subkey")) '('"value" (Member $61 '"value"))))
      (let $67 (AsStruct '('_yql_Lag0 (Void)) '('_yql_Lag1 (Void)) $65))
      (return '($66 $67))
    ))) (lambda '($70 $71) (block '(
      (let $72 (QueuePeek $55 $56 (DependsOn $70)))
      (let $73 (IfPresent $72 $57 $58))
      (let $74 (IfPresent $72 $59 $58))
      (let $75 (Nth $71 '1))
      (let $76 '('_yql_RowNumber0 (Inc (Member $75 '_yql_RowNumber0))))
      (let $77 (AsStruct '('_yql_Lag0 $73) '('_yql_Lag1 $74) $76 '('"key" (Member $70 '"key")) '('"key_hundred" (Member $70 '"key_hundred")) '('"subkey" (Member $70 '"subkey")) '('"value" (Member $70 '"value"))))
      (let $78 (AsStruct '('_yql_Lag0 (Member $75 '_yql_Lag0)) '('_yql_Lag1 (Member $75 '_yql_Lag1)) $76))
      (return '($77 $78))
    )))))
    (return (OrderedMap $60 (lambda '($79) (Nth $79 '0))))
  )))))
  (let $34 '($32 $32 $32))
  (let $35 (Sort (Map $33 (lambda '($80) (block '(
    (let $81 (Member $80 '"key"))
    (return (AsStruct '('"key" $81) '('"key_diff" (- $81 (Member $80 '_yql_Lag0))) '('"key_hundred" (Member $80 '"key_hundred")) '('"row" (Member $80 '_yql_RowNumber0)) '('"subkey_diff" (- (Member $80 '"subkey") (Member $80 '_yql_Lag1))) '('"value" (Member $80 '"value"))))
  )))) $34 (lambda '($82) '((Member $82 '"key_hundred") (Member $82 '"key") (Member $82 '"value")))))
  (let $36 (lambda '($83) (Member $83 '"key") (Member $83 '"key_diff") (Member $83 '"key_hundred") (Member $83 '"row") (Member $83 '"subkey_diff") (Member $83 '"value")))
  (return (FromFlow (ExpandMap $35 $36)))
))) $10))
(let $12 '('('"2" '"Asc") '('0 '"Asc") '('"5" '"Asc")))
(let $13 (DqCnMerge (TDqOutput $11 '0) $12))
(let $14 (DqPhyStage '($13) (lambda '($84) (FromFlow (NarrowMap (ToFlow $84) (lambda '($85 $86 $87 $88 $89 $90) (AsStruct '('"key" $85) '('"key_diff" $86) '('"key_hundred" $87) '('"row" $88) '('"subkey_diff" $89) '('"value" $90)))))) '('('"_logical_id" '6985) '('"_id" '"68ecb478-b8b8d2e8-63c6f253-5995b686"))))
(let $15 '($7 $11 $14))
(let $16 '('"key_hundred" '"key" '"key_diff" '"subkey_diff" '"row" '"value"))
(let $17 (DqCnResult (TDqOutput $14 '0) $16))
(return (KqpPhysicalQuery '((KqpPhysicalTx $15 '($17) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $9) '0 '0)) '('('"type" '"query"))))
)
