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
std::string query = "SELECT DISTINCT TOP 3 value, id FROM TableA";
hsql::SQLParserResult result;
hsql::SQLParser::parse(query, &result);
const hsql::SQLStatement* stmt = result.getStatement(0);
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.
The text was updated successfully, but these errors were encountered:
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:
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.
The text was updated successfully, but these errors were encountered: