0

I have a list of dates in scala like below.

ListBuffer(2021-10-01, 2021-10-02, 2021-10-03, 2021-10-04)

I want to pass each element in the list to the below variable and get the count.

val fctExistingDF = spark.read.table(existingTable).filter("event_date","date from the list")
fctExistingDF.count()

Please let me know how to achieve this.

4

1 回答 1

1

您可以使用isin

import org.apache.spark.sql.functions.col

val values = Seq("2021-10-01", "2021-10-02", "2021-10-03", "2021-10-04")
spark.read.table(existingTable).filter(col("event_date").isin(values:_*)).count()
于 2021-10-27T05:23:02.183 回答