Skip to content

Instantly share code, notes, and snippets.

@tzach
Last active August 15, 2016 12:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tzach/7d3a4540264418fdb15aa9fa159e0188 to your computer and use it in GitHub Desktop.
Save tzach/7d3a4540264418fdb15aa9fa159e0188 to your computer and use it in GitHub Desktop.
cqlsh>
CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };
use mykeyspace ;
CREATE TABLE users (user_id int PRIMARY KEY, fname text, lname text);
insert into users (user_id , fname, lname) values (1, 'tzach', 'livyatan');
insert into users (user_id , fname, lname) values (2, 'dor', 'laor');
insert into users (user_id , fname, lname) values (3, 'shlomi', 'laor');
insert into users (user_id , fname, lname) values (4, 'shlomi', 'livne');
insert into users (user_id , fname, lname) values (6, 'avi', 'kivity');
./presto-cli --server localhost:8080 --catalog hive --schema default
presto:default>
SELECT * FROM cassandra.mykeyspace.users where user_id >= 2 and user_id <= 3
-> ;
user_id | fname | lname
---------+--------+-------
2 | dor | laor
3 | shlomi | laor
(2 rows)
Query 20160627_072855_00002_knar7, FINISHED, 1 node
presto:default> SELECT * FROM cassandra.mykeyspace.users limit 1;
user_id | fname | lname
---------+-------+----------
1 | tzach | livyatan
@tzach
Copy link
Author

tzach commented Aug 15, 2016

Join example

cqlsh:mykeyspace> CREATE TABLE address (user_id int PRIMARY KEY, number int, street text, city text);
cqlsh:mykeyspace> insert into address (user_id , number, street) values (1, 'dizingof', 'tel aviv');
presto:default> select * from cassandra.mykeyspace.users us JOIN cassandra.mykeyspace.address ad ON us.user_id = ad.user_id;
 user_id | fname |  lname   | user_id |   city   | number |  street  
---------+-------+----------+---------+----------+--------+----------
       1 | tzach | livyatan |       1 | tel aviv |    100 | dizingof 
(1 row)

Query 20160815_115952_00019_8tuxd, FINISHED, 1 node
Splits: 5 total, 5 done (100.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment