[ 
https://issues.apache.org/jira/browse/CALCITE-3751?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-3751:
---------------------------------
    Description: 
JDBC adapter wrongly pushes ORDER BY into sub-query. When I run
{code:java}
select deptno, job, sum(sal)
from scott.emp
group by deptno, job
order by 1,2;
{code}
against the hsqldb database via the JDBC adapter I get the error
{noformat}
Error: Error while executing SQL "select deptno, job, sum(sal) from scott.emp 
group by deptno, job order by 1,2": While executing SQL [SELECT "DEPTNO", 
"JOB", SUM("SAL")
FROM (SELECT "JOB", "DEPTNO", SUM("SAL")
FROM "SCOTT"."EMP"
GROUP BY "JOB", "DEPTNO"
ORDER BY "DEPTNO" NULLS LAST, "JOB" NULLS LAST) AS "t0"] on JDBC sub-schema 
(state=,code=0)
Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object not 
found: SAL
 at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
 at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
{noformat}
Note that ORDER BY is inside a sub-query, which I presume is invalid SQL for 
hsqldb (and most other DBs).

  was:
JDBC adapter wrongly pushes ORDER BY into sub-query. When I run
{code}select deptno, job, sum(sal)
from scott.emp
group by deptno, job
order by 1,2;
{code}
against the hsqldb database via the JDBC adapter I get the error
{noformat}Error: Error while executing SQL "select deptno, job, sum(sal) from 
scott.emp group by deptno, job order by 1,2": While executing SQL [SELECT 
"DEPTNO", "JOB", SUM("SAL")
FROM (SELECT "JOB", "DEPTNO", SUM("SAL")
FROM "SCOTT"."EMP"
GROUP BY "JOB", "DEPTNO"
ORDER BY "DEPTNO" NULLS LAST, "JOB" NULLS LAST) AS "t0"] on JDBC sub-schema 
(state=,code=0)
{noformat}
Note that ORDER BY is inside a sub-query, which I presume is invalid SQL for 
hsqldb (and most other DBs).


> JDBC adapter wrongly pushes ORDER BY into sub-query
> ---------------------------------------------------
>
>                 Key: CALCITE-3751
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3751
>             Project: Calcite
>          Issue Type: Bug
>          Components: jdbc-adapter
>            Reporter: Julian Hyde
>            Priority: Major
>
> JDBC adapter wrongly pushes ORDER BY into sub-query. When I run
> {code:java}
> select deptno, job, sum(sal)
> from scott.emp
> group by deptno, job
> order by 1,2;
> {code}
> against the hsqldb database via the JDBC adapter I get the error
> {noformat}
> Error: Error while executing SQL "select deptno, job, sum(sal) from scott.emp 
> group by deptno, job order by 1,2": While executing SQL [SELECT "DEPTNO", 
> "JOB", SUM("SAL")
> FROM (SELECT "JOB", "DEPTNO", SUM("SAL")
> FROM "SCOTT"."EMP"
> GROUP BY "JOB", "DEPTNO"
> ORDER BY "DEPTNO" NULLS LAST, "JOB" NULLS LAST) AS "t0"] on JDBC sub-schema 
> (state=,code=0)
> Caused by: java.sql.SQLSyntaxErrorException: user lacks privilege or object 
> not found: SAL
>  at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
>  at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
> {noformat}
> Note that ORDER BY is inside a sub-query, which I presume is invalid SQL for 
> hsqldb (and most other DBs).



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to