(
(let $1 (OptionalType (DataType 'Int32)))
(let $2 '('"key" $1))
(let $3 '('"key_hundred" $1))
(let $4 '('"subkey" $1))
(let $5 (StructType $2 $3 $4))
(let $6 '('('"_logical_id" '7329) '('"_id" '"e9adb19b-2ad68a7d-2a322d8-3e8d474e") '('"_wide_channels" $5)))
(let $7 (DqPhyStage '() (lambda '() (block '(
  (let $19 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $20 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $19)))
  (let $21 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" '"false")))))
  (let $22 (YtStat '('Id '"Input") '('RecordsCount '"14") '('DataSize '"621") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $23 (YtTable '"Input" $20 $21 $22 '() (Void) (Void) '"/Root/plato"))
  (let $24 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $23 '('"key" '"subkey") (Void) (Void))) '()))))
  (let $25 (lambda '($26 $27) (block '(
    (let $28 (SafeCast $26 $1))
    (return $28 (/ $28 (Int32 '"100")) (SafeCast $27 $1))
  ))))
  (return (FromFlow (WideMap (DqReadWideWrap $24 '()) $25)))
))) $6))
(let $8 (DqCnHashShuffle (TDqOutput $7 '0) '('1) '0 '"HashV2"))
(let $9 (OptionalType (DataType 'Uint32)))
(let $10 (StructType '('"first_esc_null" $9) '('"first_res_null" $9) $2 $3 '('"last_esc_null" $9) '('"last_res_null" $9) $4))
(let $11 '('('"_logical_id" '7807) '('"_id" '"ff438c61-1ff1413a-a88f2c3a-848c077b") '('"_wide_channels" $10)))
(let $12 (DqPhyStage '($8) (lambda '($29) (block '(
  (let $30 (NarrowSqueezeToDict (ToFlow $29) (lambda '($36 $37 $38) $37) (lambda '($39 $40 $41) (AsStruct '('"key" $39) '('"key_hundred" $40) '('"subkey" $41))) '('Auto 'Many)))
  (let $31 (Bool 'true))
  (let $32 (Chopper (OrderedFlatMap $30 (lambda '($42) (OrderedFlatMap (DictPayloads $42) (lambda '($43) (Sort $43 $31 (lambda '($44) (Member $44 '"key"))))))) (lambda '($45) (Member $45 '"key_hundred")) (lambda '($46 $47) (AggrNotEquals $46 (Member $47 '"key_hundred"))) (lambda '($48 $49) (block '(
    (let $50 (Chain1Map $49 (lambda '($55) (block '(
      (let $56 (Member $55 '"subkey"))
      (let $57 (SafeCast $56 $9))
      (let $58 '('FirstValue0 $57))
      (let $59 '('FirstValueIgnoreNulls0 $57))
      (let $60 '('LastValue0 $57))
      (let $61 '('LastValueIgnoreNulls0 $57))
      (let $62 (AsStruct $58 $59 $60 $61 '('"key" (Member $55 '"key")) '('"key_hundred" (Member $55 '"key_hundred")) '('"subkey" $56)))
      (let $63 (AsStruct $58 $59 $60 $61))
      (return '($62 $63))
    ))) (lambda '($64 $65) (block '(
      (let $66 (Nth $65 '1))
      (let $67 '('FirstValue0 (Member $66 'FirstValue0)))
      (let $68 (Member $66 'FirstValueIgnoreNulls0))
      (let $69 (Member $64 '"subkey"))
      (let $70 (SafeCast $69 $9))
      (let $71 (If (Exists $68) $68 $70))
      (let $72 '('FirstValueIgnoreNulls0 $71))
      (let $73 '('LastValue0 $70))
      (let $74 (If (Exists $70) $70 (Member $66 'LastValueIgnoreNulls0)))
      (let $75 '('LastValueIgnoreNulls0 $74))
      (let $76 (AsStruct $67 $72 $73 $75 '('"key" (Member $64 '"key")) '('"key_hundred" (Member $64 '"key_hundred")) '('"subkey" $69)))
      (let $77 (AsStruct $67 $72 $73 $75))
      (return '($76 $77))
    )))))
    (let $51 (StructType '('FirstValue0 $9) '('FirstValueIgnoreNulls0 $9) '('LastValue0 $9) '('LastValueIgnoreNulls0 $9) $2 $3 $4))
    (let $52 (ListType $51))
    (let $53 (VariantType (StructType '('group $52) '('singleRow $51))))
    (let $54 (Condense1 $50 (lambda '($78) (block '(
      (let $79 (Nth $78 '0))
      (let $80 (Variant $79 'singleRow $53))
      (return '((Member $79 '"key") $80))
    ))) (lambda '($81 $82) (AggrNotEquals (Member (Nth $81 '0) '"key") (Nth $82 '0))) (lambda '($83 $84) (block '(
      (let $85 (Nth $83 '0))
      (let $86 (Visit (Nth $84 '1) 'group (lambda '($87) (Variant (Insert $87 $85) 'group $53)) 'singleRow (lambda '($88) (Variant (AsList $88 $85) 'group $53))))
      (return '((Nth $84 '0) $86))
    )))))
    (return (OrderedFlatMap $54 (lambda '($89) (Visit (Nth $89 '1) 'group (lambda '($90) (IfPresent (Last $90) (lambda '($91) (OrderedMap (Collect (Map $90 (lambda '($92) (AsStruct '('"key" (Member $92 '"key")) '('"key_hundred" (Member $92 '"key_hundred")) '('"subkey" (Member $92 '"subkey")))))) (lambda '($93) (AsStruct '('FirstValue0 (Member $91 'FirstValue0)) '('FirstValueIgnoreNulls0 (Member $91 'FirstValueIgnoreNulls0)) '('LastValue0 (Member $91 'LastValue0)) '('LastValueIgnoreNulls0 (Member $91 'LastValueIgnoreNulls0)) '('"key" (Member $93 '"key")) '('"key_hundred" (Member $93 '"key_hundred")) '('"subkey" (Member $93 '"subkey")))))) (List $52))) 'singleRow (lambda '($94) (AsList $94))))))
  )))))
  (let $33 '($31 $31 $31))
  (let $34 (Sort (Map $32 (lambda '($95) (AsStruct '('"first_esc_null" (Member $95 'FirstValueIgnoreNulls0)) '('"first_res_null" (Member $95 'FirstValue0)) '('"key" (Member $95 '"key")) '('"key_hundred" (Member $95 '"key_hundred")) '('"last_esc_null" (Member $95 'LastValueIgnoreNulls0)) '('"last_res_null" (Member $95 'LastValue0)) '('"subkey" (Member $95 '"subkey"))))) $33 (lambda '($96) '((Member $96 '"key_hundred") (Member $96 '"key") (Member $96 '"subkey")))))
  (let $35 (lambda '($97) (Member $97 '"first_esc_null") (Member $97 '"first_res_null") (Member $97 '"key") (Member $97 '"key_hundred") (Member $97 '"last_esc_null") (Member $97 '"last_res_null") (Member $97 '"subkey")))
  (return (FromFlow (ExpandMap $34 $35)))
))) $11))
(let $13 '('('"3" '"Asc") '('"2" '"Asc") '('"6" '"Asc")))
(let $14 (DqCnMerge (TDqOutput $12 '0) $13))
(let $15 (DqPhyStage '($14) (lambda '($98) (FromFlow (NarrowMap (ToFlow $98) (lambda '($99 $100 $101 $102 $103 $104 $105) (AsStruct '('"first_esc_null" $99) '('"first_res_null" $100) '('"key" $101) '('"key_hundred" $102) '('"last_esc_null" $103) '('"last_res_null" $104) '('"subkey" $105)))))) '('('"_logical_id" '7819) '('"_id" '"d8961c2d-40c1302b-b5bc5267-bacd724c"))))
(let $16 '($7 $12 $15))
(let $17 '('"key_hundred" '"key" '"first_res_null" '"first_esc_null" '"last_res_null" '"last_esc_null" '"subkey"))
(let $18 (DqCnResult (TDqOutput $15 '0) $17))
(return (KqpPhysicalQuery '((KqpPhysicalTx $16 '($18) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $10) '0 '0)) '('('"type" '"query"))))
)
