score:2
df.withcolumn("quelle",when(col("id").contains("123"),lit("xy")).otherwise("aa"))
should give you the result you are looking for
i tried to reproduce the error you are getting and this is likely the one which you tried df.withcolumn("quelle",when("id".contains("123"),lit("xy")).otherwise("aa")) which gives me exactly the same error you are getting above.
error: type mismatch; found : boolean required: org.apache.spark.sql.column
please check if this helps
Source: stackoverflow.com
Related Query
- Creating a column if a condition is proven to be true
- Creating a new column based on a window and a condition in Spark
- How to update column based on a condition (a value in a group)?
- EitherT: Call function returning Either only if a certain condition is true (otherwise return right)
- Modify element(s) in a list where a condition is true
- Spark DataFrame change datatype based on column condition
- dataframe with dynamic when condition using with column
- how to generate new column values for each group using a condition
- drop all columns with a special condition on a column spark
- Creating a single column table with Slick
- Evaluate expression according to the first true condition
- java.io.NotSerializableException: org.apache.spark.sql.Column when creating a new column conditionally, using a map of UDFs
- Spark: How to join two `Dataset`s A and B with the condition that an ID array column of A does NOT contain the ID column of B?
- spark scala map column names to output arraytype column for values true
- Creating a column in a dataframe based on substring of another column, scala
- Replace two different column values in a dataframe using same condition with minimum complexity in scala
- Spark creating a new column based on a mapped value of an existing column
- Getting latest based on column condition in Spark Scala is not working
- Add new column to dataframe based on previous values and condition
- Creating new column with values of looping through SparkSQL Dataframe
- Creating arraytype column in a dataframe using existing data in dataframe in scala
- spark scala - UDF usage for creating new column
- Calculate minimum and maximum value from a set of values after applying a condition on column
- Creating column types for schema
- Creating a Spark Vector Column with createDataFrame
- Spark RDD: Sum one column without creating SQL DataFrame
- spark scala: add a new column that has a list as a value; the list should verify a specific condition
- scala spark issue resolving attributes when creating a new column
- Spark Scala creating timestamp column from date
- How would I extract numbers from column names based on a match condition in spark scala?
More Query from same tag
- Play migrations alternatives
- sbt: Add multiple resolvers
- Scala Dataframe columns with space save as a databricks table
- Twitter data from spark
- Using ListView from Scala 2.9.2 with Java 7 gives compile error
- Convert List of strings to list of structs
- Why can't the compiler infer type parameter for package object (while it works fine for object)?
- Spark can't identify the event time column being supplied to withWatermark()
- Is there anything like Haskell's 'maybe' function built into Scala?
- Delete first element of List in Scala
- Invoking granular methods in Akka
- Spark (Scala): Attribute name contains invalid character
- Use a column value as column name
- Best practices to use Future inside a Controller (Play+Scala)
- converting xml to Json with lift behaves strange
- java.lang.NullPointerException with Scala regex
- Requester cannot establish the connection. Jetty, Lift /Scala, iSeries DB2/400
- Scala filter on two conditions
- How to use LIKE operator in Slick?
- How to stop program execution in worksheet?
- How to instruct Scala not to upcast abstract type?
- Case insensitive Scala parser-combinator
- How to filter out incorrect records?
- In scala 2.13, why is it sometimes impossible to summon type class explicitly? - Part 2
- Akka Http Server - How to have route respond with byte array binary response
- Play! Framework controller returns EMPTY RESPONSE after adding reactivemongo plugin
- Is there an implicit unlift of total functions in Scala when `PartialFunction` is required?
- Using a feeder to pass in header values (Gatling)
- scala HashSet[String].contains slows down app dramatically
- Mixing Scala and Java files in an Eclipse project