Skip to content

Commit 51b1bb1

Browse files
committed
Fix: move WATERMARK logic to risingwave fixes #5989
1 parent 3c7b5c0 commit 51b1bb1

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

sqlglot/dialects/risingwave.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ class Parser(Postgres.Parser):
2525
"KEY": lambda self: self._parse_encode_property(key=True),
2626
}
2727

28+
CONSTRAINT_PARSERS = {
29+
**Postgres.Parser.CONSTRAINT_PARSERS,
30+
"WATERMARK": lambda self: self.expression(
31+
exp.WatermarkColumnConstraint,
32+
this=self._match(TokenType.FOR) and self._parse_column(),
33+
expression=self._match(TokenType.ALIAS) and self._parse_disjunction(),
34+
),
35+
}
36+
37+
SCHEMA_UNNAMED_CONSTRAINTS = {
38+
*Postgres.Parser.SCHEMA_UNNAMED_CONSTRAINTS,
39+
"WATERMARK",
40+
}
41+
2842
def _parse_table_hints(self) -> t.Optional[t.List[exp.Expression]]:
2943
# There is no hint in risingwave.
3044
# Do nothing here to avoid WITH keywords conflict in CREATE SINK statement.

sqlglot/parser.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,11 +1141,6 @@ class Parser(metaclass=_Parser):
11411141
"TTL": lambda self: self.expression(exp.MergeTreeTTL, expressions=[self._parse_bitwise()]),
11421142
"UNIQUE": lambda self: self._parse_unique(),
11431143
"UPPERCASE": lambda self: self.expression(exp.UppercaseColumnConstraint),
1144-
"WATERMARK": lambda self: self.expression(
1145-
exp.WatermarkColumnConstraint,
1146-
this=self._match(TokenType.FOR) and self._parse_column(),
1147-
expression=self._match(TokenType.ALIAS) and self._parse_disjunction(),
1148-
),
11491144
"WITH": lambda self: self.expression(
11501145
exp.Properties, expressions=self._parse_wrapped_properties()
11511146
),
@@ -1211,7 +1206,6 @@ def _parse_partitioned_by_bucket_or_truncate(self) -> t.Optional[exp.Expression]
12111206
"PERIOD",
12121207
"PRIMARY KEY",
12131208
"UNIQUE",
1214-
"WATERMARK",
12151209
"BUCKET",
12161210
"TRUNCATE",
12171211
}

tests/dialects/test_duckdb.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ def test_duckdb(self):
284284
self.validate_identity(
285285
"SELECT LIST_TRANSFORM(LIST_FILTER([0, 1, 2, 3, 4, 5], LAMBDA x : x % 2 = 0), LAMBDA y : y * y)"
286286
)
287+
self.validate_identity("CREATE TABLE notes (watermark TEXT)")
287288
self.validate_identity("SELECT LIST_TRANSFORM([5, NULL, 6], LAMBDA x : COALESCE(x, 0) + 1)")
288289
self.validate_identity("SELECT LIST_TRANSFORM(nbr, LAMBDA x : x + 1) FROM article AS a")
289290
self.validate_identity("SELECT * FROM my_ducklake.demo AT (VERSION => 2)")

0 commit comments

Comments
 (0)