Apache spark 我在Spark SQL 2.x-'中遇到类型不匹配错误;应为列,但找到列';
我试图从dataframe列列表中筛选出2列,并将其作为散列函数的参数。 使用Spark Scala 2.11.8 Spark SQL-2.3.1 我正在尝试为所需的列(customerId、address)生成哈希值 可以通过在函数中提及列名来实现Apache spark 我在Spark SQL 2.x-'中遇到类型不匹配错误;应为列,但找到列';,apache-spark,apache-spark-sql,Apache Spark,Apache Spark Sql,我试图从dataframe列列表中筛选出2列,并将其作为散列函数的参数。 使用Spark Scala 2.11.8 Spark SQL-2.3.1 我正在尝试为所需的列(customerId、address)生成哈希值 可以通过在函数中提及列名来实现 //existingdataDF.withColumn("hashkey",hash(col("customerId"),col("address") )).show 但是如果我们有100列,我需要包括98列,除了2列 因此,我需要过滤不需要的
//existingdataDF.withColumn("hashkey",hash(col("customerId"),col("address") )).show
但是如果我们有100列,我需要包括98列,除了2列
因此,我需要过滤不需要的列,并为所有列生成哈希值。(需要哈希值在数据上实现SCD 2)
首先获取所需列的列表,然后应用哈希
import org.apache.spark.sql.functions._
val hashcolumns =existingdataDF.filter(x=> x!=col("effectiveDate") && x!=col("endDate")).columns.map(col(_))
existingdataDF.withColumn("hashkey",hash(hashcolumns:_*)).show
请添加完整的步骤,你们想做什么?@Manoj Kumar Dhakad我已经为问题添加了更多信息。
import org.apache.spark.sql.functions._
val hashcolumns =existingdataDF.filter(x=> x!=col("effectiveDate") && x!=col("endDate")).columns.map(col(_))
existingdataDF.withColumn("hashkey",hash(hashcolumns:_*)).show