You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by vatsal mevada <va...@live.com> on 2016/10/13 12:16:06 UTC
Execute SQL on Ignite cache of BinaryObjects
I am creating a cache of BinaryObject from spark a dataframe and then I want
to perform SQL on that ignite cache.
Here is my code where bank is the dataframe which contains three fields
(id,name and age):
/ val ic = new IgniteContext(sc, () => new IgniteConfiguration())
val cacheConfig = new CacheConfiguration[BinaryObject, BinaryObject]()
cacheConfig.setName("test123")
cacheConfig.setStoreKeepBinary(true)
cacheConfig.setIndexedTypes(classOf[BinaryObject],
classOf[BinaryObject])
val qe = new QueryEntity()
qe.setKeyType(TestKey)
qe.setValueType(TestValue)
val fields = new java.util.LinkedHashMap[String, String]()
fields.put("id", "java.lang.Long")
fields.put("name", "java.lang.String")
fields.put("age", "java.lang.Int")
qe.setFields(fields)
val qes = new java.util.ArrayList[QueryEntity]()
qes.add(qe)
cacheConfig.setQueryEntities(qes)
val cache = ic.fromCache[BinaryObject, BinaryObject](cacheConfig)
cache.savePairs(bank.rdd, (row: Bank, iContext: IgniteContext) => {
val keyBuilder = iContext.ignite().binary().builder("TestKey");
keyBuilder.setField("id", row.id);
val key = keyBuilder.build();
val valueBuilder = iContext.ignite().binary().builder("TestValue");
valueBuilder.setField("name", row.name);
valueBuilder.setField("age", row.age);
val value = valueBuilder.build();
(key, value);
}, true)/
Now I am trying to execute an SQL query like this:
/cache.sql("select age from TestValue")/
Which is failing with following exception:
/Caused by: org.h2.jdbc.JdbcSQLException: Column "AGE" not found; SQL
statement:
select age from TestValue [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) /
What am I doing wrong here?
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Execute-SQL-on-Ignite-cache-of-BinaryObjects-tp8269.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.
Re: Execute SQL on Ignite cache of BinaryObjects
Posted by vkulichenko <va...@gmail.com>.
Hi,
I responded on SO:
http://stackoverflow.com/questions/40019506/execute-sql-on-ignite-cache-of-binaryobjects
-Val
--
View this message in context: http://apache-ignite-users.70518.x6.nabble.com/Execute-SQL-on-Ignite-cache-of-BinaryObjects-tp8269p8281.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.