Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Teradata create volatile table statement #1674

Closed
MarkBell920 opened this issue May 22, 2023 · 0 comments · Fixed by #1675
Closed

Problem with Teradata create volatile table statement #1674

MarkBell920 opened this issue May 22, 2023 · 0 comments · Fixed by #1675
Assignees

Comments

@MarkBell920
Copy link

MarkBell920 commented May 22, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants