sqlglot expressions - JSON functions.
1"""sqlglot expressions - JSON functions.""" 2 3from __future__ import annotations 4 5from sqlglot.expressions.core import Expression, Func, AggFunc, Binary, Predicate 6 7 8class CheckJson(Expression, Func): 9 arg_types = {"this": True} 10 11 12class JSONArray(Expression, Func): 13 arg_types = { 14 "expressions": False, 15 "null_handling": False, 16 "return_type": False, 17 "strict": False, 18 } 19 is_var_len_args = True 20 21 22class JSONArrayAgg(Expression, AggFunc): 23 arg_types = { 24 "this": True, 25 "order": False, 26 "null_handling": False, 27 "return_type": False, 28 "strict": False, 29 } 30 31 32class JSONArrayAppend(Expression, Func): 33 arg_types = {"this": True, "expressions": True} 34 is_var_len_args = True 35 _sql_names = ["JSON_ARRAY_APPEND"] 36 37 38class JSONArrayContains(Expression, Binary, Predicate, Func): 39 arg_types = {"this": True, "expression": True, "json_type": False} 40 _sql_names = ["JSON_ARRAY_CONTAINS"] 41 42 43class JSONArrayInsert(Expression, Func): 44 arg_types = {"this": True, "expressions": True} 45 is_var_len_args = True 46 _sql_names = ["JSON_ARRAY_INSERT"] 47 48 49class JSONBContains(Expression, Binary, Func): 50 _sql_names = ["JSONB_CONTAINS"] 51 52 53class JSONBContainsAllTopKeys(Expression, Binary, Func): 54 pass 55 56 57class JSONBContainsAnyTopKeys(Expression, Binary, Func): 58 pass 59 60 61class JSONBDeleteAtPath(Expression, Binary, Func): 62 pass 63 64 65class JSONBExists(Expression, Func): 66 arg_types = {"this": True, "path": True} 67 _sql_names = ["JSONB_EXISTS"] 68 69 70class JSONBExtract(Expression, Binary, Func): 71 _sql_names = ["JSONB_EXTRACT"] 72 73 74class JSONBExtractScalar(Expression, Binary, Func): 75 arg_types = {"this": True, "expression": True, "json_type": False} 76 _sql_names = ["JSONB_EXTRACT_SCALAR"] 77 78 79class JSONBObjectAgg(Expression, AggFunc): 80 arg_types = {"this": True, "expression": True} 81 82 83class JSONBool(Expression, Func): 84 pass 85 86 87class JSONExists(Expression, Func): 88 arg_types = { 89 "this": True, 90 "path": True, 91 "passing": False, 92 "on_condition": False, 93 "from_dcolonqmark": False, 94 } 95 96 97class JSONExtract(Expression, Binary, Func): 98 arg_types = { 99 "this": True, 100 "expression": True, 101 "only_json_types": False, 102 "expressions": False, 103 "variant_extract": False, 104 "json_query": False, 105 "option": False, 106 "quote": False, 107 "on_condition": False, 108 "requires_json": False, 109 "emits": False, 110 } 111 _sql_names = ["JSON_EXTRACT"] 112 is_var_len_args = True 113 114 @property 115 def output_name(self) -> str: 116 return self.expression.output_name if not self.expressions else "" 117 118 119class JSONExtractArray(Expression, Func): 120 arg_types = {"this": True, "expression": False} 121 _sql_names = ["JSON_EXTRACT_ARRAY"] 122 123 124class JSONExtractScalar(Expression, Binary, Func): 125 arg_types = { 126 "this": True, 127 "expression": True, 128 "only_json_types": False, 129 "expressions": False, 130 "json_type": False, 131 "scalar_only": False, 132 } 133 _sql_names = ["JSON_EXTRACT_SCALAR"] 134 is_var_len_args = True 135 136 @property 137 def output_name(self) -> str: 138 return self.expression.output_name 139 140 141class JSONFormat(Expression, Func): 142 arg_types = {"this": False, "options": False, "is_json": False, "to_json": False} 143 _sql_names = ["JSON_FORMAT"] 144 145 146class JSONKeys(Expression, Func): 147 arg_types = {"this": True, "expression": False, "expressions": False} 148 is_var_len_args = True 149 _sql_names = ["JSON_KEYS"] 150 151 152class JSONKeysAtDepth(Expression, Func): 153 arg_types = {"this": True, "expression": False, "mode": False} 154 155 156class JSONObject(Expression, Func): 157 arg_types = { 158 "expressions": False, 159 "null_handling": False, 160 "unique_keys": False, 161 "return_type": False, 162 "encoding": False, 163 } 164 165 166class JSONObjectAgg(Expression, AggFunc): 167 arg_types = { 168 "expressions": False, 169 "null_handling": False, 170 "unique_keys": False, 171 "return_type": False, 172 "encoding": False, 173 } 174 175 176class JSONRemove(Expression, Func): 177 arg_types = {"this": True, "expressions": True} 178 is_var_len_args = True 179 _sql_names = ["JSON_REMOVE"] 180 181 182class JSONSet(Expression, Func): 183 arg_types = {"this": True, "expressions": True} 184 is_var_len_args = True 185 _sql_names = ["JSON_SET"] 186 187 188class JSONStripNulls(Expression, Func): 189 arg_types = { 190 "this": True, 191 "expression": False, 192 "include_arrays": False, 193 "remove_empty": False, 194 } 195 _sql_names = ["JSON_STRIP_NULLS"] 196 197 198class StripNullValue(Expression, Func): 199 pass 200 201 202class JSONTable(Expression, Func): 203 arg_types = { 204 "this": True, 205 "schema": True, 206 "path": False, 207 "error_handling": False, 208 "empty_handling": False, 209 } 210 211 212class JSONType(Expression, Func): 213 arg_types = {"this": True, "expression": False} 214 _sql_names = ["JSON_TYPE"] 215 216 217class ObjectId(Expression, Func): 218 arg_types = {"this": True, "expression": False} 219 220 221class ObjectInsert(Expression, Func): 222 arg_types = { 223 "this": True, 224 "key": True, 225 "value": True, 226 "update_flag": False, 227 } 228 229 230class OpenJSON(Expression, Func): 231 arg_types = {"this": True, "path": False, "expressions": False} 232 233 234class ParseJSON(Expression, Func): 235 # BigQuery, Snowflake have PARSE_JSON, Presto has JSON_PARSE 236 # Snowflake also has TRY_PARSE_JSON, which is represented using `safe` 237 _sql_names = ["PARSE_JSON", "JSON_PARSE"] 238 arg_types = {"this": True, "expression": False, "safe": False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
13class JSONArray(Expression, Func): 14 arg_types = { 15 "expressions": False, 16 "null_handling": False, 17 "return_type": False, 18 "strict": False, 19 } 20 is_var_len_args = True
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
23class JSONArrayAgg(Expression, AggFunc): 24 arg_types = { 25 "this": True, 26 "order": False, 27 "null_handling": False, 28 "return_type": False, 29 "strict": False, 30 }
arg_types =
{'this': True, 'order': False, 'null_handling': False, 'return_type': False, 'strict': False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
33class JSONArrayAppend(Expression, Func): 34 arg_types = {"this": True, "expressions": True} 35 is_var_len_args = True 36 _sql_names = ["JSON_ARRAY_APPEND"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONArrayContains(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Predicate, sqlglot.expressions.core.Func):
39class JSONArrayContains(Expression, Binary, Predicate, Func): 40 arg_types = {"this": True, "expression": True, "json_type": False} 41 _sql_names = ["JSON_ARRAY_CONTAINS"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
44class JSONArrayInsert(Expression, Func): 45 arg_types = {"this": True, "expressions": True} 46 is_var_len_args = True 47 _sql_names = ["JSON_ARRAY_INSERT"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONBContains(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONBContainsAllTopKeys(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONBContainsAnyTopKeys(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONBDeleteAtPath(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
66class JSONBExists(Expression, Func): 67 arg_types = {"this": True, "path": True} 68 _sql_names = ["JSONB_EXISTS"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONBExtract(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONBExtractScalar(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
75class JSONBExtractScalar(Expression, Binary, Func): 76 arg_types = {"this": True, "expression": True, "json_type": False} 77 _sql_names = ["JSONB_EXTRACT_SCALAR"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
88class JSONExists(Expression, Func): 89 arg_types = { 90 "this": True, 91 "path": True, 92 "passing": False, 93 "on_condition": False, 94 "from_dcolonqmark": False, 95 }
arg_types =
{'this': True, 'path': True, 'passing': False, 'on_condition': False, 'from_dcolonqmark': False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONExtract(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
98class JSONExtract(Expression, Binary, Func): 99 arg_types = { 100 "this": True, 101 "expression": True, 102 "only_json_types": False, 103 "expressions": False, 104 "variant_extract": False, 105 "json_query": False, 106 "option": False, 107 "quote": False, 108 "on_condition": False, 109 "requires_json": False, 110 "emits": False, 111 } 112 _sql_names = ["JSON_EXTRACT"] 113 is_var_len_args = True 114 115 @property 116 def output_name(self) -> str: 117 return self.expression.output_name if not self.expressions else ""
arg_types =
{'this': True, 'expression': True, 'only_json_types': False, 'expressions': False, 'variant_extract': False, 'json_query': False, 'option': False, 'quote': False, 'on_condition': False, 'requires_json': False, 'emits': False}
output_name: str
115 @property 116 def output_name(self) -> str: 117 return self.expression.output_name if not self.expressions else ""
Name of the output column if this expression is a selection.
If the Expr has no output name, an empty string is returned.
Example:
>>> from sqlglot import parse_one >>> parse_one("SELECT a").expressions[0].output_name 'a' >>> parse_one("SELECT b AS c").expressions[0].output_name 'c' >>> parse_one("SELECT 1 + 2").expressions[0].output_name ''
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
120class JSONExtractArray(Expression, Func): 121 arg_types = {"this": True, "expression": False} 122 _sql_names = ["JSON_EXTRACT_ARRAY"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
class
JSONExtractScalar(sqlglot.expressions.core.Expression, sqlglot.expressions.core.Binary, sqlglot.expressions.core.Func):
125class JSONExtractScalar(Expression, Binary, Func): 126 arg_types = { 127 "this": True, 128 "expression": True, 129 "only_json_types": False, 130 "expressions": False, 131 "json_type": False, 132 "scalar_only": False, 133 } 134 _sql_names = ["JSON_EXTRACT_SCALAR"] 135 is_var_len_args = True 136 137 @property 138 def output_name(self) -> str: 139 return self.expression.output_name
arg_types =
{'this': True, 'expression': True, 'only_json_types': False, 'expressions': False, 'json_type': False, 'scalar_only': False}
output_name: str
Name of the output column if this expression is a selection.
If the Expr has no output name, an empty string is returned.
Example:
>>> from sqlglot import parse_one >>> parse_one("SELECT a").expressions[0].output_name 'a' >>> parse_one("SELECT b AS c").expressions[0].output_name 'c' >>> parse_one("SELECT 1 + 2").expressions[0].output_name ''
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
142class JSONFormat(Expression, Func): 143 arg_types = {"this": False, "options": False, "is_json": False, "to_json": False} 144 _sql_names = ["JSON_FORMAT"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
147class JSONKeys(Expression, Func): 148 arg_types = {"this": True, "expression": False, "expressions": False} 149 is_var_len_args = True 150 _sql_names = ["JSON_KEYS"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
153class JSONKeysAtDepth(Expression, Func): 154 arg_types = {"this": True, "expression": False, "mode": False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
157class JSONObject(Expression, Func): 158 arg_types = { 159 "expressions": False, 160 "null_handling": False, 161 "unique_keys": False, 162 "return_type": False, 163 "encoding": False, 164 }
arg_types =
{'expressions': False, 'null_handling': False, 'unique_keys': False, 'return_type': False, 'encoding': False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
167class JSONObjectAgg(Expression, AggFunc): 168 arg_types = { 169 "expressions": False, 170 "null_handling": False, 171 "unique_keys": False, 172 "return_type": False, 173 "encoding": False, 174 }
arg_types =
{'expressions': False, 'null_handling': False, 'unique_keys': False, 'return_type': False, 'encoding': False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
177class JSONRemove(Expression, Func): 178 arg_types = {"this": True, "expressions": True} 179 is_var_len_args = True 180 _sql_names = ["JSON_REMOVE"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
183class JSONSet(Expression, Func): 184 arg_types = {"this": True, "expressions": True} 185 is_var_len_args = True 186 _sql_names = ["JSON_SET"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
189class JSONStripNulls(Expression, Func): 190 arg_types = { 191 "this": True, 192 "expression": False, 193 "include_arrays": False, 194 "remove_empty": False, 195 } 196 _sql_names = ["JSON_STRIP_NULLS"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
203class JSONTable(Expression, Func): 204 arg_types = { 205 "this": True, 206 "schema": True, 207 "path": False, 208 "error_handling": False, 209 "empty_handling": False, 210 }
arg_types =
{'this': True, 'schema': True, 'path': False, 'error_handling': False, 'empty_handling': False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
213class JSONType(Expression, Func): 214 arg_types = {"this": True, "expression": False} 215 _sql_names = ["JSON_TYPE"]
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
222class ObjectInsert(Expression, Func): 223 arg_types = { 224 "this": True, 225 "key": True, 226 "value": True, 227 "update_flag": False, 228 }
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
231class OpenJSON(Expression, Func): 232 arg_types = {"this": True, "path": False, "expressions": False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments
235class ParseJSON(Expression, Func): 236 # BigQuery, Snowflake have PARSE_JSON, Presto has JSON_PARSE 237 # Snowflake also has TRY_PARSE_JSON, which is represented using `safe` 238 _sql_names = ["PARSE_JSON", "JSON_PARSE"] 239 arg_types = {"this": True, "expression": False, "safe": False}
Inherited Members
- sqlglot.expressions.core.Expression
- this
- expression
- expressions
- text
- is_string
- is_number
- to_py
- is_int
- is_star
- alias
- alias_column_names
- name
- alias_or_name
- output_name
- type
- is_type
- is_leaf
- meta
- copy
- add_comments
- pop_comments
- append
- set
- set_kwargs
- depth
- iter_expressions
- find
- find_all
- find_ancestor
- parent_select
- same_parent
- root
- walk
- dfs
- bfs
- unnest
- unalias
- unnest_operands
- flatten
- to_s
- sql
- transform
- replace
- pop
- assert_is
- error_messages
- and_
- or_
- not_
- update_positions
- as_
- isin
- between
- is_
- like
- ilike
- eq
- neq
- rlike
- div
- asc
- desc
- args
- parent
- arg_key
- index
- comments