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
There is a problem with parsing the Teradata CREATE VOLATILE TABLE statement.
In Teradata version 16.20 this SQL will work correctly:
create multiset volatile table my_table (
id int
)
primary index (id)
on commit preserve rows ;
This SQL will fail
create multiset volatile table my_table (
id int
)
on commit preserve rows
primary index (id) ;
With the Error "Expected something between the ROWS keyword and the PRIMARY keyword"
In sqlglot using teradata
The first statement will fail but the second incorrect statement will parse correctly.
The error from the first statement is:
File ~\AppData\Roaming\Python\Python311\site-packages\sqlglot\parser.py:851, in Parser.parse(self, raw_tokens, sql)
837 def parse(
838 self, raw_tokens: t.List[Token], sql: t.Optional[str] = None
839 ) -> t.List[t.Optional[exp.Expression]]:
840 """
841 Parses a list of tokens and returns a list of syntax trees, one tree
842 per parsed SQL statement.
(...)
849 The list of syntax trees.
850 """
--> 851 return self._parse(
852 parse_method=self.class._parse_statement, raw_tokens=raw_tokens, sql=sql
853 )
There is a problem with parsing the Teradata CREATE VOLATILE TABLE statement.
In Teradata version 16.20 this SQL will work correctly:
create multiset volatile table my_table (
id int
)
primary index (id)
on commit preserve rows ;
This SQL will fail
create multiset volatile table my_table (
id int
)
on commit preserve rows
primary index (id) ;
With the Error "Expected something between the ROWS keyword and the PRIMARY keyword"
In sqlglot using teradata
The first statement will fail but the second incorrect statement will parse correctly.
The error from the first statement is:
File ~\AppData\Roaming\Python\Python311\site-packages\sqlglot\parser.py:851, in Parser.parse(self, raw_tokens, sql)
837 def parse(
838 self, raw_tokens: t.List[Token], sql: t.Optional[str] = None
839 ) -> t.List[t.Optional[exp.Expression]]:
840 """
841 Parses a list of tokens and returns a list of syntax trees, one tree
842 per parsed SQL statement.
(...)
849 The list of syntax trees.
850 """
--> 851 return self._parse(
852 parse_method=self.class._parse_statement, raw_tokens=raw_tokens, sql=sql
853 )
File ~\AppData\Roaming\Python\Python311\site-packages\sqlglot\parser.py:917, in Parser._parse(self, parse_method, raw_tokens, sql)
914 expressions.append(parse_method(self))
916 if self._index < len(self._tokens):
--> 917 self.raise_error("Invalid expression / Unexpected token")
919 self.check_errors()
921 return expressions
File ~\AppData\Roaming\Python\Python311\site-packages\sqlglot\parser.py:960, in Parser.raise_error(self, message, token)
948 error = ParseError.new(
949 f"{message}. Line {token.line}, Col: {token.col}.\n"
950 f" {start_context}\033[4m{highlight}\033[0m{end_context}",
(...)
956 end_context=end_context,
957 )
959 if self.error_level == ErrorLevel.IMMEDIATE:
--> 960 raise error
962 self.errors.append(error)
ParseError: Invalid expression / Unexpected token. Line 6, Col: 2.
The text was updated successfully, but these errors were encountered: