简体   繁体   中英

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

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 ".

early help will be appreciated.

Thanks in advance.

你可以使用由Column实现的bitwiseOR

val t1 = df.withColumn("C1", when($"a1" > 0 , $"C1".bitwiseOR(mask.toInt)).otherwise($"C1"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM