[
https://issues.apache.org/jira/browse/LENS-126?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14247819#comment-14247819
]
Sushil Mohanty commented on LENS-126:
-------------------------------------
{CODE}
Input Query :
SELECT (dim1 . date) dim1_date , sum((f . msr1)) msr1
FROM fact f
INNER JOIN dim1 dim1
WHERE ((dim1 . date) = '2014-11-25 00:00:00')
GROUP BY (dim1 . date), (dim2 . name)
ORDER BY dim1_date;
{CODE}
{CODE}
Final Rewritten Query :
SELECT (dim1___dim1 . date) dim1_date,
sum(sum_fact___f_msr1) msr1
FROM
(SELECT fact___f.dim1_id,
sum((fact___f . msr1)) AS sum_fact___f_msr1
FROM fact fact___f
WHERE fact___f.dim1_id IN
(SELECT dim1 .id
FROM dim1
WHERE ((dim1. date) = '2014-11-25 00:00:00'))
GROUP BY fact___f.dim1_id) fact___f
INNER JOIN dim1 dim1___dim1 ON ((fact___f . dim1_id) = (dim1___dim1 . id))
WHERE ((dim1___dim1 . date) = '2014-11-25 00:00:00')
GROUP BY (dim1___dim1 . date), (dim2 . name)
ORDER BY dim1_date ASC
{CODE}
> jdbc rewrite error while using alias name in order by
> -----------------------------------------------------
>
> Key: LENS-126
> URL: https://issues.apache.org/jira/browse/LENS-126
> Project: Apache Lens
> Issue Type: Bug
> Reporter: Raghavendra Singh
> Assignee: Sushil Mohanty
> Fix For: 2.0
>
> Attachments: LENS-126.patch
>
>
> for a query having:
> select col1 as alias1 . . . order by alias1 desc limit 10
> the rewritten query misses the alias name and is rewritten as:-
> order by desc limit 10
> error message:-
> {CODE}
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'desc limit 10'
> at line 1
> at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
> at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
> at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
> at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
> at com.mysql.jdbc.Connection.execSQL(Connection.java:3277)
> at com.mysql.jdbc.Connection.execSQL(Connection.java:3206)
> at com.mysql.jdbc.Statement.execute(Statement.java:727)
> at
> com.mchange.v2.c3p0.impl.NewProxyStatement.execute(NewProxyStatement.java:1006)
> at
> org.apache.lens.driver.jdbc.JDBCDriver$QueryCallable.call(JDBCDriver.java:299)
> at
> org.apache.lens.driver.jdbc.JDBCDriver.executeInternal(JDBCDriver.java:694)
> at org.apache.lens.driver.jdbc.JDBCDriver.explain(JDBCDriver.java:573)
> ... 5 more
> {CODE}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)