summaryrefslogtreecommitdiffstats
path: root/sqlglot/dialects/bigquery.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-26 17:21:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-10-26 17:21:54 +0000
commitc03ba18c491e52cc85d8aae1825dd9e0b4f75e32 (patch)
treef76d58b50900be4bfd2dc15f0ec38d1a70d8417b /sqlglot/dialects/bigquery.py
parentReleasing debian version 18.13.0-1. (diff)
downloadsqlglot-c03ba18c491e52cc85d8aae1825dd9e0b4f75e32.tar.xz
sqlglot-c03ba18c491e52cc85d8aae1825dd9e0b4f75e32.zip
Merging upstream version 18.17.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'sqlglot/dialects/bigquery.py')
-rw-r--r--sqlglot/dialects/bigquery.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/sqlglot/dialects/bigquery.py b/sqlglot/dialects/bigquery.py
index 7f69dd9..51baba2 100644
--- a/sqlglot/dialects/bigquery.py
+++ b/sqlglot/dialects/bigquery.py
@@ -8,6 +8,7 @@ from sqlglot import exp, generator, parser, tokens, transforms
from sqlglot._typing import E
from sqlglot.dialects.dialect import (
Dialect,
+ arg_max_or_min_no_count,
binary_from_function,
date_add_interval_sql,
datestrtodate_sql,
@@ -434,8 +435,13 @@ class BigQuery(Dialect):
TRANSFORMS = {
**generator.Generator.TRANSFORMS,
exp.ApproxDistinct: rename_func("APPROX_COUNT_DISTINCT"),
+ exp.ArgMax: arg_max_or_min_no_count("MAX_BY"),
+ exp.ArgMin: arg_max_or_min_no_count("MIN_BY"),
exp.ArraySize: rename_func("ARRAY_LENGTH"),
exp.Cast: transforms.preprocess([transforms.remove_precision_parameterized_types]),
+ exp.CollateProperty: lambda self, e: f"DEFAULT COLLATE {self.sql(e, 'this')}"
+ if e.args.get("default")
+ else f"COLLATE {self.sql(e, 'this')}",
exp.Create: _create_sql,
exp.CTE: transforms.preprocess([_pushdown_cte_column_names]),
exp.DateAdd: date_add_interval_sql("DATE", "ADD"),
@@ -632,6 +638,13 @@ class BigQuery(Dialect):
"within",
}
+ def eq_sql(self, expression: exp.EQ) -> str:
+ # Operands of = cannot be NULL in BigQuery
+ if isinstance(expression.left, exp.Null) or isinstance(expression.right, exp.Null):
+ return "NULL"
+
+ return self.binary(expression, "=")
+
def attimezone_sql(self, expression: exp.AtTimeZone) -> str:
parent = expression.parent