Meisam Emamjome
Meisam Emamjome

Reputation: 508

spark-sql case when works in REPL but code doesnt compile

This code works in REPL but doesnt compile. I guess I am missing an implicit. But

people.select(when(people("gender") === "male", 0)
    .when(people("gender") === "female", 1)
    .otherwise(2))

Upvotes: 0

Views: 91

Answers (1)

Paweł Jurczenko
Paweł Jurczenko

Reputation: 4471

In non-REPL code you should use the following import:

import org.apache.spark.sql.functions._

Upvotes: 2

Related Questions