diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-07 12:35:01 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-04-07 12:35:01 +0000 |
commit | 58c11f70074708344e433080e47621091a6dcd84 (patch) | |
tree | 2589166e0e58be4947e07a956d26efa497bccaf2 /sqlglot/expressions.py | |
parent | Adding upstream version 11.4.5. (diff) | |
download | sqlglot-upstream/11.5.2.tar.xz sqlglot-upstream/11.5.2.zip |
Adding upstream version 11.5.2.upstream/11.5.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/expressions.py')
-rw-r--r-- | sqlglot/expressions.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/sqlglot/expressions.py b/sqlglot/expressions.py index f4aae47..9011dce 100644 --- a/sqlglot/expressions.py +++ b/sqlglot/expressions.py @@ -948,12 +948,17 @@ class Column(Condition): return Dot.build(parts) +class ColumnPosition(Expression): + arg_types = {"this": False, "position": True} + + class ColumnDef(Expression): arg_types = { "this": True, "kind": False, "constraints": False, "exists": False, + "position": False, } @@ -3290,6 +3295,13 @@ class Anonymous(Func): is_var_len_args = True +# https://docs.snowflake.com/en/sql-reference/functions/hll +# https://docs.aws.amazon.com/redshift/latest/dg/r_HLL_function.html +class Hll(AggFunc): + arg_types = {"this": True, "expressions": False} + is_var_len_args = True + + class ApproxDistinct(AggFunc): arg_types = {"this": True, "accuracy": False} @@ -3440,6 +3452,10 @@ class CurrentTimestamp(Func): arg_types = {"this": False} +class CurrentUser(Func): + arg_types = {"this": False} + + class DateAdd(Func, TimeUnit): arg_types = {"this": True, "expression": True, "unit": False} @@ -3647,6 +3663,11 @@ class JSONBExtractScalar(JSONExtract): _sql_names = ["JSONB_EXTRACT_SCALAR"] +class JSONFormat(Func): + arg_types = {"this": False, "options": False} + _sql_names = ["JSON_FORMAT"] + + class Least(Func): arg_types = {"expressions": False} is_var_len_args = True @@ -3703,14 +3724,9 @@ class VarMap(Func): is_var_len_args = True -class Matches(Func): - """Oracle/Snowflake decode. - https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions040.htm - Pattern matching MATCHES(value, search1, result1, ...searchN, resultN, else) - """ - - arg_types = {"this": True, "expressions": True} - is_var_len_args = True +# https://dev.mysql.com/doc/refman/8.0/en/fulltext-search.html +class MatchAgainst(Func): + arg_types = {"this": True, "expressions": True, "modifier": False} class Max(AggFunc): @@ -4989,9 +5005,10 @@ def replace_placeholders(expression, *args, **kwargs): Examples: >>> from sqlglot import exp, parse_one >>> replace_placeholders( - ... parse_one("select * from :tbl where ? = ?"), "a", "b", tbl="foo" + ... parse_one("select * from :tbl where ? = ?"), + ... exp.to_identifier("str_col"), "b", tbl=exp.to_identifier("foo") ... ).sql() - 'SELECT * FROM foo WHERE a = b' + "SELECT * FROM foo WHERE str_col = 'b'" Returns: The mapped expression. @@ -5002,10 +5019,10 @@ def replace_placeholders(expression, *args, **kwargs): if node.name: new_name = kwargs.get(node.name) if new_name: - return to_identifier(new_name) + return convert(new_name) else: try: - return to_identifier(next(args)) + return convert(next(args)) except StopIteration: pass return node |