Joining two result sets into one

空扰寡人 提交于 2020-01-14 14:05:59

问题


I wanted to know if there's a way to join two or more result sets into one.
I actually need to execute more than one query and return just one result set. I can't use the UNION or the JOIN operators because I'm working with Cassandra (CQL)
Thanks in advance !


回答1:


Framework like Playorm provide support for JOIN (INNER and LEFT JOINs)queries in Cassandra.

http://buffalosw.com/wiki/Command-Line-Tool/

You may see more examples at:

https://github.com/deanhiller/playorm/blob/master/src/test/java/com/alvazan/test/TestJoins.java




回答2:


If your wanting to query multiple rows within the same column family you can use the IN keyword:

SELECT * FROM testCF WHERE key IN ('rowKeyA', 'rowKeyB', 'rowKeyZ') LIMIT 10;

This will get you back 10 results from each row.

If your needing to join results from different CFs, or query with differing WHERE clauses, then you need to run multiple queries and merge the results in code - cassandra doesn't cater for that kind of thing.




回答3:


PlayOrm can do joins, but you may need to have PlayOrm partitioning on so you still scale. (ie. you dont' want to join 1 billion rows with 1 billion rows). Typically instead you do a join of one partition with another partition or a partition on the Account table joining a partition on the Users table. ie. make sure you design for scale still.



来源:https://stackoverflow.com/questions/15760684/joining-two-result-sets-into-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!