This is regarding an issue I am facing while querying Cassandra from Apache Spark.
The normal query from Spark works fine without any issues , however when I query with a condition which is the key I get the below error. Initially I tried querying for a composite key column family and it was also giving the same issue as below.
"Caused by: InvalidRequestException(why:empid cannot be restricted by more than one relation if it includes an Equal)"
Column Family:
CREATE TABLE emp (
empID int,
deptID int,
first_name varchar,
last_name varchar,
PRIMARY KEY (empID));
Column Family Contents:
empID, deptID, first_name, last_name
104, 15, 'jane', 'smith'
Sample SCALA Code:
val job=new Job()
job.setInputFormatClass(classOf[CqlPagingInputFormat])
val host: String = "localhost"
val port: String = "9160"
ConfigHelper.setInputInitialAddress(job.getConfiguration(), host)
ConfigHelper.setInputRpcPort(job.getConfiguration(), port)
ConfigHelper.setInputColumnFamily(job.getConfiguration(), "demodb", "emp")
ConfigHelper.setInputPartitioner(job.getConfiguration(), "Murmur3Partitioner")
CqlConfigHelper.setInputColumns(job.getConfiguration(), "empid,deptid,first_name,last_name")
//CqlConfigHelper.setInputCQLPageRowSize(job.getConfiguration(), limit.toString)
CqlConfigHelper.setInputWhereClauses(job.getConfiguration(),"empid='104'")
// Make a new Hadoop RDD
val casRdd = sc.newAPIHadoopRDD(job.getConfiguration(),
classOf[CqlPagingInputFormat],
classOf[Map[String, ByteBuffer]],
classOf[Map[String, ByteBuffer]])
I kindly request you to let me know if there is any work around for this kind of scenario as I am struggling to overcome this issue for the past few days.
Thanks