I'm trying to use a SPARC SQL to query a table from a date range. For example, I am trying to run a SQL statement such as: SELECT * FROM trip WHERE utc_startdate> '' 2015-01-01 '' and UTC_startDate & lt; = '2015-12-31' and Depression_ID = 1 and Device_id = 1, when I run the query, no error is thrown, but when I have some expectations then I can not find any results without querying the query. Time is getting results back to I SetAppName ("SparkTest"). Set ("spark.executor.memory", "1g") .set ("" spark ". (" Spark.cassandra.connection.native.port "," 9042 ") .set (" spark.cassandra.connection.rpc JavaSparkContext Reference = New JavaSparkContext (sparkConf); JavaCasandra SQL Context sqlContext = New JavaCandra SQL Contex (reference); sqlContext.sqlContext () setKeyspace ("mykeyspace"); string sql = "SELECT * excursion" From WHERE utc_startdate> = '2015-01-01' and utc_startdate & lt; '2015-12-31' and deployment_id = 1 and device_id = 1 "; JavaSchemaRDD rdd = sqlContext.sql (SQL); & lt ; Line & gt; line = rdd.collect (); // rows.size () is zero when I expect it to be in E lines should be
schema:
create table tour (device_id bigint, deployment_id bigint, utc_startdate timestamp, other column .... primary key ( Device_id, deployment_id), Utc_startdate));
Any help would be appreciated by clustering order (utc_startdate asc).
What's your look like table schema (specifically, your primary key definition)? Without even seeing this, I am quite sure that you are seeing this behavior because you are not qualifying your query with the partition key. The rows will be filtered by date
using the allow
directive (assuming your clustering key is), but this is a large cluster or a large dataset Not a good solution.
Let's say you are asking users in a specific geographical area. If you use the area as a partition key, you can run this query, and this will work:
Select * From users where the area = 'California' And date & gt; = '2015-01- 01' and date & lt; = '2015-12-31';
Let's read Patrick McFaddin's article. There are some good examples that can help you.
No comments:
Post a Comment