【问题标题】:cqlsh 'Select' statement does not return the data that existscqlsh 'Select' 语句不返回存在的数据
【发布时间】:2018-11-06 11:21:42
【问题描述】:

我有以下 Cassandra 表:

CREATE TABLE myflights.flights_by_airport2 (
origin text,
dep_time timestamp,
fl_date timestamp,
airline_id int,
carrier text,
fl_num int,
PRIMARY KEY ((origin), dep_time)
) WITH CLUSTERING ORDER BY (dep_time ASC);


cqlsh:myflights> select * from flights_by_airport2 limit 5;

 origin | dep_time                        | airline_id | carrier | fl_date                         | fl_num
--------+---------------------------------+------------+---------+---------------------------------+--------
    MSY | 2012-01-01 05:57:00.000000+0000 |      19977 |      UA | 2012-01-01 00:00:00.000000+0000 |    275
    MSY | 2012-01-01 06:01:00.000000+0000 |      20409 |      B6 | 2012-01-01 00:00:00.000000+0000 |    110
    MSY | 2012-01-01 06:13:00.000000+0000 |      19790 |      DL | 2012-01-01 00:00:00.000000+0000 |    551
    MSY | 2012-01-01 06:45:00.000000+0000 |      19805 |      AA | 2012-01-01 00:00:00.000000+0000 |   1190
    MSY | 2012-01-01 06:46:00.000000+0000 |      19977 |      UA | 2012-01-01 00:00:00.000000+0000 |   1184

以下语句不返回任何数据:

cqlsh:myflights>  select * from flights_by_airport2 where origin = 'MSY';

 origin | dep_time | airline_id | carrier | fl_date | fl_num
--------+----------+------------+---------+---------+--------

(0 rows)

我在 Ubuntu 虚拟机上安装了单节点 Cassandra 和 Spark(DSE 6 集群)。

【问题讨论】:

  • 我会首先通过运行where origin contains 'MSY'来检查是否是空白问题
  • 我从源文件中删除了所有前导空格并刷新了 Cassandra 表。现在可以了。干杯!

标签: scala apache-spark cassandra apache-spark-sql datastax-enterprise


【解决方案1】:

由于我的评论已经产生了答案,我将把它作为答案发布:

我会先通过运行检查是否是空格问题

select * from flights_by_airport2 where origin contains 'MSY';

如果这仍然是一个问题,那么您可以尝试使用trim,或者只是清理数据。

【讨论】:

  • 我无法投票,因为我没有足够的积分。我希望我能够。非常感谢你帮助我。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-08-13
  • 1970-01-01
  • 2013-01-07
  • 2018-05-13
  • 2020-07-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多