(
(let $1 (Bool 'false))
(let $2 (Bool 'true))
(let $3 (OptionalType (TupleType (DataType 'Int32) (OptionalType (OptionalType (DataType 'Double))))))
(let $4 '('('"_logical_id" '1453) '('"_id" '"1db9b3f-aaa9fb9b-98d3cf3c-a951020e") '('"_wide_channels" (StructType '('_yql_agg_0 $3) '('_yql_agg_1 $3)))))
(let $5 (DqPhyStage '() (lambda '() (block '(
  (let $14 '@@["StructType";[["key";["DataType";"Uint32"]];["subkey";["DataType";"Uint32"]];["value";["OptionalType";["TupleType";[["DataType";"Int32"];["OptionalType";["OptionalType";["DataType";"Double"]]]]]]]]]@@)
  (let $15 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $14)))
  (let $16 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $17 (YtStat '('Id '"Input") '('RecordsCount '"14") '('DataSize '"600") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $18 (YtTable '"Input" $15 $16 $17 '() (Void) (Void) '"/Root/plato"))
  (let $19 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $18 '('"value") (Void) (Void))) '()))))
  (let $20 (lambda '($22) $22 $22))
  (let $21 (lambda '($26 $27 $28) (block '(
    (let $29 (IfPresent $26 (lambda '($31) (IfPresent $27 (lambda '($32) (block '(
      (let $33 (Nth $31 '0))
      (let $34 (Nth $32 '0))
      (let $35 (IfPresent (Nth $32 '1) (lambda '($37) (IfPresent (Nth $31 '1) (lambda '($38) (AggrGreaterOrEqual $38 $37)) $1)) $2))
      (let $36 (If (AggrEquals $33 $34) $35 (AggrGreater $33 $34)))
      (return (Just (If $36 $31 $32)))
    ))) $26)) $27))
    (let $30 (IfPresent $26 (lambda '($39) (IfPresent $28 (lambda '($40) (block '(
      (let $41 (Nth $39 '0))
      (let $42 (Nth $40 '0))
      (let $43 (IfPresent (Nth $39 '1) (lambda '($45) (IfPresent (Nth $40 '1) (lambda '($46) (AggrLessOrEqual $45 $46)) $1)) $2))
      (let $44 (If (AggrEquals $41 $42) $43 (AggrLess $41 $42)))
      (return (Just (If $44 $39 $40)))
    ))) $26)) $28))
    (return $29 $30)
  ))))
  (return (FromFlow (WideCondense1 (DqReadWideWrap $19 '()) $20 (lambda '($23 $24 $25) $1) $21)))
))) $4))
(let $6 (DqCnUnionAll (TDqOutput $5 '0)))
(let $7 (StructType '('Max0 $3) '('Min0 $3)))
(let $8 '('('"_logical_id" '1534) '('"_id" '"c6de9dca-73aa987-d701f3f2-50acf4a7") '('"_partition_mode" '"aggregate") '('"_wide_channels" $7)))
(let $9 (DqPhyStage '($6) (lambda '($47) (block '(
  (let $48 (lambda '($50 $51) $50 $51))
  (let $49 (lambda '($56 $57 $58 $59) (block '(
    (let $60 (IfPresent $56 (lambda '($62) (IfPresent $58 (lambda '($63) (block '(
      (let $64 (Nth $62 '0))
      (let $65 (Nth $63 '0))
      (let $66 (IfPresent (Nth $63 '1) (lambda '($68) (IfPresent (Nth $62 '1) (lambda '($69) (AggrGreaterOrEqual $69 $68)) $1)) $2))
      (let $67 (If (AggrEquals $64 $65) $66 (AggrGreater $64 $65)))
      (return (Just (If $67 $62 $63)))
    ))) $56)) $58))
    (let $61 (IfPresent $57 (lambda '($70) (IfPresent $59 (lambda '($71) (block '(
      (let $72 (Nth $70 '0))
      (let $73 (Nth $71 '0))
      (let $74 (IfPresent (Nth $70 '1) (lambda '($76) (IfPresent (Nth $71 '1) (lambda '($77) (AggrLessOrEqual $76 $77)) $1)) $2))
      (let $75 (If (AggrEquals $72 $73) $74 (AggrLess $72 $73)))
      (return (Just (If $75 $70 $71)))
    ))) $57)) $59))
    (return $60 $61)
  ))))
  (return (FromFlow (WideCondense1 (ToFlow $47) $48 (lambda '($52 $53 $54 $55) $1) $49)))
))) $8))
(let $10 (DqCnUnionAll (TDqOutput $9 '0)))
(let $11 (DqPhyStage '($10) (lambda '($78) (block '(
  (let $79 (Condense (NarrowMap (ToFlow $78) (lambda '($80 $81) (AsStruct '('Max0 $80) '('Min0 $81)))) (List (ListType $7)) (lambda '($82 $83) $1) (lambda '($84 $85) (AsList $84))))
  (return (FromFlow (Map $79 (lambda '($86) (block '(
    (let $87 (ToOptional $86))
    (return (AsStruct '('"column0" (Member $87 'Min0)) '('"column1" (Member $87 'Max0))))
  ))))))
))) '('('"_logical_id" '1710) '('"_id" '"8130f14d-bfba2e51-2fb5de1f-47b78106"))))
(let $12 '($5 $9 $11))
(let $13 (DqCnResult (TDqOutput $11 '0) '('"column0" '"column1")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $12 '($13) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType (StructType '('"column0" $3) '('"column1" $3))) '0 '0)) '('('"type" '"query"))))
)
