Apache ignit:SQL 语句创建表中的语法错误
Posted
技术标签:
【中文标题】Apache ignit:SQL 语句创建表中的语法错误【英文标题】:Apache ignit : Syntax error in SQL statement create table 【发布时间】:2018-02-28 16:20:35 【问题描述】:我希望索引我的数据 apache ignite,然后使用 spring data ignite。 但是我在启动我的项目时遇到了问题; ignite无法创建sql表。
我认为这可能是属性名称的错误,但我更改了索引属性,但总是遇到相同的错误。
我使用数据库 mongoDb,是否兼容此功能?
org.apache.ignite.IgniteCheckedException: Failed to register query type: QueryTypeDescriptorImpl [cacheName=CacheVehiculeImmat, name=VehiculeImmat, schemaName=CacheVehiculeImmat, tblName=VEHICULEIMMAT, fields=ID=class java.lang.String, OBJECTID=class java.lang.String, idxs=VEHICULEIMMAT_OBJECTID_IDX=QueryIndexDescriptorImpl [name=VEHICULEIMMAT_OBJECTID_IDX, type=SORTED, inlineSize=-1], VEHICULEIMMAT_ID_IDX=QueryIndexDescriptorImpl [name=VEHICULEIMMAT_ID_IDX, type=SORTED, inlineSize=-1], fullTextIdx=null, keyCls=class java.lang.String, valCls=class java.lang.Object, keyTypeName=java.lang.String, valTypeName=com.persist.petiteflotte.model.VehiculeImmat, valTextIdx=false, typeId=51183916, affKey=null, keyFieldName=null, valFieldName=null, obsolete=false]
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.registerType(IgniteH2Indexing.java:1709) ~[ignite-indexing-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.query.GridQueryProcessor.registerCache0(GridQueryProcessor.java:1512) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart0(GridQueryProcessor.java:779) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.query.GridQueryProcessor.onCacheStart(GridQueryProcessor.java:840) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.cache.GridCacheProcessor.startCache(GridCacheProcessor.java:1113) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.cache.GridCacheProcessor.prepareCacheStart(GridCacheProcessor.java:1816) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.cache.GridCacheProcessor.startCachesOnLocalJoin(GridCacheProcessor.java:1681) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.initCachesOnLocalJoin(GridDhtPartitionsExchangeFuture.java:725) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture.init(GridDhtPartitionsExchangeFuture.java:613) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.cache.GridCachePartitionExchangeManager$ExchangeWorker.body(GridCachePartitionExchangeManager.java:2279) ~[ignite-core-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:110) [ignite-core-2.3.0.jar:2.3.0]
at java.lang.Thread.run(Thread.java:748) [na:1.8.0_151]
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "CREATE TABLE ""CacheVehiculeImmat"".""VEHICULEIMMAT"" (_KEY VARCHAR INVISIBLE[*] NOT NULL,_VAL OTHER INVISIBLE,_VER OTHER INVISIBLE,""ID"" VARCHAR,""OBJECTID"" VARCHAR) ENGINE ""org.apache.ignite.internal.processors.query.h2.H2TableEngine"" "; expected "(, FOR, UNSIGNED, NOT, NULL, AS, DEFAULT, GENERATED, NOT, NULL, AUTO_INCREMENT, BIGSERIAL, SERIAL, IDENTITY, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE "CacheVehiculeImmat"."VEHICULEIMMAT" (_KEY VARCHAR INVISIBLE NOT NULL,_VAL OTHER INVISIBLE,_VER OTHER INVISIBLE,"ID" VARCHAR,"OBJECTID" VARCHAR) engine "org.apache.ignite.internal.processors.query.h2.H2TableEngine" [42001-193]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345) ~[h2-1.4.193.jar:1.4.193]
at org.h2.message.DbException.getSyntaxError(DbException.java:205) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.getSyntaxError(Parser.java:537) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.read(Parser.java:3186) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.readIfMore(Parser.java:885) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.parseCreateTable(Parser.java:6043) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.parseCreate(Parser.java:4238) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.parsePrepared(Parser.java:362) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.parse(Parser.java:317) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.parse(Parser.java:293) ~[h2-1.4.193.jar:1.4.193]
at org.h2.command.Parser.prepareCommand(Parser.java:254) ~[h2-1.4.193.jar:1.4.193]
at org.h2.engine.Session.prepareLocal(Session.java:561) ~[h2-1.4.193.jar:1.4.193]
at org.h2.engine.Session.prepareCommand(Session.java:502) ~[h2-1.4.193.jar:1.4.193]
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1203) ~[h2-1.4.193.jar:1.4.193]
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:170) ~[h2-1.4.193.jar:1.4.193]
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:158) ~[h2-1.4.193.jar:1.4.193]
at org.apache.ignite.internal.processors.query.h2.H2TableEngine.createTable(H2TableEngine.java:65) ~[ignite-indexing-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.createTable(IgniteH2Indexing.java:1784) ~[ignite-indexing-2.3.0.jar:2.3.0]
at org.apache.ignite.internal.processors.query.h2.IgniteH2Indexing.registerType(IgniteH2Indexing.java:1702) ~[ignite-indexing-2.3.0.jar:2.3.0]
... 11 common frames omitted
这是我的代码:
CacheConfiguration cacheVehiculeImmat = new CacheConfiguration();
cacheVehiculeImmat.setName(CacheHash.CACHEVEHICULE);
cacheVehiculeImmat.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
cacheVehiculeImmat.setReadThrough(true);
cacheVehiculeImmat.setIndexedTypes(String.class, VehiculeImmat.class);
cacheVehiculeImmat.setWriteThrough(true);
cacheVehiculeImmat.setStoreKeepBinary(false);
cacheVehiculeImmat.setWriteBehindEnabled(true);
cacheVehiculeImmat.setCacheMode(CacheMode.REPLICATED);
Factory<SpringDataVehiculeDataStore> storeDataVehicule = FactoryBuilder.factoryOf(SpringDataVehiculeDataStore.class);
cacheVehiculeImmat.setCacheStoreFactory(storeDataVehicule);
我的模特:
@Document(collection = "vehicule")
public class VehiculeImmat implements Serializable
@Id
private String id=new ObjectId().toString();
@QuerySqlField(index = true)
private String objectId = UUID.randomUUID().toString();
我的数据存储:
public class SpringDataVehiculeDataStore extends CacheStoreAdapter<String, VehiculeImmat> implements LifecycleAware
private VehiculeRepository vehiculeRepository = null;
@Override
public VehiculeImmat load(String immat) throws CacheLoaderException
VehiculeImmat courtierEnterprise = vehiculeRepository.findByImmat(immat);
return courtierEnterprise;
@Override
public void write(Cache.Entry<? extends String, ? extends VehiculeImmat> entry) throws CacheWriterException
VehiculeImmat vehiculeImmat = entry.getValue();
vehiculeRepository.save(vehiculeImmat);
@Override
public void delete(Object o) throws CacheWriterException
VehiculeImmat vehiculeImmat = vehiculeRepository.findByImmat(String.valueOf(o));
vehiculeRepository.delete(vehiculeImmat);
@Override
public void start() throws IgniteException
vehiculeRepository = AppContext.getApplicationContext().getBean(VehiculeRepository.class);
public void loadCache(IgniteBiInClosure<String,VehiculeImmat> clo,
Object... args)
for(VehiculeImmat vehiculeImmat:vehiculeRepository.findAll())
clo.apply(vehiculeImmat.getImmat(),vehiculeImmat);
@Override
public void stop() throws IgniteException
你知道这个问题吗?
【问题讨论】:
这可能是在抱怨INVISIBLE
之后的[*]
,因为根据H2 syntax,这无效。
但是怎么去掉那个字符,我自己从来不加。知道是什么产生了它?
可能是org.apache.ignite.internal.processors.query.h2.H2TableEngine.createTable
方法,因此您必须与 Apache Ignite 人员交谈。
【参考方案1】:
这似乎是 H2 版本不匹配。 Ignite 2.3 构建在 H2 1.4.195 之上。但是,在您的堆栈跟踪中,我看到版本 1.4.193,它与 Ignite 2.3 不兼容。
请确保使用正确的 H2 版本。
【讨论】:
为什么 maven 2.3.0 ignite-indexing 依赖项包含 com.h2.database 1.4.193?我试图排除它并添加 maven 依赖项 1..4.195 但我得到一个错误> java.lang.ClassNotFoundException: org.h2.result.RowFactory Ignite 索引和 SQL 依赖于 H2 数据库,它是强制依赖,至少在今天是这样。以上是关于Apache ignit:SQL 语句创建表中的语法错误的主要内容,如果未能解决你的问题,请参考以下文章
Apache Zeppelin 与 Ignite 集成时出现“无法启动 Ignite 节点”错误
Hazelcast 是不是支持像 Apache Ignite 这样的 SQL 查询?