summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/bigquery.py
diff options
context:
space:
mode:
Diffstat (limited to 'sqlglot/dialects/bigquery.py')
-rw-r--r--sqlglot/dialects/bigquery.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/sqlglot/dialects/bigquery.py b/sqlglot/dialects/bigquery.py
index 4550d65..5b44912 100644
--- a/sqlglot/dialects/bigquery.py
+++ b/sqlglot/dialects/bigquery.py
@@ -56,12 +56,12 @@ def _derived_table_values_to_unnest(self, expression):
def _returnsproperty_sql(self, expression):
- value = expression.args.get("value")
- if isinstance(value, exp.Schema):
- value = f"{value.this} <{self.expressions(value)}>"
+ this = expression.this
+ if isinstance(this, exp.Schema):
+ this = f"{this.this} <{self.expressions(this)}>"
else:
- value = self.sql(value)
- return f"RETURNS {value}"
+ this = self.sql(this)
+ return f"RETURNS {this}"
def _create_sql(self, expression):
@@ -142,6 +142,11 @@ class BigQuery(Dialect):
),
}
+ FUNCTION_PARSERS = {
+ **parser.Parser.FUNCTION_PARSERS,
+ }
+ FUNCTION_PARSERS.pop("TRIM")
+
NO_PAREN_FUNCTIONS = {
**parser.Parser.NO_PAREN_FUNCTIONS,
TokenType.CURRENT_DATETIME: exp.CurrentDatetime,
@@ -174,6 +179,7 @@ class BigQuery(Dialect):
exp.Values: _derived_table_values_to_unnest,
exp.ReturnsProperty: _returnsproperty_sql,
exp.Create: _create_sql,
+ exp.Trim: lambda self, e: f"TRIM({self.format_args(e.this, e.expression)})",
exp.VolatilityProperty: lambda self, e: f"DETERMINISTIC"
if e.name == "IMMUTABLE"
else "NOT DETERMINISTIC",
@@ -200,9 +206,7 @@ class BigQuery(Dialect):
exp.VolatilityProperty,
}
- WITH_PROPERTIES = {
- exp.AnonymousProperty,
- }
+ WITH_PROPERTIES = {exp.Property}
EXPLICIT_UNION = True