You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ignite.apache.org by "Alexander Paschenko (JIRA)" <ji...@apache.org> on 2017/06/13 00:09:00 UTC
[jira] [Comment Edited] (IGNITE-5464) DML: Can not insert arrays
[ https://issues.apache.org/jira/browse/IGNITE-5464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16047256#comment-16047256 ]
Alexander Paschenko edited comment on IGNITE-5464 at 6/13/17 12:08 AM:
-----------------------------------------------------------------------
I've done a quick investigation. This happens because Ignite treats all non primitive arrays declared in query entity as {{OTHER}} (i.e. *Object*) when preparing {{CREATE TABLE}} triggered by cache registration while H2 on {{PreparedStatement.setObject}} call internally always treats arrays as such, that's why this internal error of type conversions occurs. Will focus on this when I'm able to.
was (Author: al.psc):
I've done a quick investigation. This happens because Ignite treats all non primitive arrays as {{OTHER}} (i.e. *Object*) while H2 on {{PreparedStatement.setObject}} call internally always treats arrays as such, that's why this internal error of type conversions occurs. Will focus on this when I'm able to.
> DML: Can not insert arrays
> --------------------------
>
> Key: IGNITE-5464
> URL: https://issues.apache.org/jira/browse/IGNITE-5464
> Project: Ignite
> Issue Type: Bug
> Components: sql
> Affects Versions: 2.0
> Reporter: Pavel Tupitsyn
> Assignee: Alexander Paschenko
> Fix For: 2.1
>
>
> Reproducer:
> {code}
> QueryEntity queryEntity = new QueryEntity(Integer.class.getName(), Integer[].class.getName());
> queryEntity.setTableName("ints");
> CacheConfiguration ccfg = new CacheConfiguration().setName("foo").setQueryEntities(Arrays.asList(queryEntity));
> IgniteCache<Integer, Integer[]> cache = ignite.createCache(ccfg);
> cache.put(1, new Integer[] {1, 2}); // works
> cache.query(new SqlFieldsQuery("insert into ints (_key, _val) values (?, ?)")
> .setArgs(1, new Integer[] {1, 2})).getAll(); // throws
> {code}
> Exception:
> {code}
> Exception in thread "main" javax.cache.CacheException: class org.apache.ignite.IgniteException: Failed to execute SQL query.
> at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:818)
> at TestDml.main(TestDml.java:34)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
> Caused by: class org.apache.ignite.IgniteException: Failed to execute SQL query.
> at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor$3.iterator(DmlStatementsProcessor.java:356)
> at org.apache.ignite.internal.processors.cache.QueryCursorImpl.iterator(QueryCursorImpl.java:94)
> at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.doInsert(DmlStatementsProcessor.java:827)
> at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.executeUpdateStatement(DmlStatementsProcessor.java:369)
> at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFields(DmlStatementsProcessor.java:164)
> at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor.updateSqlFieldsTwoStep(DmlStatementsProcessor.java:198)
> at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.queryTwoStep(IgniteH2Indexing.java:1659)
> at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:1659)
> at org.apache.ignite.internal.processors.query.GridQueryProcessor$4.applyx(GridQueryProcessor.java:1657)
> at org.apache.ignite.internal.util.lang.IgniteOutClosureX.apply(IgniteOutClosureX.java:36)
> at org.apache.ignite.internal.processors.query.GridQueryProcessor.executeQuery(GridQueryProcessor.java:2103)
> at org.apache.ignite.internal.processors.query.GridQueryProcessor.queryTwoStep(GridQueryProcessor.java:1657)
> at org.apache.ignite.internal.processors.cache.IgniteCacheProxy.query(IgniteCacheProxy.java:806)
> ... 6 more
> Caused by: class org.apache.ignite.IgniteCheckedException: Failed to execute SQL query.
> at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQuery(IgniteH2Indexing.java:1226)
> at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQueryWithTimer(IgniteH2Indexing.java:1278)
> at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.access$1300(IgniteH2Indexing.java:241)
> at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$4.iterator(IgniteH2Indexing.java:1081)
> at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing$4.iterator(IgniteH2Indexing.java:1069)
> at org.apache.ignite.internal.processors.query.h2.DmlStatementsProcessor$3.iterator(DmlStatementsProcessor.java:353)
> ... 18 more
> Caused by: org.h2.jdbc.JdbcSQLException: Hexadecimal string contains non-hex character: "(1, 2)"; SQL statement:
> SELECT
> TABLE._KEY,
> TABLE._VAL
> FROM TABLE(_KEY INTEGER=(?1,), _VAL OTHER=(?2,)) [90004-195]
> 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.util.StringUtils.convertHexToBytes(StringUtils.java:946)
> at org.h2.value.Value.convertTo(Value.java:957)
> at org.h2.table.Column.convert(Column.java:167)
> at org.h2.expression.TableFunction.getTable(TableFunction.java:118)
> at org.h2.expression.TableFunction.getValue(TableFunction.java:41)
> at org.h2.table.FunctionTable.getValueResultSet(FunctionTable.java:218)
> at org.h2.table.FunctionTable.getResult(FunctionTable.java:189)
> at org.h2.index.FunctionIndex.find(FunctionIndex.java:50)
> at org.h2.index.BaseIndex.find(BaseIndex.java:128)
> at org.h2.index.IndexCursor.find(IndexCursor.java:169)
> at org.h2.table.TableFilter.next(TableFilter.java:468)
> at org.h2.command.dml.Select$LazyResultQueryFlat.fetchNextRow(Select.java:1452)
> at org.h2.result.LazyResult.hasNext(LazyResult.java:79)
> at org.h2.result.LazyResult.next(LazyResult.java:59)
> at org.h2.command.dml.Select.queryFlat(Select.java:519)
> at org.h2.command.dml.Select.queryWithoutCache(Select.java:625)
> at org.h2.command.dml.Query.queryWithoutCacheLazyCheck(Query.java:114)
> at org.h2.command.dml.Query.query(Query.java:352)
> at org.h2.command.dml.Query.query(Query.java:333)
> at org.h2.command.CommandContainer.query(CommandContainer.java:113)
> at org.h2.command.Command.executeQuery(Command.java:201)
> at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:111)
> at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.executeSqlQuery(IgniteH2Indexing.java:1219)
> ... 23 more
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)