如何动态选择CassandraRow中的列。列不固定。以下示例代码。
var columnList = "column1, column2, column3" // this is generated dynamically
SparkContextFunctions(sc)
.cassandraTable(ckeyspaceName, tableName)
.select(columnList)
答案 0 :(得分:1)
例如:
val columns = Seq("column1", "column2", "column3").map(ColumnName(_))
val table = SparkContextFunctions(sc).cassandraTable(ckeyspaceName, tableName)
table.select(columns: _*)