You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for adding INCLUDE indexes in #2855, we've updated and now it works. There are EXCLUDE indexes in PostgreSQL, which would be great to support. Here is the example:
Python 3.8.10 (default, Nov 22 2023, 10:22:35)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlglot
>>> sqlglot.parse_one("""
... CREATE TABLE ht (
... vid INTEGER NOT NULL,
... fid INTEGER NOT NULL,
... nid INTEGER NOT NULL CHECK (nid > vid),
... vop CHAR(1) NOT NULL,
... nop CHAR(1) NOT NULL,
... geom GEOMETRY(POINTZ, 3857),
... fld_i INTEGER,
... fld_t TEXT,
... fld_d DATE,
... PRIMARY KEY (vid, fid),
... CONSTRAINT ht_vid_nid_fid_idx EXCLUDE USING gist (int4range(vid, nid) WITH &&, int4range(fid, fid, '[]') WITH &&)
... )
... """, read="postgres")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/__init__.py", line 124, in parse_one
result = dialect.parse(sql, **opts)
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/dialects/dialect.py", line 477, in parse
return self.parser(**opts).parse(self.tokenize(sql), sql)
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 1099, in parse
return self._parse(
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 1165, in _parse
expressions.append(parse_method(self))
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 1367, in _parse_statement
return self.STATEMENT_PARSERS[self._prev.token_type](self)
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 616, in <lambda>
TokenType.CREATE: lambda self: self._parse_create(),
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 1487, in _parse_create
this = self._parse_schema(this=table_parts)
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 4288, in _parse_schema
args = self._parse_csv(lambda: self._parse_constraint() or self._parse_field_def())
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 5367, in _parse_csv
parse_result = parse_method()
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 4288, in <lambda>
args = self._parse_csv(lambda: self._parse_constraint() or self._parse_field_def())
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 4453, in _parse_constraint
return self.expression(
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 1229, in expression
return self.validate_expression(instance)
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 1249, in validate_expression
self.raise_error(error_message)
File "/opt/ngw/env/lib/python3.8/site-packages/sqlglot/parser.py", line 1209, in raise_error
raise error
sqlglot.errors.ParseError: Required keyword: 'expressions' missing for <class 'sqlglot.expressions.Constraint'>. Line 13, Col: 38.
TEXT,
fld_d DATE,
PRIMARY KEY (vid, fid),
CONSTRAINT ht_vid_nid_fid_idx EXCLUDE USING gist (int4range(vid, nid) WITH &&, int4range(fid, fid, '[]') WITH &&)
)
>>> sqlglot.__version__
'22.2.1'
The text was updated successfully, but these errors were encountered:
Thanks for adding INCLUDE indexes in #2855, we've updated and now it works. There are EXCLUDE indexes in PostgreSQL, which would be great to support. Here is the example:
The text was updated successfully, but these errors were encountered: