[英]How to perform binary “or” operations on column of Data Frame in Spark
Let me explain you the scenario: 让我解释一下这个场景:
I am creating one mask value. 我正在创建一个掩码值。 ie
即
val Date = 20170501
val day = Date.toString.substring(6, 8)
val mask = pow(2, day.toInt -1)
Then next I am creating dataframe
which create additional column using withColumn
ie 接下来,我正在创建
dataframe
withColumn
使用withColumn
即创建额外的列
val t1 = df.withColumn("C1", when($"a1" > 0 , $"C1" | mask.toInt).otherwise($"C1"))
but when I am performing |
但是当我在表演
|
operation with Dataframe
column it is giving me error as " value | is not a member of org.apache.spark.sql.ColumnName
". 使用
Dataframe
列操作它给出了错误,因为“ value | is not a member of org.apache.spark.sql.ColumnName
”。
early help will be appreciated. 早期的帮助将不胜感激。
Thanks in advance. 提前致谢。
你可以使用由Column
实现的bitwiseOR :
val t1 = df.withColumn("C1", when($"a1" > 0 , $"C1".bitwiseOR(mask.toInt)).otherwise($"C1"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.