You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Sergey Kozlov (JIRA)" <ji...@apache.org> on 2016/06/29 12:34:05 UTC

[jira] [Updated] (IGNITE-3397) Query with SUM and AVG fails if data type is integer

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

Sergey Kozlov updated IGNITE-3397:
----------------------------------
    Description: 
1. Extract everything from attached zip file into examples directory
2. Run {{CacheQueryFailures query4}}. It fails:
{noformat}
[15:32:35] Topology snapshot [ver=1, servers=1, clients=0, CPUs=8, heap=3.5GB]
>>> initialize 300 keys
>>> run query4, type: SqlFieldsQuery, query SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
[15:32:35] Ignite node stopped OK [uptime=00:00:00:485]
Exception in thread "main" javax.cache.CacheException: class org.apache.ignite.IgniteException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
	at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:682)
	at org.apache.ignite.examples.datagrid.CacheQueryFailures.runQuery(CacheQueryFailures.java:117)
	at org.apache.ignite.examples.datagrid.CacheQueryFailures.main(CacheQueryFailures.java:83)
	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:140)
Caused by: class org.apache.ignite.IgniteException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
	at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:811)
	at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:673)
	... 7 more
Caused by: class org.apache.ignite.IgniteCheckedException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
	at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:1787)
	at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:804)
	... 8 more
Caused by: javax.cache.CacheException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1058)
	at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:806)
	at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:804)
	at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
	at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:1769)
	... 9 more
Caused by: org.h2.jdbc.JdbcSQLException: SUM или AVG на недопустимом типе данных "SUM(INTCOL)"
SUM or AVG on wrong data type for "SUM(INTCOL)"; SQL statement:
SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ? [90015-175]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
	at org.h2.message.DbException.get(DbException.java:172)
	at org.h2.message.DbException.get(DbException.java:149)
	at org.h2.expression.Aggregate.optimize(Aggregate.java:408)
	at org.h2.command.dml.Select.prepare(Select.java:810)
	at org.h2.command.Parser.prepareCommand(Parser.java:240)
	at org.h2.engine.Session.prepareLocal(Session.java:436)
	at org.h2.engine.Session.prepareCommand(Session.java:379)
	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
	at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:70)
	at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:267)
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:366)
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1055)
	... 13 more
Process finished with exit code 1
{noformat}


  was:
1. Extract everything from attached zip file into examples directory
2. Run {{CacheQueryFailures query3}}. It fails:
{noformat}
[14:52:52] Ignite node started OK (id=2821d4cc)
[14:52:52] Topology snapshot [ver=1, servers=1, clients=0, CPUs=8, heap=3.5GB]
>>> initialize 300 keys
>>> run query3, type: SqlFieldsQuery, query SELECT COUNT(longCol), shortCol FROM AllTypes WHERE shortCol > ? GROUP BY shortCol
>>> Query: SqlFieldsQuery [sql=SELECT COUNT(longCol), shortCol FROM AllTypes WHERE shortCol > ? GROUP BY shortCol, args=[10000], collocated=false]
[14:52:52,517][ERROR][main][GridMapQueryExecutor] Failed to execute local query: GridQueryRequest [reqId=1, pageSize=1024, space=cache_0001, qrys=[GridCacheSqlQuery [qry=SELECT
COUNT(LONGCOL) __C0,
SHORTCOL __C1
FROM "cache_0001".ALLTYPES
WHERE SHORTCOL > ?1
GROUP BY SHORTCOL, params=[10000], paramIdxs=[0], paramsSize=1, cols={__C0=GridSqlType [type=5, scale=0, precision=19, displaySize=20, sql=BIGINT], __C1=GridSqlType [type=19, scale=0, precision=2147483647, displaySize=2147483647, sql=OTHER]}, alias=null]], topVer=AffinityTopologyVersion [topVer=1, minorTopVer=0], extraSpaces=null, parts=null]
class org.apache.ignite.IgniteCheckedException: Failed to execute SQL query.
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQuery(IgniteH2Indexing.java:847)
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQueryWithTimer(IgniteH2Indexing.java:870)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.onQueryRequest(GridMapQueryExecutor.java:454)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.onMessage(GridMapQueryExecutor.java:184)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.send(GridReduceQueryExecutor.java:1065)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:572)
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$2.iterator(IgniteH2Indexing.java:971)
	at org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:61)
	at org.apache.ignite.examples.datagrid.CacheQueryFailures.runQuery(CacheQueryFailures.java:120)
	at org.apache.ignite.examples.datagrid.CacheQueryFailures.main(CacheQueryFailures.java:83)
	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:140)
Caused by: org.h2.jdbc.JdbcSQLException: Шестнадцатиричная строка содержит нечетное количество символов: "10000"
Hexadecimal string with odd number of characters: "10000"; SQL statement:
SELECT
COUNT(LONGCOL) __C0,
SHORTCOL __C1
FROM "cache_0001".ALLTYPES
WHERE SHORTCOL > ?1
GROUP BY SHORTCOL [90003-175]
	at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
	at org.h2.message.DbException.get(DbException.java:172)
	at org.h2.message.DbException.get(DbException.java:149)
	at org.h2.util.StringUtils.convertHexToBytes(StringUtils.java:944)
	at org.h2.value.Value.convertTo(Value.java:847)
	at org.h2.table.Table.compareTypeSave(Table.java:1068)
	at org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase.compareValues(GridH2IndexBase.java:143)
	at org.apache.ignite.internal.processors.query.h2.opt.GridH2IndexBase.compareRows(GridH2IndexBase.java:125)
	at org.apache.ignite.internal.processors.query.h2.opt.GridH2TreeIndex$ComparableRow.compareTo(GridH2TreeIndex.java:433)
	at org.apache.ignite.internal.processors.query.h2.opt.GridH2TreeIndex$ComparableRow.compareTo(GridH2TreeIndex.java:415)
	at org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap$AbstractIter.cmp(GridOffHeapSnapTreeMap.java:3454)
	at org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap$AbstractIter.pushFirst(GridOffHeapSnapTreeMap.java:3492)
	at org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap$AbstractIter.<init>(GridOffHeapSnapTreeMap.java:3440)
	at org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap$EntryIter.<init>(GridOffHeapSnapTreeMap.java:3303)
	at org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap$EntryIter.<init>(GridOffHeapSnapTreeMap.java:3285)
	at org.apache.ignite.internal.util.offheap.unsafe.GridOffHeapSnapTreeMap$SubMap$EntrySubSet.iterator(GridOffHeapSnapTreeMap.java:4013)
	at java.util.AbstractMap$2$1.<init>(AbstractMap.java:378)
	at java.util.AbstractMap$2.iterator(AbstractMap.java:377)
	at org.apache.ignite.internal.processors.query.h2.opt.GridH2TreeIndex.doFind(GridH2TreeIndex.java:324)
	at org.apache.ignite.internal.processors.query.h2.opt.GridH2TreeIndex.find(GridH2TreeIndex.java:283)
	at org.h2.index.BaseIndex.find(BaseIndex.java:126)
	at org.h2.index.IndexCursor.find(IndexCursor.java:159)
	at org.h2.table.TableFilter.next(TableFilter.java:328)
	at org.h2.command.dml.Select.queryGroupSorted(Select.java:165)
	at org.h2.command.dml.Select.queryWithoutCache(Select.java:625)
	at org.h2.command.dml.Query.query(Query.java:297)
	at org.h2.command.dml.Query.query(Query.java:284)
	at org.h2.command.dml.Query.query(Query.java:36)
	at org.h2.command.CommandContainer.query(CommandContainer.java:91)
	at org.h2.command.Command.executeQuery(Command.java:196)
	at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:106)
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQuery(IgniteH2Indexing.java:844)
	... 14 more
Exception in thread "main" javax.cache.CacheException: Failed to run map query remotely.
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:585)
	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$2.iterator(IgniteH2Indexing.java:971)
	at org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:61)
	at org.apache.ignite.examples.datagrid.CacheQueryFailures.runQuery(CacheQueryFailures.java:120)
	at org.apache.ignite.examples.datagrid.CacheQueryFailures.main(CacheQueryFailures.java:83)
	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:140)
Caused by: javax.cache.CacheException: Failed to execute map query on the node: 2821d4cc-6679-49ac-b227-4548fd289c60, class org.apache.ignite.IgniteCheckedException:Failed to execute SQL query.
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.fail(GridReduceQueryExecutor.java:257)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.onFail(GridReduceQueryExecutor.java:247)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.onMessage(GridReduceQueryExecutor.java:228)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.sendError(GridMapQueryExecutor.java:525)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.onQueryRequest(GridMapQueryExecutor.java:501)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridMapQueryExecutor.onMessage(GridMapQueryExecutor.java:184)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.send(GridReduceQueryExecutor.java:1065)
	at org.apache.ignite.internal.processors.query.h2.twostep.GridReduceQueryExecutor.query(GridReduceQueryExecutor.java:572)
	... 9 more
[14:52:52] Ignite node stopped OK [uptime=00:00:00:473]
{noformat}

Same query without {{WHERE}} clause works fine

        Summary: Query with SUM and AVG fails if data type is integer  (was: CLONE - Aggregation query with where clause failed)

> Query with SUM and AVG fails if data type is integer
> ----------------------------------------------------
>
>                 Key: IGNITE-3397
>                 URL: https://issues.apache.org/jira/browse/IGNITE-3397
>             Project: Ignite
>          Issue Type: Bug
>          Components: cache
>    Affects Versions: 1.6
>            Reporter: Sergey Kozlov
>            Priority: Critical
>
> 1. Extract everything from attached zip file into examples directory
> 2. Run {{CacheQueryFailures query4}}. It fails:
> {noformat}
> [15:32:35] Topology snapshot [ver=1, servers=1, clients=0, CPUs=8, heap=3.5GB]
> >>> initialize 300 keys
> >>> run query4, type: SqlFieldsQuery, query SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
> [15:32:35] Ignite node stopped OK [uptime=00:00:00:485]
> Exception in thread "main" javax.cache.CacheException: class org.apache.ignite.IgniteException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
> 	at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:682)
> 	at org.apache.ignite.examples.datagrid.CacheQueryFailures.runQuery(CacheQueryFailures.java:117)
> 	at org.apache.ignite.examples.datagrid.CacheQueryFailures.main(CacheQueryFailures.java:83)
> 	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:140)
> Caused by: class org.apache.ignite.IgniteException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:811)
> 	at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:673)
> 	... 7 more
> Caused by: class org.apache.ignite.IgniteCheckedException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:1787)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:804)
> 	... 8 more
> Caused by: javax.cache.CacheException: Failed to parse query: SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ?
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1058)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:806)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:804)
> 	at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
> 	at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:1769)
> 	... 9 more
> Caused by: org.h2.jdbc.JdbcSQLException: SUM или AVG на недопустимом типе данных "SUM(INTCOL)"
> SUM or AVG on wrong data type for "SUM(INTCOL)"; SQL statement:
> SELECT SUM(intCol), AVG(intCol) FROM AllTypes WHERE shortCol >= ? [90015-175]
> 	at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
> 	at org.h2.message.DbException.get(DbException.java:172)
> 	at org.h2.message.DbException.get(DbException.java:149)
> 	at org.h2.expression.Aggregate.optimize(Aggregate.java:408)
> 	at org.h2.command.dml.Select.prepare(Select.java:810)
> 	at org.h2.command.Parser.prepareCommand(Parser.java:240)
> 	at org.h2.engine.Session.prepareLocal(Session.java:436)
> 	at org.h2.engine.Session.prepareCommand(Session.java:379)
> 	at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
> 	at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:70)
> 	at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:267)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.prepareStatement(IgniteH2Indexing.java:366)
> 	at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1055)
> 	... 13 more
> Process finished with exit code 1
> {noformat}



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