Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sqlglot/dialects/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ def _parse_unnest(self, with_alias: bool = True) -> t.Optional[exp.Unnest]:
def _parse_make_interval(self) -> exp.MakeInterval:
expr = exp.MakeInterval()

for arg_key in expr.arg_types:
for arg_key in ["year", "month", "day", "hour", "minute", "second"]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever an array/set exceeds 3 elements we tend to extract them out of the function e.g check out bigquery.py::DQUOTES_ESCAPING_JSON_FUNCTIONS

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'll do that.

value = self._parse_lambda()

if not value:
Expand Down
1 change: 1 addition & 0 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6591,6 +6591,7 @@ class MakeInterval(Func):
arg_types = {
"year": False,
"month": False,
"week": False,
"day": False,
"hour": False,
"minute": False,
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def test_bigquery(self):
self.validate_identity("BEGIN DECLARE y INT64", check_command_warning=True)
self.validate_identity("LOOP SET x = x + 1", check_command_warning=True)
self.validate_identity("REPEAT SET x = x + 1", check_command_warning=True)
self.validate_identity("SELECT MAKE_INTERVAL(100, 11, 1, 12, 30, 10)")
self.validate_identity(
"WHILE i < ARRAY_LENGTH(batches) DO SET x = batches[OFFSET(i)]",
check_command_warning=True,
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_databricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def test_databricks(self):
self.validate_identity("CURRENT_TIMEZONE()")
self.validate_identity("CURDATE()", "CURRENT_DATE")
self.validate_identity("CURDATE", "CURRENT_DATE")
self.validate_identity("SELECT MAKE_INTERVAL(100, 11, 12, 13, 14, 14, 15)")

# https://docs.databricks.com/sql/language-manual/functions/colonsign.html
def test_json(self):
Expand Down
1 change: 1 addition & 0 deletions tests/dialects/test_spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,7 @@ def test_spark(self):
)
self.validate_identity("BITMAP_OR_AGG(x)")
self.validate_identity("SELECT ELT(2, 'foo', 'bar', 'baz') AS Result")
self.validate_identity("SELECT MAKE_INTERVAL(100, 11, 12, 13, 14, 14, 15)")

def test_bool_or(self):
self.validate_all(
Expand Down