(
(let $1 '@@["StructType";[["K";["DataType";"Int64"]];["J";["DataType";"Json"]]]]@@)
(let $2 (YqlRowSpec '('NativeYtTypeFlags '0) '('StrictSchema '1) '('UniqueKeys '0) '('Type $1)))
(let $3 (YtMeta '('CanWrite '1) '('DoesExist '1) '('YqlCompatibleScheme '1) '('InferredScheme '0) '('IsDynamic '0) '('Attrs '('('"native_strict_schema" '"false")))))
(let $4 (YtStat '('Id '"T") '('RecordsCount '"6") '('DataSize '"672") '('ChunkCount '1) '('ModifyTime '0) '('Revision '0)))
(let $5 (YtTable '"T" $2 $3 $4 '() (Void) (Void) '"/Root/plato"))
(let $6 (YtReadTable! world (DataSource '"yt" '"/Root/plato") '((YtSection '((YtPath $5 '('"J" '"K") (Void) (Void))) '()))))
(let $7 (TupleType (DataType 'Uint8) (DataType 'String)))
(let $8 (DataType 'Utf8))
(let $9 (OptionalType $8))
(let $10 (ResourceType '"JsonNode"))
(let $11 '((OptionalType $10)))
(let $12 '((ResourceType '"JsonPath")))
(let $13 (DictType $8 $10))
(let $14 '($13))
(let $15 (CallableType '() '((VariantType (TupleType $7 $9))) $11 $12 $14))
(let $16 '('('"strict")))
(let $17 (Udf '"Json2.SqlValueConvertToUtf8" (Void) (VoidType) '"" $15 (VoidType) '"" $16))
(let $18 '((DataType 'Json) '"" '1))
(let $19 (CallableType '() '($10) $18))
(let $20 (Udf '"Json2.Parse" (Void) (VoidType) '"" $19 (VoidType) '"" '()))
(let $21 (CallableType '() $12 '($8)))
(let $22 (Udf '"Json2.CompilePath" (Void) (VoidType) '"" $21 (VoidType) '"" '()))
(let $23 (Apply $22 (Utf8 '"lax $.who")))
(let $24 (Dict $13))
(let $25 (Nothing $9))
(let $26 (lambda '($89) $25))
(let $27 (lambda '($90) $90))
(let $28 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($85 $86) (block '(
  (let $87 (Apply $17 (Just (Apply $20 $85)) $23 $24))
  (let $88 (Visit $87 '0 $26 '1 $27))
  (return (AsStruct '('"K" $86) '('"Who" $88)))
)))))) '('('"_logical_id" '4272) '('"_id" '"303579bc-aa5b1695-5f5e866c-665b031f"))))
(let $29 (DqCnUnionAll (TDqOutput $28 '0)))
(let $30 (DqPhyStage '($29) (lambda '($91) $91) '('('"_logical_id" '4750) '('"_id" '"c56229b4-60b5a9d1-39c0ae3f-2efd80a5"))))
(let $31 (DqCnResult (TDqOutput $30 '0) '('"K" '"Who")))
(let $32 '('('"type" '"generic")))
(let $33 (KqpPhysicalTx '($28 $30) '($31) '() $32))
(let $34 (Apply $22 (Utf8 '"lax $.where")))
(let $35 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($92 $93) (block '(
  (let $94 (Just (Apply $20 $92)))
  (let $95 (Apply $17 $94 $34 $24))
  (let $96 (Visit $95 '0 $26 '1 $27))
  (let $97 (Apply $17 $94 $23 $24))
  (let $98 (Visit $97 '0 $26 '1 $27))
  (return (AsStruct '('"K" $93) '('"Nali" $96) '('"Who" $98)))
)))))) '('('"_logical_id" '4355) '('"_id" '"1b56fc39-3237fd4b-c9073458-7a88e3bd"))))
(let $36 (DqCnUnionAll (TDqOutput $35 '0)))
(let $37 (DqPhyStage '($36) (lambda '($99) $99) '('('"_logical_id" '5127) '('"_id" '"8c11f5ed-c5974877-4800c110-b59f9ae9"))))
(let $38 '('"K" '"Who" '"Nali"))
(let $39 (DqCnResult (TDqOutput $37 '0) $38))
(let $40 (KqpPhysicalTx '($35 $37) '($39) '() $32))
(let $41 (Apply $22 (Utf8 '"strict $.where")))
(let $42 (Uint8 '0))
(let $43 (lambda '($109) (Just $109)))
(let $44 '"Failed to cast default value from ON ERROR clause to target type Optional<Utf8>")
(let $45 (Ensure $25 (Bool '"false") (String $44)))
(let $46 (Apply $22 (Utf8 '"strict $.who")))
(let $47 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($100 $101) (block '(
  (let $102 (Just (Apply $20 $100)))
  (let $103 (Apply $17 $102 $41 $24))
  (let $104 (Visit $103 '0 (lambda '($107) (block '(
    (let $108 (IfPresent (SafeCast (String '"no where there") $9) $43 $45))
    (return (If (== (Nth $107 '0) $42) $25 $108))
  ))) '1 $27))
  (let $105 (Apply $17 $102 $46 $24))
  (let $106 (Visit $105 '0 $26 '1 $27))
  (return (AsStruct '('"K" $101) '('"Nali" $104) '('"Who" $106)))
)))))) '('('"_logical_id" '4440) '('"_id" '"416a7b1c-74900c0f-8ad06771-627cf517"))))
(let $48 (DqCnUnionAll (TDqOutput $47 '0)))
(let $49 (DqPhyStage '($48) (lambda '($110) $110) '('('"_logical_id" '5583) '('"_id" '"8e820892-8695cfca-17c1178-374d7371"))))
(let $50 (DqCnResult (TDqOutput $49 '0) $38))
(let $51 (KqpPhysicalTx '($47 $49) '($50) '() $32))
(let $52 (lambda '($120) (block '(
  (let $121 (IfPresent (SafeCast (String '"*** error ***") $9) $43 $45))
  (return (If (== (Nth $120 '0) $42) $25 $121))
))))
(let $53 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($111 $112) (block '(
  (let $113 (Just (Apply $20 $111)))
  (let $114 (Apply $17 $113 (Apply $22 (Utf8 '"lax $.friends.name")) $24))
  (let $115 (Visit $114 '0 $52 '1 $27))
  (let $116 (Apply $17 $113 $34 $24))
  (let $117 (Visit $116 '0 $26 '1 $27))
  (let $118 (Apply $17 $113 $23 $24))
  (let $119 (Visit $118 '0 $26 '1 $27))
  (return (AsStruct '('"Friend" $115) '('"K" $112) '('"Nali" $117) '('"Who" $119)))
)))))) '('('"_logical_id" '4527) '('"_id" '"503a273e-52ab8cb4-692dc28f-1397aed2"))))
(let $54 (DqCnUnionAll (TDqOutput $53 '0)))
(let $55 (DqPhyStage '($54) (lambda '($122) $122) '('('"_logical_id" '6169) '('"_id" '"ef723436-e76647f-753220f-c9e84241"))))
(let $56 '('"K" '"Who" '"Nali" '"Friend"))
(let $57 (DqCnResult (TDqOutput $55 '0) $56))
(let $58 (KqpPhysicalTx '($53 $55) '($57) '() $32))
(let $59 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($123 $124) (block '(
  (let $125 (Just (Apply $20 $123)))
  (let $126 (Apply $17 $125 (Apply $22 (Utf8 '"strict $.friends[*].name")) $24))
  (let $127 (Visit $126 '0 $52 '1 $27))
  (let $128 (Apply $17 $125 $41 $24))
  (let $129 (Visit $128 '0 $26 '1 $27))
  (let $130 (Apply $17 $125 $46 $24))
  (let $131 (Visit $130 '0 $26 '1 $27))
  (return (AsStruct '('"Friend" $127) '('"K" $124) '('"Nali" $129) '('"Who" $131)))
)))))) '('('"_logical_id" '4616) '('"_id" '"d4ccf7a-e619eac9-3d82ae5e-aa2b2a8a"))))
(let $60 (DqCnUnionAll (TDqOutput $59 '0)))
(let $61 (DqPhyStage '($60) (lambda '($132) $132) '('('"_logical_id" '6897) '('"_id" '"6c7fa221-dd708809-66e41bfe-42d9e196"))))
(let $62 (DqCnResult (TDqOutput $61 '0) $56))
(let $63 (KqpPhysicalTx '($59 $61) '($62) '() $32))
(let $64 (DataType 'Int64))
(let $65 (OptionalType $64))
(let $66 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($133 $134) (block '(
  (let $135 (CallableType '() '((VariantType (TupleType $7 (OptionalType (DataType 'Double))))) $11 $12 $14))
  (let $136 (Udf '"Json2.SqlValueNumber" (Void) (VoidType) '"" $135 (VoidType) '"" $16))
  (let $137 (Just (Apply $20 $133)))
  (let $138 (Apply $136 $137 (Apply $22 (Utf8 '"lax $.friends[0].rank")) $24))
  (let $139 (Nothing $65))
  (let $140 (Visit $138 '0 (lambda '($143) $139) '1 (lambda '($144) (If (Exists $144) (SafeCast $144 $65) $139))))
  (let $141 (Apply $17 $137 $23 $24))
  (let $142 (Visit $141 '0 $26 '1 $27))
  (return (AsStruct '('"K" $134) '('"Rank" $140) '('"Who" $142)))
)))))) '('('"_logical_id" '4703) '('"_id" '"1ba5b8dd-1876d810-5811871-677bc923"))))
(let $67 (DqCnUnionAll (TDqOutput $66 '0)))
(let $68 (DqPhyStage '($67) (lambda '($145) $145) '('('"_logical_id" '7613) '('"_id" '"9372e8c-e97d8a4b-7854da2-1666766f"))))
(let $69 '('"K" '"Who" '"Rank"))
(let $70 (DqCnResult (TDqOutput $68 '0) $69))
(let $71 (KqpPhysicalTx '($66 $68) '($70) '() $32))
(let $72 '($33 $40 $51 $58 $63 $71))
(let $73 '('"K" $64))
(let $74 '('"Who" $9))
(let $75 (KqpTxResultBinding (ListType (StructType $73 $74)) '0 '0))
(let $76 '('"Nali" $9))
(let $77 (ListType (StructType $73 $76 $74)))
(let $78 (KqpTxResultBinding $77 '1 '0))
(let $79 (KqpTxResultBinding $77 '"2" '0))
(let $80 (ListType (StructType '('"Friend" $9) $73 $76 $74)))
(let $81 (KqpTxResultBinding $80 '"3" '0))
(let $82 (KqpTxResultBinding $80 '"4" '0))
(let $83 (KqpTxResultBinding (ListType (StructType $73 '('"Rank" $65) $74)) '"5" '0))
(let $84 '($75 $78 $79 $81 $82 $83))
(return (KqpPhysicalQuery $72 $84 '('('"type" '"query"))))
)
