cassandra - 通过 cassandra 在 Zeppelin 中读取数据
问题描述
我在 Cassandra 的一张桌子上有问题。
CREATE TABLE tfm.foehis (hooe text, hodtac int, hohrac int, hoclic text, hocdan text, hocdrs text, hocdsl text, hocol text, hocpny text, hodesf text, hodtcl int, hodtcm int, hodtea int, hodtra int, hodtrc int, hodtto date, hodtua int, hohrcl int, hohrcm int, hohrea int, hohrra int, hohrrc int, hohrua int, holinh text, holinr int, honrac int, honumr int, hoobs text, hotdsc int, hotour text, hotpac text, housca text, houscl text, huscm text, housea text, houser text, housra text, housrc text,PRIMARY KEY ((hooe, hodtac, hohrac), hoclic)) WITH CLUSTERING ORDER BY (hoclic ASC)
AND bloom_filter_fp_chance = 0.01
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
AND max_index_interval = 2048
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99PERCENTILE';
当我尝试进行查询时出现一些错误。
cqlsh> select housca from tfm.foehis where hoclic=1101;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Invalid INTEGER constant (1101) for "hoclic" of type text"
cqlsh> select housca from tfm.foehis where hoclic=MOBIDI;
SyntaxException: line 1:49 no viable alternative at input ';' (...from tfm.foehis where hoclic=[MOBIDI];)
cqlsh> select * from tfm.foehis where hoclic=MOBIDI;
SyntaxException: line 1:44 no viable alternative at input ';' (...from
tfm.foehis where hoclic=[MOBIDI];)
cqlsh> select * from tfm.foehis where hoclic=1101;
InvalidRequest: Error from server: code=2200 [Invalid query] message="Invalid INTEGER constant (1101) for "hoclic" of type text"
甚至 1101 和 MOBIDI 都是hoclic
.
在 Zeppelin 中,当我使用select * from tfm.foehis;
出现所有数据时,我可以制作我想要的图形,但是当我引入这个新语句时select * from tfm.foehis where hoclic="${CLIENT=1101|MOBIDI}";
出现这个错误。
com.datastax.driver.core.exceptions.SyntaxError: line 1:46 no viable
alternative at input ';' (...from tfm.foehis where hoclic=["singl]e";)
at
com.datastax.driver.core.exceptions.SyntaxError.copy(SyntaxError.java:58)
at com.datastax.driver.core.exceptions.SyntaxError.copy(SyntaxError.java:24)
...
我认为问题是表的主键的定义,但我不知道如何解决它
解决方案
文本字段必须包含在单引号中,而不是包含在双引号中!并且根本没有使用引号 - 就像你的例子一样......
你的例子应该写成
select housca from tfm.foehis where hoclic='1101';
select housca from tfm.foehis where hoclic='MOBIDI';
请参阅CQL 文字的定义。
推荐阅读
- javascript - 我正在尝试通过显示进度条定期更改图像?
- database - MongoDB - 从数组中的所有匹配对象中获取一个字段?
- arrays - array.length 函数在打字稿中没有输出正确的值
- react-native - 如何在 React Native JSX 中将两个用户连接到一个房间
- mysql - 使用 CONNECT 引擎和 unixODBC 从 MariaDB 连接到 MSSQL 时出现登录超时错误
- terraform - 您如何使用 Packer 和 Terraform 管理图像版本?
- javascript - 我可以轻松地将已安装的 Bit 组件“弹出”到本地项目中以删除包依赖吗?
- apache - 为什么我收到错误消息“参数不匹配:mod_evasive”?
- python - Python中贪心方法的硬币找零问题
- visual-studio - Windows 窗体和 Visual Studio 上的 Program.cs 之间的链接