(
(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 (DataType 'Bool))
(let $8 (ResourceType '"JsonNode"))
(let $9 (OptionalType $8))
(let $10 '($9))
(let $11 '((ResourceType '"JsonPath")))
(let $12 (DataType 'Utf8))
(let $13 (DictType $12 $8))
(let $14 '($13))
(let $15 '('('"strict")))
(let $16 (DataType 'Json))
(let $17 '($16 '"" '1))
(let $18 (CallableType '() '($8) $17))
(let $19 (Udf '"Json2.Parse" (Void) (VoidType) '"" $18 (VoidType) '"" '()))
(let $20 (CallableType '() $11 '($12)))
(let $21 (Udf '"Json2.CompilePath" (Void) (VoidType) '"" $20 (VoidType) '"" '()))
(let $22 (Apply $21 (Utf8 '"lax $.friends")))
(let $23 (Dict $13))
(let $24 (Bool 'false))
(let $25 '($7))
(let $26 (CallableType '() $10 $10 $11 $14 $25 $10 $25 $10))
(let $27 (Udf '"Json2.SqlQuery" (Void) (VoidType) '"" $26 (VoidType) '"" '()))
(let $28 (Nothing $9))
(let $29 (DataType 'JsonDocument))
(let $30 '($8 '"" '1))
(let $31 (CallableType '() '($29) $30))
(let $32 (Udf '"Json2.SerializeToJsonDocument" (Void) (VoidType) '"" $31 (VoidType) '"" '()))
(let $33 (OptionalType $29))
(let $34 (OptionalType $12))
(let $35 (CallableType '() '((VariantType (TupleType (TupleType (DataType 'Uint8) (DataType 'String)) $34))) $10 $11 $14))
(let $36 (Udf '"Json2.SqlValueConvertToUtf8" (Void) (VoidType) '"" $35 (VoidType) '"" $15))
(let $37 (Apply $21 (Utf8 '"lax $.where")))
(let $38 (lambda '($112) (Nothing $34)))
(let $39 (lambda '($113) $113))
(let $40 (Apply $21 (Utf8 '"lax $.who")))
(let $41 '('"K" (DataType 'Int64)))
(let $42 '('"Nali" $34))
(let $43 '('"Who" $34))
(let $44 (StructType '('"Friends" $33) $41 $42 $43))
(let $45 (DqPhyStage '() (lambda '() (FromFlow (NarrowFlatMap (DqReadWideWrap $6 '()) (lambda '($98 $99) (block '(
  (let $100 '((OptionalType $7)))
  (let $101 (CallableType '() $100 $10 $11 $14 $100))
  (let $102 (Udf '"Json2.SqlExists" (Void) (VoidType) '"" $101 (VoidType) '"" $15))
  (let $103 (Just (Apply $19 $98)))
  (let $104 (Apply $102 $103 $22 $23 (Just $24)))
  (let $105 (Apply $27 $103 $22 $23 $24 $28 $24 $28))
  (let $106 (IfPresent $105 (lambda '($111) (Just (Apply $32 $111))) (Nothing $33)))
  (let $107 (Apply $36 $103 $37 $23))
  (let $108 (Visit $107 '0 $38 '1 $39))
  (let $109 (Apply $36 $103 $40 $23))
  (let $110 (Visit $109 '0 $38 '1 $39))
  (return (If (Coalesce $104 $24) (Just (AsStruct '('"Friends" $106) '('"K" $99) '('"Nali" $108) '('"Who" $110))) (Nothing (OptionalType $44))))
)))))) '('('"_logical_id" '3474) '('"_id" '"8a3e777b-78957d93-3df204a9-6754f123"))))
(let $46 (DqCnUnionAll (TDqOutput $45 '0)))
(let $47 (DqPhyStage '($46) (lambda '($114) $114) '('('"_logical_id" '3801) '('"_id" '"7a5349cc-54ea1a2-16e05390-954856a4"))))
(let $48 '('"K" '"Who" '"Nali" '"Friends"))
(let $49 (DqCnResult (TDqOutput $47 '0) $48))
(let $50 '('('"type" '"generic")))
(let $51 (KqpPhysicalTx '($45 $47) '($49) '() $50))
(let $52 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($115 $116) (block '(
  (let $117 (Just (Apply $19 $115)))
  (let $118 (Apply $27 $117 $22 $23 $24 $28 $24 $28))
  (let $119 (IfPresent $118 (lambda '($124) (Just (Apply $32 $124))) (Nothing $33)))
  (let $120 (Apply $36 $117 $37 $23))
  (let $121 (Visit $120 '0 $38 '1 $39))
  (let $122 (Apply $36 $117 $40 $23))
  (let $123 (Visit $122 '0 $38 '1 $39))
  (return (AsStruct '('"Friends" $119) '('"K" $116) '('"Nali" $121) '('"Who" $123)))
)))))) '('('"_logical_id" '3567) '('"_id" '"15f3a59e-b7887940-c513c38b-d3af2f0b"))))
(let $53 (DqCnUnionAll (TDqOutput $52 '0)))
(let $54 (DqPhyStage '($53) (lambda '($125) $125) '('('"_logical_id" '4780) '('"_id" '"95486bdc-fca68f3c-a9bd1a27-97622cc"))))
(let $55 (DqCnResult (TDqOutput $54 '0) $48))
(let $56 (KqpPhysicalTx '($52 $54) '($55) '() $50))
(let $57 (Udf '"Json2.SqlQueryWrap" (Void) (VoidType) '"" $26 (VoidType) '"" '()))
(let $58 (DqPhyStage '() (lambda '() (FromFlow (NarrowMap (DqReadWideWrap $6 '()) (lambda '($126 $127) (block '(
  (let $128 (Just (Apply $19 $126)))
  (let $129 (Apply $57 $128 (Apply $21 (Utf8 '"lax $.friends.name")) $23 $24 $28 $24 $28))
  (let $130 (IfPresent $129 (lambda '($135) (Just (Apply $32 $135))) (Nothing $33)))
  (let $131 (Apply $36 $128 $37 $23))
  (let $132 (Visit $131 '0 $38 '1 $39))
  (let $133 (Apply $36 $128 $40 $23))
  (let $134 (Visit $133 '0 $38 '1 $39))
  (return (AsStruct '('"FriendsNames" $130) '('"K" $127) '('"Nali" $132) '('"Who" $134)))
)))))) '('('"_logical_id" '3656) '('"_id" '"8eb41990-1f97e977-fdc23305-d097d2e4"))))
(let $59 (DqCnUnionAll (TDqOutput $58 '0)))
(let $60 (DqPhyStage '($59) (lambda '($136) $136) '('('"_logical_id" '5510) '('"_id" '"a7e47478-1d792052-11e35df4-ae38f07c"))))
(let $61 '('"K" '"Who" '"Nali" '"FriendsNames"))
(let $62 (DqCnResult (TDqOutput $60 '0) $61))
(let $63 (KqpPhysicalTx '($58 $60) '($62) '() $50))
(let $64 '@@{ "a": "[1,2]", "b": [1,2], "c": "hi"}@@)
(let $65 (SafeCast (String $64) (OptionalType $16)))
(let $66 (Apply $21 (Utf8 '"strict $.a")))
(let $67 (Apply $21 (Utf8 '"strict $.b")))
(let $68 (Apply $21 (Utf8 '"strict $.c")))
(let $69 '('"_partition_mode" '"single"))
(let $70 '('('"_logical_id" '3687) '('"_id" '"8d2d36d9-da7c69ac-af3c9e4c-2ac6089") $69))
(let $71 (DqPhyStage '() (lambda '() (block '(
  (let $137 (IfPresent $65 (lambda '($144) (Just (Apply $19 $144))) (Nothing $9)))
  (let $138 (Apply $36 $137 $66 $23))
  (let $139 (Visit $138 '0 $38 '1 $39))
  (let $140 (Apply $36 $137 $67 $23))
  (let $141 (Visit $140 '0 $38 '1 $39))
  (let $142 (Apply $36 $137 $68 $23))
  (let $143 (Visit $142 '0 $38 '1 $39))
  (return (Iterator (AsList (AsStruct '('"column0" $139) '('"column1" $141) '('"column2" $143)))))
))) $70))
(let $72 '('"column0" '"column1" '"column2"))
(let $73 (DqCnResult (TDqOutput $71 '0) $72))
(let $74 (KqpPhysicalTx '($71) '($73) '() $50))
(let $75 '('('"_logical_id" '3711) '('"_id" '"3e38a931-6cd09fb4-a090385b-8a0679e2") $69))
(let $76 (DqPhyStage '() (lambda '() (block '(
  (let $145 (IfPresent $65 (lambda '($154) (Just (Apply $19 $154))) $28))
  (let $146 (Apply $27 $145 $66 $23 $24 $28 $24 $28))
  (let $147 (lambda '($155) (Just (Apply $32 $155))))
  (let $148 (Nothing $33))
  (let $149 (IfPresent $146 $147 $148))
  (let $150 (Apply $27 $145 $67 $23 $24 $28 $24 $28))
  (let $151 (IfPresent $150 $147 $148))
  (let $152 (Apply $27 $145 $68 $23 $24 $28 $24 $28))
  (let $153 (IfPresent $152 $147 $148))
  (return (Iterator (AsList (AsStruct '('"column0" $149) '('"column1" $151) '('"column2" $153)))))
))) $75))
(let $77 (DqCnResult (TDqOutput $76 '0) $72))
(let $78 (KqpPhysicalTx '($76) '($77) '() $50))
(let $79 '('('"_logical_id" '3735) '('"_id" '"500af51f-ad76cdc9-de13709f-5095a268") $69))
(let $80 (DqPhyStage '() (lambda '() (block '(
  (let $156 (IfPresent $65 (lambda '($165) (Just (Apply $19 $165))) $28))
  (let $157 (Apply $57 $156 $66 $23 $24 $28 $24 $28))
  (let $158 (lambda '($166) (Just (Apply $32 $166))))
  (let $159 (Nothing $33))
  (let $160 (IfPresent $157 $158 $159))
  (let $161 (Apply $57 $156 $67 $23 $24 $28 $24 $28))
  (let $162 (IfPresent $161 $158 $159))
  (let $163 (Apply $57 $156 $68 $23 $24 $28 $24 $28))
  (let $164 (IfPresent $163 $158 $159))
  (return (Iterator (AsList (AsStruct '('"column0" $160) '('"column1" $162) '('"column2" $164)))))
))) $79))
(let $81 (DqCnResult (TDqOutput $80 '0) $72))
(let $82 (KqpPhysicalTx '($80) '($81) '() $50))
(let $83 '('('"_logical_id" '3759) '('"_id" '"34cbb74f-90e00368-11200e0f-ee069e38") $69))
(let $84 (DqPhyStage '() (lambda '() (block '(
  (let $167 (Udf '"Json2.SqlQueryConditionalWrap" (Void) (VoidType) '"" $26 (VoidType) '"" '()))
  (let $168 (IfPresent $65 (lambda '($177) (Just (Apply $19 $177))) $28))
  (let $169 (Apply $167 $168 $66 $23 $24 $28 $24 $28))
  (let $170 (lambda '($178) (Just (Apply $32 $178))))
  (let $171 (Nothing $33))
  (let $172 (IfPresent $169 $170 $171))
  (let $173 (Apply $167 $168 $67 $23 $24 $28 $24 $28))
  (let $174 (IfPresent $173 $170 $171))
  (let $175 (Apply $167 $168 $68 $23 $24 $28 $24 $28))
  (let $176 (IfPresent $175 $170 $171))
  (return (Iterator (AsList (AsStruct '('"column0" $172) '('"column1" $174) '('"column2" $176)))))
))) $83))
(let $85 (DqCnResult (TDqOutput $84 '0) $72))
(let $86 (KqpPhysicalTx '($84) '($85) '() $50))
(let $87 '($51 $56 $63 $74 $78 $82 $86))
(let $88 (ListType $44))
(let $89 (KqpTxResultBinding $88 '0 '0))
(let $90 (KqpTxResultBinding $88 '1 '0))
(let $91 (KqpTxResultBinding (ListType (StructType '('"FriendsNames" $33) $41 $42 $43)) '"2" '0))
(let $92 (KqpTxResultBinding (ListType (StructType '('"column0" $34) '('"column1" $34) '('"column2" $34))) '"3" '0))
(let $93 (ListType (StructType '('"column0" $33) '('"column1" $33) '('"column2" $33))))
(let $94 (KqpTxResultBinding $93 '"4" '0))
(let $95 (KqpTxResultBinding $93 '"5" '0))
(let $96 (KqpTxResultBinding $93 '6 '0))
(let $97 '($89 $90 $91 $92 $94 $95 $96))
(return (KqpPhysicalQuery $87 $97 '('('"type" '"query"))))
)
