Skip to content

Commit

Permalink
fix: array overlaps closes #2903
Browse files Browse the repository at this point in the history
  • Loading branch information
tobymao committed Feb 1, 2024
1 parent b00b393 commit ab97246
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions sqlglot/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4126,10 +4126,6 @@ class Sub(Binary):
pass


class ArrayOverlaps(Binary):
pass


# Unary Expressions
# (NOT a)
class Unary(Condition):
Expand Down Expand Up @@ -4467,6 +4463,10 @@ class ArrayJoin(Func):
arg_types = {"this": True, "expression": True, "null": False}


class ArrayOverlaps(Binary, Func):
pass


class ArraySize(Func):
arg_types = {"this": True, "expression": False}

Expand Down
8 changes: 7 additions & 1 deletion tests/dialects/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ def test_postgres(self):
self.validate_identity("CAST(x AS DATEMULTIRANGE)")
self.validate_identity("SELECT ARRAY[1, 2, 3] @> ARRAY[1, 2]")
self.validate_identity("SELECT ARRAY[1, 2, 3] <@ ARRAY[1, 2]")
self.validate_identity("SELECT ARRAY[1, 2, 3] && ARRAY[1, 2]")
self.validate_all(
"SELECT ARRAY[1, 2, 3] && ARRAY[1, 2]",
write={
"": "SELECT ARRAY_OVERLAPS(ARRAY(1, 2, 3), ARRAY(1, 2))",
"postgres": "SELECT ARRAY[1, 2, 3] && ARRAY[1, 2]",
},
)
self.validate_identity("x$")
self.validate_identity("SELECT ARRAY[1, 2, 3]")
self.validate_identity("SELECT ARRAY(SELECT 1)")
Expand Down

0 comments on commit ab97246

Please sign in to comment.