You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Vova Vysotskyi (Jira)" <ji...@apache.org> on 2021/12/31 19:40:00 UTC
[jira] [Assigned] (CALCITE-4968) Calcite generates invalid MS SQL queries for the query with the LIMIT statement
[ https://issues.apache.org/jira/browse/CALCITE-4968?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Vova Vysotskyi reassigned CALCITE-4968:
---------------------------------------
Assignee: Vova Vysotskyi
> Calcite generates invalid MS SQL queries for the query with the LIMIT statement
> -------------------------------------------------------------------------------
>
> Key: CALCITE-4968
> URL: https://issues.apache.org/jira/browse/CALCITE-4968
> Project: Calcite
> Issue Type: Bug
> Reporter: Vova Vysotskyi
> Assignee: Vova Vysotskyi
> Priority: Major
> Labels: pull-request-available
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Calcite converts the following query
> {code:sql}
> SELECT * FROM "employee" LIMIT 1
> {code}
> to the following one for {{MssqlSqlDialect}}:
> {code:sql}
> SELECT *
> FROM [foodmart].[employee]
> FETCH NEXT 1 ROWS ONLY
> {code}
> The issue is that MS SQL Server allows using {{FETCH}} (and {{OFFSET}}) statements only when {{ORDER BY}} is specified, so the query above fails.
> One of the workarounds for this limitation is to insert {{ORDER BY (SELECT NULL)}} for the case when no actual {{ORDER BY}} statement is specified.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)