创建临时视图时使用 WHERE 或 FILTER

Use WHERE or FILTER whe creating TempView

创建 SparkSQL TempView 时是否可以使用 wherefilter

我有一个 Cassandra table words

word | count
------------
apples | 20
banana | 10

我试过了

%spark

val df = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options( Map ("keyspace"-> "temp", "table"->"words" ))
.where($"count" > 10)
.load()
.createOrReplaceTempView("high_counted")

 %spark

val df = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options( Map ("keyspace"-> "temp", "table"->"words" ))
.where("count > 10")
.load()
.createOrReplaceTempView("high_counted")

如果不按照@undefined_variable 的建议.load()ing table,您就无法执行WHEREFILTER

尝试:

%spark

val df = sqlContext
.read
.format("org.apache.spark.sql.cassandra")
.options( Map ("keyspace"-> "temp", "table"->"words" ))
.load()
.where($"count" > 10)
.createOrReplaceTempView("high_counted")

或者,您可以按照记录进行自由格式查询 here

Spark 评估了 lazy fashion 中的语句,上面的语句是一个转换。 (如果您认为我们需要在加载前进行过滤)