(
(let $1 (DataType 'String))
(let $2 (OptionalType $1))
(let $3 '('subkey (OptionalType (DataType 'Int64))))
(let $4 (lambda '($41) (Member $41 '_yql_agg_0) (Member $41 '_yql_agg_1) (Member $41 'subkey)))
(let $5 (lambda '($42 $43 $44) (AsStruct '('_yql_agg_0 $42) '('_yql_agg_1 $43) '('subkey $44))))
(let $6 (StructType '('_yql_agg_0 $2) '('_yql_agg_1 $2) $3))
(let $7 '('('"_logical_id" '1638) '('"_id" '"19ca3881-b440cccb-15f29ff5-ebdafb0b") '('"_wide_channels" $6)))
(let $8 (DqPhyStage '() (lambda '() (block '(
  (let $18 '@@["StructType";[["key";["OptionalType";["DataType";"String"]]]]]@@)
  (let $19 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '0) '('UniqueKeys '0) '('Type $18)))
  (let $20 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '0) '('InferredScheme '1) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $21 (YtStat '('Id '"Input") '('RecordsCount '"3") '('DataSize '"95") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $22 (YtTable '"Input" $19 $20 $21 '() (Void) (Void) '"/Root/plato"))
  (let $23 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $22 '('"_other" '"key") (Void) (Void))) '()))))
  (let $24 (Nothing (OptionalType (DictType $1 (DataType 'Yson)))))
  (let $25 (CombineCore (NarrowFlatMap (DqReadWideWrap $23 '()) (lambda '($26 $27) (block '(
    (let $28 (AsStruct '('"_other" $26) '('"key" $27)))
    (let $29 (Member $28 '"_other"))
    (let $30 (TryWeakMemberFromDict (Just $29) $24 'Int64 'subkey))
    (return (If (Coalesce (> $30 (Int32 '0)) (Bool 'false)) (Just (AsStruct '('"_other" $29) '('"key" (Member $28 '"key")) '('subkey $30))) (Nothing (OptionalType (StructType '('"_other" (DictType $1 $1)) '('"key" $2) $3)))))
  )))) (lambda '($31) (Member $31 'subkey)) (lambda '($32 $33) (block '(
    (let $34 (TryWeakMemberFromDict (Just (Member $33 '"_other")) $24 'String '"value"))
    (return (AsStruct '('_yql_agg_0 $34) '('_yql_agg_1 (Member $33 '"key"))))
  ))) (lambda '($35 $36 $37) (block '(
    (let $38 (TryWeakMemberFromDict (Just (Member $36 '"_other")) $24 'String '"value"))
    (return (AsStruct '('_yql_agg_0 (AggrMax $38 (Member $37 '_yql_agg_0))) '('_yql_agg_1 (AggrMin (Member $36 '"key") (Member $37 '_yql_agg_1)))))
  ))) (lambda '($39 $40) (Just (AsStruct '('_yql_agg_0 (Member $40 '_yql_agg_0)) '('_yql_agg_1 (Member $40 '_yql_agg_1)) '('subkey $39)))) '0))
  (return (FromFlow (ExpandMap (NarrowMap (ExpandMap $25 $4) $5) $4)))
))) $7))
(let $9 (DqCnHashShuffle (TDqOutput $8 '0) '('"2") '0 '"HashV2"))
(let $10 (StructType '('"column0" $2) '('"column2" $2) $3))
(let $11 '('('"_logical_id" '2668) '('"_id" '"2013b2dc-c325b6de-27e3fa96-ad34c3ff") '('"_wide_channels" $10)))
(let $12 (DqPhyStage '($9) (lambda '($45) (block '(
  (let $46 (lambda '($54 $55 $56 $57) $55 $56 $57))
  (let $47 (lambda '($58 $59 $60 $61 $62 $63 $64) (AggrMax $59 $62) (AggrMin $60 $63) $64))
  (let $48 (WideCombiner (ExpandMap (NarrowMap (ToFlow $45) $5) $4) '"" (lambda '($51 $52 $53) $53) $46 $47 $46))
  (let $49 (Sort (NarrowMap $48 (lambda '($65 $66 $67) (block '(
    (let $68 (AsStruct '('Max0 $65) '('Min0 $66) '('subkey $67)))
    (return (AsStruct '('"column0" (Member $68 'Min0)) '('"column2" (Member $68 'Max0)) '('subkey (Member $68 'subkey))))
  )))) (Bool 'true) (lambda '($69) (Member $69 'subkey))))
  (let $50 (lambda '($70) (Member $70 '"column0") (Member $70 '"column2") (Member $70 'subkey)))
  (return (FromFlow (ExpandMap $49 $50)))
))) $11))
(let $13 (DqCnMerge (TDqOutput $12 '0) '('('"2" '"Asc"))))
(let $14 (DqPhyStage '($13) (lambda '($71) (FromFlow (NarrowMap (ToFlow $71) (lambda '($72 $73 $74) (AsStruct '('"column0" $72) '('"column2" $73) '('subkey $74)))))) '('('"_logical_id" '2680) '('"_id" '"8a3b8c7-9231113b-7db26651-8f004835"))))
(let $15 '($8 $12 $14))
(let $16 '('"column0" 'subkey '"column2"))
(let $17 (DqCnResult (TDqOutput $14 '0) $16))
(return (KqpPhysicalQuery '((KqpPhysicalTx $15 '($17) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $10) '0 '0)) '('('"type" '"query"))))
)
