scala - How to preserve order of columns in cassandra -


i have 2 tables in cassandra:

create table table1 (           name text primary key,           grade text,            labid list<int>);  create table table2(           name text primary key,           deptid list<int>             grade text,); 

for example:

val result: rdd[string, string, list[int]] = myfunction(); result.savetocassandra(keyspace, table1) 

it working fine. in case of using below line:

result.savetocassandra(keyspace, table2) 

m getting type of error : com.datastax.spark.connector.types.typeconversionexception: cannot convert object test_data of type class java.lang.string list[anyref]

is there solution using somecolumns satisfy both tables[we don't know table executed]. eg:

result.savetocassandra(keyspace, table, somecolumns(....))? 

you arguments should in different order because tables have different column types:

val result: rdd[string, string, list[int]] = myfunction(); val reorder: rdd[string, list[int], string] = result.map(r => r._1, r._3, r._2) reorder.savetocassandra(keyspace, table2) 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -