(
(let $1 (DataType 'Int32))
(let $2 '('('"_logical_id" '2760) '('"_id" '"f0751fbb-8d140ca0-2c935ead-f5a933e4") '('"_wide_channels" (StructType '('"ts" (OptionalType $1))))))
(let $3 (DqPhyStage '() (lambda '() (block '(
  (let $12 '@@["StructType";[["user";["OptionalType";["DataType";"String"]]];["ts";["OptionalType";["DataType";"Int32"]]];["payload";["DataType";"Int32"]]]]@@)
  (let $13 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $12)))
  (let $14 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $15 (YtStat '('Id '"Input") '('RecordsCount '"18") '('DataSize '"656") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $16 (YtTable '"Input" $13 $14 $15 '() (Void) (Void) '"/Root/plato"))
  (let $17 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $16 '('"ts") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $17 '())))
))) $2))
(let $4 (DqCnUnionAll (TDqOutput $3 '0)))
(let $5 (StructType '('"session_start" $1)))
(let $6 '('('"_logical_id" '3130) '('"_id" '"6e6f563b-d5057c7e-51e92f30-a727eb19") '('"_wide_channels" $5)))
(let $7 (DqPhyStage '($4) (lambda '($18) (block '(
  (let $19 (Bool 'true))
  (let $20 (Uint32 '0))
  (let $21 (Chain1Map (NarrowMap (WideSort (ToFlow $18) '('('0 $19))) (lambda '($25) (AsStruct '('"ts" $25)))) (lambda '($26) (block '(
    (let $27 (Member $26 '"ts"))
    (return '($26 $27 $27 $20))
  ))) (lambda '($28 $29) (block '(
    (let $30 (Member $28 '"ts"))
    (let $31 (Nth $29 '2))
    (let $32 (If (Coalesce (< $31 $30) $19) (- $30 $31) (- $31 $30)))
    (let $33 (If (And (AggrNotEquals $30 $31) (Coalesce (< (Int32 '"9") $32) $19)) $30 (Nth $29 '1)))
    (return '($28 $33 $30 $20))
  )))))
  (let $22 '"_yql_group_session_start")
  (let $23 (Condense1 $21 (lambda '($34) (AsStruct '('_yql_agg_0 (Member (Nth $34 '0) '"ts")) '($22 (Nth $34 '1)))) (lambda '($35 $36) (AggrNotEquals (Nth $35 '1) (Member $36 $22))) (lambda '($37 $38) (AsStruct '('_yql_agg_0 (AggrMin (Member (Nth $37 '0) '"ts") (Member $38 '_yql_agg_0))) '($22 (Member $38 $22))))))
  (let $24 (Sort (Map $23 (lambda '($39) (AsStruct '('"session_start" (Coalesce (Member $39 '_yql_agg_0) (Int32 '"100500")))))) $19 (lambda '($40) (Member $40 '"session_start"))))
  (return (FromFlow (ExpandMap $24 (lambda '($41) (Member $41 '"session_start")))))
))) $6))
(let $8 (DqCnMerge (TDqOutput $7 '0) '('('0 '"Asc"))))
(let $9 (DqPhyStage '($8) (lambda '($42) (FromFlow (NarrowMap (ToFlow $42) (lambda '($43) (AsStruct '('"session_start" $43)))))) '('('"_logical_id" '3142) '('"_id" '"e542b31a-2c50f4ef-7eb3ac8e-b720970d"))))
(let $10 '($3 $7 $9))
(let $11 (DqCnResult (TDqOutput $9 '0) '('"session_start")))
(return (KqpPhysicalQuery '((KqpPhysicalTx $10 '($11) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $5) '0 '0)) '('('"type" '"query"))))
)
