(
(let $1 (lambda '() (block '(
  (let $27 '@@["StructType";[["key";["DataType";"String"]];["subkey";["DataType";"String"]];["value";["DataType";"String"]]]]@@)
  (let $28 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $27)))
  (let $29 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" 'false)))))
  (let $30 (YtStat '('Id '"Input") '('RecordsCount '"4") '('DataSize '"166") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
  (let $31 (YtTable '"Input" $28 $29 $30 '() (Void) (Void) '"/Root/plato"))
  (let $32 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $31 '('"key" '"subkey") (Void) (Void))) '()))))
  (return (FromFlow (DqReadWideWrap $32 '())))
))))
(let $2 '('"_logical_id" '3360))
(let $3 (DataType 'String))
(let $4 '('"key" $3))
(let $5 '('"subkey" $3))
(let $6 '('"_wide_channels" (StructType $4 $5)))
(let $7 '($2 '('"_id" '"1b2d70f8-138d60d5-765d3495-8bcafd8") $6))
(let $8 (DqPhyStage '() $1 $7))
(let $9 '($2 '('"_id" '"5d22df95-ae1e184e-d0c0d27f-3a41fb19") $6))
(let $10 (DqPhyStage '() $1 $9))
(let $11 (DqCnUnionAll (TDqOutput $10 '0)))
(let $12 (Bool 'true))
(let $13 (Bool 'false))
(let $14 (StructType '('FirstValue0 $3) '('FirstValue1 (NullType)) '('FirstValueIgnoreNulls0 $3) '('FirstValueIgnoreNulls1 (NullType)) '('LastValue0 $3) '('LastValue1 (NullType)) '('LastValueIgnoreNulls0 $3) '('LastValueIgnoreNulls1 (NullType))))
(let $15 '('('"_logical_id" '3421) '('"_id" '"747aa336-402eee2-6de123dd-f33a03eb") '('"_partition_mode" '"aggregate") '('"_wide_channels" $14)))
(let $16 (DqPhyStage '($11) (lambda '($33) (block '(
  (let $34 (lambda '($38) $38 (Null) $38 (Null) $38 (Null) $38 (Null)))
  (let $35 (lambda '($48 $49 $50 $51 $52 $53 $54 $55 $56) $49 $50 $49 $50 $48 (Null) $48 (Null)))
  (return (FromFlow (WideCondense1 (WideMap (WideSort (ToFlow $33) '('('1 $12))) (lambda '($36 $37) $36)) $34 (lambda '($39 $40 $41 $42 $43 $44 $45 $46 $47) $13) $35)))
))) $15))
(let $17 (DqCnMap (TDqOutput $8 '0)))
(let $18 (DqCnBroadcast (TDqOutput $16 '0)))
(let $19 (StructType '('"column1" $3) '('"column2" $3) '('"column3" $3) '('"column4" $3) '('"column5" (NullType)) '('"column6" (NullType)) '('"column7" (NullType)) '('"column8" (NullType)) $4 $5))
(let $20 '('('"_logical_id" '3660) '('"_id" '"c80e3818-41d3a8b0-a6c2ba04-1809662d") '('"_wide_channels" $19)))
(let $21 (DqPhyStage '($17 $18) (lambda '($57 $58) (block '(
  (let $59 (Condense1 (NarrowMap (ToFlow $58) (lambda '($66 $67 $68 $69 $70 $71 $72 $73) (AsStruct '('FirstValue0 $66) '('FirstValue1 $67) '('FirstValueIgnoreNulls0 $68) '('FirstValueIgnoreNulls1 $69) '('LastValue0 $70) '('LastValue1 $71) '('LastValueIgnoreNulls0 $72) '('LastValueIgnoreNulls1 $73)))) (lambda '($74) (AsList $74)) (lambda '($75 $76) $13) (lambda '($77 $78) (Append $78 $77))))
  (let $60 '"b.FirstValueIgnoreNulls0")
  (let $61 '"b.FirstValueIgnoreNulls1")
  (let $62 '"b.LastValueIgnoreNulls0")
  (let $63 '"b.LastValueIgnoreNulls1")
  (let $64 (Sort (Map (FlatMap $59 (lambda '($79) (NarrowFlatMap (ToFlow $57) (lambda '($80 $81) (Map (Collect $79) (lambda '($82) (AsStruct '('"a.key" $80) '('"a.subkey" $81) '('"b.FirstValue0" (Member $82 'FirstValue0)) '('"b.FirstValue1" (Member $82 'FirstValue1)) '($60 (Member $82 'FirstValueIgnoreNulls0)) '($61 (Member $82 'FirstValueIgnoreNulls1)) '('"b.LastValue0" (Member $82 'LastValue0)) '('"b.LastValue1" (Member $82 'LastValue1)) '($62 (Member $82 'LastValueIgnoreNulls0)) '($63 (Member $82 'LastValueIgnoreNulls1))))))))) (lambda '($83) (AsStruct '('"column1" (Member $83 '"b.FirstValue0")) '('"column2" (Member $83 $60)) '('"column3" (Member $83 '"b.LastValue0")) '('"column4" (Member $83 $62)) '('"column5" (Member $83 '"b.FirstValue1")) '('"column6" (Member $83 $61)) '('"column7" (Member $83 '"b.LastValue1")) '('"column8" (Member $83 $63)) '('"key" (Member $83 '"a.key")) '('"subkey" (Member $83 '"a.subkey"))))) $12 (lambda '($84) (Member $84 '"subkey"))))
  (let $65 (lambda '($85) (Member $85 '"column1") (Member $85 '"column2") (Member $85 '"column3") (Member $85 '"column4") (Member $85 '"column5") (Member $85 '"column6") (Member $85 '"column7") (Member $85 '"column8") (Member $85 '"key") (Member $85 '"subkey")))
  (return (FromFlow (ExpandMap $64 $65)))
))) $20))
(let $22 (DqCnMerge (TDqOutput $21 '0) '('('"9" '"Asc"))))
(let $23 (DqPhyStage '($22) (lambda '($86) (FromFlow (NarrowMap (ToFlow $86) (lambda '($87 $88 $89 $90 $91 $92 $93 $94 $95 $96) (AsStruct '('"column1" $87) '('"column2" $88) '('"column3" $89) '('"column4" $90) '('"column5" $91) '('"column6" $92) '('"column7" $93) '('"column8" $94) '('"key" $95) '('"subkey" $96)))))) '('('"_logical_id" '3672) '('"_id" '"481632fb-ddfc2109-2f537ca7-c3798ab4"))))
(let $24 '($8 $10 $16 $21 $23))
(let $25 '('"key" '"column1" '"column2" '"column3" '"column4" '"column5" '"column6" '"column7" '"column8" '"subkey"))
(let $26 (DqCnResult (TDqOutput $23 '0) $25))
(return (KqpPhysicalQuery '((KqpPhysicalTx $24 '($26) '() '('('"type" '"generic")))) '((KqpTxResultBinding (ListType $19) '0 '0)) '('('"type" '"query"))))
)
