select * from customer where cust_city = 'Mumbai' allow filtering;
当我运行此查询时,结果只显示列名,而不是如果我在where子句中给出一个整数值,我得到输出。
select * from customer where payment_amt=7000 allow filtering;
表格数据
cust_code | agent_code | cust_city | cust_country | cust_name | grade | opening_amt | outstanding_amt | payment_amt | phone_no | receiveamt | working_area
-------------+--------------+---------------+----------------+---------------+-------+-------------+-----------------+-------------+----------------+------------+----------------
C00011 | A010 | Chennai | India | Sundariya | 3 | 7000 | 11000 | 7000 | PPHGRTS | 1000 | Chennai
C00012 | A012 | San Jose | USA | Steven | 1 | 5000 | 3000 | 9000 | KRFYGJK | 000 | San Jose
C00013 | A003 | London | UK | Holmes | 2 | 6000 | 4000 | 7000 | BBBBBBB | 000 | London
C00014 | A001 | Bangalore | India | Rangarappa | 2 | 8000 | 12000 | 7000 | AAAATGF | 1000 | Bangalore
C00018 | A005 | Brisban | Australia | Fleming | 2 | 7000 | 5000 | 9000 | NHBGVFC | 000 | Brisban
C00015 | A003 | London | UK | Stuart | 1 | 6000 | 11000 | 3000 | GFSGERS | 000 | London
C00004 | A005 | Brisban | Australia | Winston | 1 | 5000 | 6000 | 7000 | AAAAAAA | 000 | Brisban
C00022 | A002 | Mumbai | India | Avinash | 2 | 7000 | 9000 | 9000 | 113-12345678 | 1000 | Mumbai
C00001 | A008 | New York | USA | Micheal | 2 | 3000 | 6000 | 2000 | CCCCCCC | 000 | New York
C00021 | A005 | Brisban | Australia | Jacks | 1 | 7000 | 7000 | 7000 | WERTGDF | 000 | Brisban
C00023 | A006 | London | UK | Karl | 0 | 4000 | 3000 | 7000 | AAAABAA | 000 | London
C00006 | A004 | Torento | Canada | Shilton | 1 | 10000 | 11000 | 6000 | DDDDDDD | 000 | Torento
C00008 | A004 | Torento | Canada | Karolina | 1 | 7000 | 5000 | 9000 | HJKORED | 000 | Torento
C00016 | A007 | Bangalore | India | Venkatpati | 2 | 8000 | 12000 | 7000 | JRTVFDD | 1000 | Bangalore
C00002 | A008 | New York | USA | Bolt | 3 | 5000 | 3000 | 9000 | DDNRDRH | 000 | New York
C00019 | A010 | Chennai | India | Yearannaidu | 1 | 8000 | 8000 | 7000 | ZZZZBFV | 000 | Chennai
C00010 | A009 | Hampshair | UK | Charles | 3 | 6000 | 5000 | 5000 | MMMMMMM | 000 | Hampshair
C00009 | A002 | Mumbai | India | Ramesh | 3 | 8000 | 12000 | 3000 | Phone No | 000 | Mumbai
C00020 | A008 | New York | USA | Albert | 3 | 5000 | 6000 | 6000 | BBBBSBB | 000 | New York
C00017 | A007 | Bangalore | India | Srinivas | 2 | 8000 | 9000 | 3000 | AAAAAAB | 000 | Bangalore
C00025 | A011 | Bangalore | India | Ravindran | 2 | 5000 | 8000 | 4000 | AVAVAVA | 000 | Bangalore
C00005 | A002 | Mumbai | India | Sasikant | 1 | 7000 | 11000 | 7000 | 147-25896312 | 1000 | Mumbai
C00003 | A004 | Torento | Canada | Martin | 2 | 8000 | 8000 | 7000 | MJYURFD | 000 | Torento
C00024 | A006 | London | UK | Cook | 2 | 4000 | 6000 | 7000 | FSDDSDF | 000 | London
C00007 | A010 | Chennai | India | Ramanathan | 1 | 7000 | 9000 | 9000 | GHRDWSD | 1000 | Chennai
输出1(字符串)
cust_code | agent_code | cust_city | cust_country | cust_name | grade | opening_amt | outstanding_amt | payment_amt | phone_no | receive_amt | working_area
-----------+------------+-----------+--------------+-----------+-------+-------------+-----------------+-------------+----------+-------------+--------------
(0 rows)
输出2(整数)
cust_code | agent_code | cust_city | cust_country | cust_name | grade | opening_amt | outstanding_amt | payment_amt | phone_no | receive_amt | working_area
-------------+--------------+---------------+----------------+---------------+-------+-------------+-----------------+-------------+----------------+-------------+----------------
C00011 | A010 | Chennai | India | Sundariya | 3 | 7000 | 11000 | 7000 | PPHGRTS | 11000 | Chennai
C00013 | A003 | London | UK | Holmes | 2 | 6000 | 4000 | 7000 | BBBBBBB | 5000 | London
C00014 | A001 | Bangalore | India | Rangarappa | 2 | 8000 | 12000 | 7000 | AAAATGF | 11000 | Bangalore
C00004 | A005 | Brisban | Australia | Winston | 1 | 5000 | 6000 | 7000 | AAAAAAA | 8000 | Brisban
C00021 | A005 | Brisban | Australia | Jacks | 1 | 7000 | 7000 | 7000 | WERTGDF | 7000 | Brisban
C00023 | A006 | London | UK | Karl | 0 | 4000 | 3000 | 7000 | AAAABAA | 6000 | London
C00016 | A007 | Bangalore | India | Venkatpati | 2 | 8000 | 12000 | 7000 | JRTVFDD | 11000 | Bangalore
C00019 | A010 | Chennai | India | Yearannaidu | 1 | 8000 | 8000 | 7000 | ZZZZBFV | 7000 | Chennai
C00005 | A002 | Mumbai | India | Sasikant | 1 | 7000 | 11000 | 7000 | 147-25896312 | 11000 | Mumbai
C00003 | A004 | Torento | Canada | Martin | 2 | 8000 | 8000 | 7000 | MJYURFD | 7000 | Torento
C00024 | A006 | London | UK | Cook | 2 | 4000 | 6000 | 7000 | FSDDSDF | 9000 | London
(11 rows)
有人可以为此提供帮助。
答案 0 :(得分:1)
确保确保cust_city字段中没有前导和尾随空格
您正在使用允许过滤。小心。使用allow过滤执行此查询可能不是一个好主意,因为它可能会使用大量的计算资源,并且可能由于超时而无法返回任何结果。不要在生产中使用allow过滤阅读有关使用ALLOW FILTERING
的datastax文档https://docs.datastax.com/en/cql/3.3/cql/cql_reference/select_r.html?hl=allow,filter
您应该在cust_city
字段上创建索引。
CREATE INDEX cust_city_index ON customer (cust_city);
现在,使用cust_city过滤的选择查询会更快。
何时不使用索引?