Open startompiz12 opened 1 year ago
Thank you for reporting it. We will look into it.
result.getStatement(0)
returns a nullptr
because the parser does not parse the query. According to the parser rule, the DISTINCT
keyword has to be before the TOP n
keyword:
https://github.com/hyrise/sql-parser/blob/18b9d0877d15b2ba06dfea2946d8c96e37254525/src/parser/bison_parser.y#L823
Thus, the parser errors: syntax error, unexpected TOP (L0:16)
. When you swap the keywords and write
SELECT TOP 3 DISTINCT value, id FROM TableA
the statement gets parsed correctly.
Hi, thank you for the quick answer.
According to the Microsoft documentation, the TOP clause must be placed after the DISTINCT one (at least for SQL Server and Azure SQL Database).
Using SELECT TOP 3 DISTINCT
would only work with Azure Synapse Analytics and Parallel Data Warehouse.
Running the following code results in a segfault:
DISTINCT and TOP clauses are handled correctly when used individually, the problem seems to happen only when both are used at the same time. Also not happening when using a LIMIT clause instead of the TOP.