较新的spark-cassandra连接器已弃用/删除了允许执行CQL的CassandraSQLContext。而且,现在,我找不到一种方法来查找目录信息,如:键空间列表,键空间中的表或列元数据。
具体来说,我希望能够运行类似select keyspace_name, table_name, column_name, type from system_schema.columns where keyspace_name = 'test'
的内容
也许我错过了运行CQL的API? (我正在使用2.0连接器)
答案 0 :(得分:1)
Spark Cassandra连接器可以使用.then(response => console.log(response))
方法,就像在Java驱动程序中一样,这样(从documentation采用):
withSessionDo
但是你可以使用更简单的RDD操作,如下所示:
import com.datastax.spark.connector.cql.CassandraConnector
CassandraConnector(conf).withSessionDo { session =>
session.execute("select keyspace_name, table_name, column_name,
type from system_schema.columns where keyspace_name = 'test';")
}
P.S。此外,请注意,通过会话 - >群集可以通过sc.cassandraTable("system_schema", "columns").select("keyspace_name","table_name",
...other columns...)
类进行访问是更便携的方式。