[
https://issues.apache.org/jira/browse/CALCITE-6819?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17925121#comment-17925121
]
Sree Harsha Ramanavarapu edited comment on CALCITE-6819 at 2/8/25 2:06 AM:
---------------------------------------------------------------------------
It is true that this problem extends to HAVING too.
SELECT COUNT\(\*\), c11 FROM t1 GROUP BY c11 HAVING TRUE;
Msg 4145, Level 15, State 1, Server 2bb9efcde8bf, Line 6
An expression of non-boolean type specified in a context where a condition is
expected, near ';'.
SELECT COUNT\(\*\), c11 FROM t1 GROUP BY c11 HAVING 1=1;
works fine.
But "SELECT TRUE" or "SELECT 1=1" in this case is a bit more tricky because
MSSQL returns the error:
SELECT 1=1;
Incorrect syntax near '='.
I will withdraw the current PR and submit a new one to include the HAVING
clause.
Please let me know if you think we should just return an error for the "SELECT
TRUE" or "SELECT 1=1" case for MSSQL.
was (Author: JIRAUSER305541):
It is true that this problem extends to HAVING too.
SELECT COUNT(*), c11 FROM t1 GROUP BY c11 HAVING TRUE;
Msg 4145, Level 15, State 1, Server 2bb9efcde8bf, Line 6
An expression of non-boolean type specified in a context where a condition is
expected, near ';'.
SELECT COUNT(*), c11 FROM t1 GROUP BY c11 HAVING 1=1;
works fine.
But "SELECT TRUE" or "SELECT 1=1" in this case is a bit more tricky because
MSSQL returns the error:
SELECT 1=1;
Incorrect syntax near '='.
I will withdraw the current PR and submit a new one to include the HAVING
clause.
Please let me know if you think we should just return an error for the "SELECT
TRUE" or "SELECT 1=1" case for MSSQL.
> MSSQL doesn't support TRUE/FALSE keywords in its Join predicate
> ---------------------------------------------------------------
>
> Key: CALCITE-6819
> URL: https://issues.apache.org/jira/browse/CALCITE-6819
> Project: Calcite
> Issue Type: Bug
> Reporter: Sree Harsha Ramanavarapu
> Priority: Major
> Labels: pull-request-available
>
> CREATE TABLE t1 (c11 int, c12 int);
> INSERT INTO t1 VALUES (1,10), (2,20), (3,30);
> CREATE TABLE t2 (c21 int, c22 int);
> SELECT * FROM t1 LEFT OUTER JOIN t2 ON TRUE;
> Msg 4145, Level 15, State 1, Server a08c6f7cfc77, Line 9
> An expression of non-boolean type specified in a context where a condition is
> expected, near ';'.
> TRUE/FALSE are not supported in MSSQL (but it is supported in most DBs).
> The MSSQL way would be to write the query as :
> SELECT * FROM t1 LEFT OUTER JOIN t2 ON 1=1;
> MSSQL dialect should support this syntax.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)