Skip to content

Various SQLGlot parsing issues #502

@izeigerman

Description

@izeigerman

1

Example:

In [2]: from sqlglot import parse_one

In [3]: parse_one("""
   ...: WITH cte AS (
   ...:   SELECT
   ...:     DISTINCT id,
   ...:     case
   ...:       when type = 'some_type' and name = 'Some Name' then timestamp
   ...:     end as ts
   ...:   FROM some_table
   ...:   WHERE timestamp::date >= '2022'
   ...: )
   ...: SELECT * FROM cte
   ...: """)

Error:

ParseError: Expected END after CASE. Line 7, Col: 5.
  id,
    case
      when type = 'some_type' and name = 'Some Name' then timestamp
    eend as ts
  FROM some_table
  WHERE timestamp::date >= '2022'
)
SELECT * FROM cte

2

Example:

In [5]: parse_one("""
   ...: SELECT DISTINCT
   ...:   FROM_SOMETHING
   ...: FROM some_table
   ...: """)

Error

ParseError: Invalid expression / Unexpected token. Line 2, Col: 8.

SELECT DISTINCT
  FROM_SOMETHING
FROM some_table

3

Example:

In [10]: parse_one("SELECT TOP 1 group_id FROM group_data")

Error:

ParseError: Invalid expression / Unexpected token. Line 1, Col: 12.
  SELECT TOP 1 group_id FROM group_data

4

Example:

parse_one("CONVERT(INT, something)", read="redshift")

Error:

ParseError: Required keyword: 'to' missing for <class 'sqlglot.expressions.TryCast'>. Line 1, Col: 14.
  CONVERT(INT, something)

5

Example:

In [17]: parse_one("LAST_VALUE(smth IGNORE NULLS) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)", read="redshift")

Error:

ParseError: Required keyword: 'expression' missing for <class 'sqlglot.expressions.And'>. Line 1, Col: 121.
  smth IGNORE NULLS) OVER (ORDER BY date ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

Progress:

  • No. 1
  • No. 2
  • No. 3
  • No. 4
  • No. 5

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions