i have 2 tables:
CREATE TABLE ks.t1 (
colA text, colB int, colC bigint, colD timestamp,
PRIMARY KEY (( colA, colB ), colC)
)
and
CREATE TABLE ks.t2 (
colA text, colB int, colC bigint, colD timestamp, colE Boolean, colF text
PRIMARY KEY (( colA, colB ), colC)
)
I created the C* class in spark:
case class cl1(colA:String, colB:Int, colC:BigInt)
And populated with this:
val no30 = sc.cassandraTable[cl1]("ks","t1").select("colA","colB","colC")
And save it with this:
no30.saveToCassandra("ks","t2", SomeColumns("colA","colB","colC"))
Question:
colD, colE and colF have value null. Is there a way to set a default value?
Like for colE i want to set a false to all the rows.
I tried this approach but no success:
case class cl1(colA:String, colB:Int, colC:BigInt, colD:Boolean = false)
Populated with this:
val no30 = sc.cassandraTable[cl1]("ks","t1").select("colA","colB","colC")
And when tried to save with this:
no30.saveToCassandra("ks","t2", SomeColumns("colA","colB","colC","colD"))
It returned this:
java.lang.IllegalArgumentException: Failed to map constructor parameter expirationchanged in newoffer32 to a column of ks.t1
at com.datastax.spark.connector.mapper.DefaultColumnMapper$$anonfun$4$$anonfun$apply$1.apply(DefaultColumnMapper.scala:78)
at com.datastax.spark.connector.mapper.DefaultColumnMapper$$anonfun$4$$anonfun$apply$1.apply(DefaultColumnMapper.scala:78)
at scala.Option.getOrElse(Option.scala:120)
at com.datastax.spark.connector.mapper.DefaultColumnMapper$$anonfun$4.apply(DefaultColumnMapper.scala:78)
at com.datastax.spark.connector.mapper.DefaultColumnMapper$$anonfun$4.apply(DefaultColumnMapper.scala:76)
at scala.collection.TraversableLike$WithFilter$$anonfun$map$2.apply(TraversableLike.scala:722)
at scala.collection.immutable.List.foreach(List.scala:318)
at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:721)
at com.datastax.spark.connector.mapper.DefaultColumnMapper.columnMapForReading(DefaultColumnMapper.scala:76)
at com.datastax.spark.connector.rdd.reader.GettableDataToMappedTypeConverter.<init>(GettableDataToMappedTypeConverter.scala:56)
at com.datastax.spark.connector.rdd.reader.ClassBasedRowReader.<init>(ClassBasedRowReader.scala:23)
at com.datastax.spark.connector.rdd.reader.ClassBasedRowReaderFactory.rowReader(ClassBasedRowReader.scala:48)
at com.datastax.spark.connector.rdd.reader.ClassBasedRowReaderFactory.rowReader(ClassBasedRowReader.scala:43)
at com.datastax.spark.connector.rdd.CassandraTableRowReaderProvider$class.rowReader(CassandraTableRowReaderProvider.scala:48)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.rowReader$lzycompute(CassandraTableScanRDD.scala:59)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.rowReader(CassandraTableScanRDD.scala:59)
at com.datastax.spark.connector.rdd.CassandraTableRowReaderProvider$class.verify(CassandraTableRowReaderProvider.scala:151)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.verify(CassandraTableScanRDD.scala:59)
at com.datastax.spark.connector.rdd.CassandraTableScanRDD.getPartitions(CassandraTableScanRDD.scala:143)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:219)
at org.apache.spark.rdd.RDD$$anonfun$partitions$2.apply(RDD.scala:217)
Can someone help me with this case?
Tried with this too but no success:
no30.saveToCassandra("ks","t2", SomeColumns("colA","colB","colC","colD"=false))
But with class definition without colD:
case class cl1(colA:String, colB:Int, colC:BigInt)
--
You received this message because you are subscribed to the Google Groups "DataStax Spark Connector for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spark-connector-...@lists.datastax.com.
I came across the similar situation and I went ahead with Rowrdd and attaching the schema while converting to df.
In case you plan to upgrade Scala you well have to build your spark with the newer version of Scala. So you should be ready for that.
Otherwise you can use Rowrdd which worked for me. If you n need I can give some code samples.
> To unsubscribe from this group and stop receiving emails from it, send an email to spark-connector-user+unsub...@lists.datastax.com.
>
>
> --
>
>
>
>
> Russell Spitzer
> Software Engineer
>
>
>
>
>
>
>
> https://github.com/datastax/spark-cassandra-connector/blob/master/doc/FAQ.md
> http://spark-packages.org/package/datastax/spark-cassandra-connector
Hello Russel,
your solution worked like a charm, but then i came with a scala limitation:
<console>:7: error: Implementation restriction: case classes cannot have more than 22 parameters.
I tried to create a class inside and referencing it inside the other class, but it didn't work.
Read that with scala 2.11 this was solved, but we can't update the softwares easily here.
Questions:
-Is it possible to change the scala jars only inside the folder /usr/share/dse/resources/spark/lib/ ?
-Is it possible to only update spark with using the same dse (4.8.7)?
-Do you know other approach that i can try to do the same task? My source table has 23 columns and the destiny table has 30 columns, is it possible and performatic to do an insert into select query?
Regards
--
You received this message because you are subscribed to the Google Groups "DataStax Spark Connector for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spark-connector-user+unsub...@lists.datastax.com.
--
You received this message because you are subscribed to the Google Groups "DataStax Spark Connector for Apache Cassandra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to spark-connector-user+unsub...@lists.datastax.com.
output.batch.size.rows |
output.concurrent.writes |