ignite-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Mashenkov (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (IGNITE-4247) Table aliases not supported for SqlQuery
Date Tue, 29 Nov 2016 14:16:58 GMT

    [ https://issues.apache.org/jira/browse/IGNITE-4247?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15702160#comment-15702160
] 

Andrew Mashenkov edited comment on IGNITE-4247 at 11/29/16 2:16 PM:
--------------------------------------------------------------------

H2Indexing.generateQuery() method should provide correct column names in "SELECT" part of
query. The correct way is analyze "FROM" part of query, choose suitable alias and rewrite
"SELECT" part with correct alias. But it is not obvious how to choose right alias if multiple
tables or subquery is present in "FROM" part.

Fix in PR allow alias to be provided as an argument.


was (Author: amashenkov):
H2Indexing.generateQuery() method should provide correct column names in "SELECT" part of
query. The correct way is analyze "FROM" part of query, choose suitable alias and rewrite
"SELECT" part with correct alias. 

> Table aliases not supported for SqlQuery
> ----------------------------------------
>
>                 Key: IGNITE-4247
>                 URL: https://issues.apache.org/jira/browse/IGNITE-4247
>             Project: Ignite
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.7
>            Reporter: Valentin Kulichenko
>            Assignee: Andrew Mashenkov
>             Fix For: 2.0
>
>
> Here is the example of the query:
> {code}
> from Person p where p.salary > ? and p.salary <= ?
> {code}
> Ignite is not aware of the alias and incorrectly appends the SELECT statement, which
causes this exception:
> {noformat}
> Exception in thread "main" javax.cache.CacheException: Failed to parse query: SELECT
"CacheQueryExamplePersons".Person._key, "CacheQueryExamplePersons".Person._val from Person
p where salary > ? and salary <= ?
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1217)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1123)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:813)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:811)
> 	at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:1760)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:811)
> 	at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:733)
> 	at org.apache.ignite.examples.datagrid.CacheQueryExample.sqlQuery(CacheQueryExample.java:176)
> 	at org.apache.ignite.examples.datagrid.CacheQueryExample.main(CacheQueryExample.java:116)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
> Caused by: org.h2.jdbc.JdbcSQLException: Column "CacheQueryExamplePersons.PERSON._KEY"
not found; SQL statement:
> SELECT "CacheQueryExamplePersons".Person._key, "CacheQueryExamplePersons".Person._val
from Person p where salary > ? and salary <= ? [42122-191]
> 	at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
> 	at org.h2.message.DbException.get(DbException.java:179)
> 	at org.h2.message.DbException.get(DbException.java:155)
> 	at org.h2.expression.ExpressionColumn.optimize(ExpressionColumn.java:147)
> 	at org.h2.command.dml.Select.prepare(Select.java:852)
> 	at org.h2.command.Parser.prepareCommand(Parser.java:257)
> 	at org.h2.engine.Session.prepareLocal(Session.java:560)
> 	at org.h2.engine.Session.prepareCommand(Session.java:501)
> 	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1188)
> 	at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:73)
> 	at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:276)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:410)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1201)
> 	... 14 more
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message