【问题标题】:"no viable alternative at input" error when querying cassndra table查询 cassndra 表时出现“输入时没有可行的替代方案”错误
【发布时间】:2017-09-15 00:30:50
【问题描述】:

我在 Cassandra 有一张这样的桌子:

CREATE TABLE vroc.sensor_data (
    dpnode text,
    year int,
    month int,
    day int,
    data_timestamp bigint,
    data_sensor text,
    dsnode text,
    data_quality double,
    data_value blob,
    PRIMARY KEY ((dpnode, year, month, day), data_timestamp, data_sensor, dsnode)
) WITH read_repair_chance = 0.0
   AND dclocal_read_repair_chance = 0.1
   AND gc_grace_seconds = 864000
   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 default_time_to_live = 0
   AND speculative_retry = '99PERCENTILE'
   AND min_index_interval = 128
   AND max_index_interval = 2048
   AND crc_check_chance = 1.0;

但是,当我运行以下查询时:

SELECT dpnode, "year", "month", "day", data_timestamp, data_sensor, dsnode, data_quality, data_value
FROM vroc.sensor_data 
WHERE dpnode="PSACAB" and "year"=2016 and "month"=11 and day=28;

我得到了这个例外:

com.datastax.driver.core.exceptions.SyntaxError: line 2:44 no viable alternative at input 'and' (...FROM vroc.sensor_data where dpnode=["PSACA]B" and...)
  com.datastax.driver.core.exceptions.SyntaxError: line 2:44 no viable alternative at input 'and' (...FROM vroc.sensor_data where dpnode=["PSACA]B" and...)

我不确定我在这里做错了什么?

【问题讨论】:

    标签: cassandra datastax


    【解决方案1】:

    这应该可以解决问题:

    select dpnode, year, month, day, data_timestamp, data_sensor, dsnode, data_quality, data_value from vroc.sensor_data where dpnode='PSACAB' and year = 2016 and month = 1 and day = 28;
    

    基本上字符串应该用'转义

    【讨论】:

      猜你喜欢
      • 2017-01-07
      • 2016-01-14
      • 1970-01-01
      • 2022-11-04
      • 2020-08-10
      • 2013-08-26
      • 2014-10-01
      • 2021-08-25
      • 1970-01-01
      相关资源
      最近更新 更多