简体   繁体   English

在 Apache Ignite 中删除并重新创建表

[英]Delete and recreate table in Apache Ignite

I am having a problem when I want to DROP a table and recreate it in APACHE IGNITE;当我想删除一个表并在DROP IGNITE 中重新创建它时,我遇到了问题; I am using a combination of REST API and PyIgnite to perform the operations.我正在使用 REST API 和 PyIgnite 的组合来执行操作。 IGNITE says the table do not exists, however it does not let me recreate it saying that it exists IGNITE 说该表不存在,但是它不允许我重新创建它说它存在

>>> DROP_QUERY_ALERT="DROP TABLE alerts"
>>> client.sql(DROP_QUERY_ALERT)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pyignite/client.py", line 404, in sql
    raise SQLError(result.message)
pyignite.exceptions.SQLError: Table doesn't exist: ALERTS
>>> CREATE_ALERT_QUERY = '''CREATE TABLE storage.alerts (
...         id VARCHAR PRIMARY KEY,
...         name VARCHAR,
...         address_field VARCHAR,
...         create_on TIMESTAMP,
...         integration VARCHAR,
...         alert VARCHAR,
...     ) WITH "CACHE_NAME=storage"'''
>>> client.sql(CREATE_ALERT_QUERY)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pyignite/client.py", line 404, in sql
    raise SQLError(result.message)
pyignite.exceptions.SQLError: Table already exists: ALERTS
>>> 

If I try to make a query, it also fails:如果我尝试进行查询,它也会失败:

>>> N_ALERT_QUERY = '''SELECT * FROM alerts'''
>>> result = client.sql(N_ALERT_QUERY, include_field_names=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pyignite/client.py", line 404, in sql
    raise SQLError(result.message)
pyignite.exceptions.SQLError: Failed to parse query. Table "ALERTS" not found; SQL statement:
SELECT * FROM alerts [42102-197]
>>> 

I am lost since this seemed to work before, but now I am unable to continue.我迷路了,因为这似乎以前有效,但现在我无法继续。 Is this a bug, a known behavior?这是一个错误,一个已知的行为吗? Am I missing something?我错过了什么吗?

Thank you.谢谢你。

It may be a known behavior :这可能是一种已知行为

Note, however, that the cache we create can not be dropped with DDL command.但是请注意,我们创建的缓存不能使用 DDL 命令删除。 … It should be deleted as any other key-value cache. …它应该像任何其他键值缓存一样被删除。

After some search and trying, I finally found that there was indeed a table by executing the following query:经过一番搜索和尝试,通过执行以下查询,我终于发现确实有一个表:

SHOW_TABLES_QUERY="SELECT * FROM INFORMATION_SCHEMA.TABLES"

It turns out that IGNITE do not drop a table if it has at least a records, as it was in this case ( http://apache-ignite-users.70518.x6.nabble.com/Table-not-getting-dropped-td27957.html ).事实证明,如果 IGNITE 至少有一个记录,它不会删除一个表,就像在这种情况下一样( http://apache-ignite-users.70518.x6.nabble.com/Table-not-getting-dropped -td27957.html )。

I deleted the records, and dropped the table.我删除了记录,并删除了表。 It took some minutes, but then I was able to recreate the table.花了几分钟,但后来我能够重新创建表。

Some of the confusion in my case was related to the fact that TABLE_NAME should have been replaced with <cachename>.TABLE_NAME when performing the drop query:在我的案例中,一些混淆与执行删除查询时TABLE_NAME应该被替换为<cachename>.TABLE_NAME的事实有关:

DROP_QUERY_ALERT="DROP TABLE storage.alerts"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM