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

Using levels other than ErrorLevel.IMMEDIATE produces bogus errors and strange output #1698

Closed
pkit opened this issue May 27, 2023 · 3 comments

Comments

@pkit
Copy link
Contributor

pkit commented May 27, 2023

>>> import sqlglot; sqlglot.transpile("CREATE TABLE t (i UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple()", read="clickhouse", write="clickhouse", pretty=True, error_level=sqlglot.ErrorLevel("IMMEDIATE"))
['CREATE TABLE t (\n  i UInt8\n)\nENGINE=AggregatingMergeTree()\nORDER BY tuple()']

>>> import sqlglot; sqlglot.transpile("CREATE TABLE t (i UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple()", read="clickhouse", write="clickhouse", pretty=True, error_level=sqlglot.ErrorLevel("RAISE"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/kit/git/sqlglot/sqlglot/__init__.py", line 195, in transpile
    for expression in parse(sql, read, error_level=error_level)
  File "/home/kit/git/sqlglot/sqlglot/__init__.py", line 83, in parse
    return dialect.parse(sql, **opts)
  File "/home/kit/git/sqlglot/sqlglot/dialects/dialect.py", line 174, in parse
    return self.parser(**opts).parse(self.tokenize(sql), sql)
  File "/home/kit/git/sqlglot/sqlglot/parser.py", line 823, in parse
    return self._parse(
  File "/home/kit/git/sqlglot/sqlglot/parser.py", line 891, in _parse
    self.check_errors()
  File "/home/kit/git/sqlglot/sqlglot/parser.py", line 903, in check_errors
    raise ParseError(
sqlglot.errors.ParseError: Expecting ). Line 1, Col: 17.
  CREATE TABLE t (i UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple()

Required keyword: 'this' missing for <class 'sqlglot.expressions.Subquery'>. Line 1, Col: 23.
  CREATE TABLE t (i UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple()

Expecting ). Line 1, Col: 17.
  CREATE TABLE t (i UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple()

... and 2 more

>>> import sqlglot; sqlglot.transpile("CREATE TABLE t (i UInt8) ENGINE = AggregatingMergeTree() ORDER BY tuple()", read="clickhouse", write="clickhouse", pretty=True, error_level=sqlglot.ErrorLevel("IGNORE"))
['CREATE TABLE t AS\n(\n  \n)']

Version: 14.1.1

Looks like when the error level changes read and write become None...

@pkit
Copy link
Contributor Author

pkit commented May 27, 2023

@tobymao when is the next release? https://sql-translate.tools currently errors out left and right because of this one. lol

@tobymao
Copy link
Owner

tobymao commented May 28, 2023

monday, i don't like to deploy on weekends

@pkit
Copy link
Contributor Author

pkit commented May 28, 2023

thanks!

adrianisk pushed a commit to adrianisk/sqlglot that referenced this issue Jun 21, 2023
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

No branches or pull requests

2 participants