Pattern Matching not working as expected with 10.4 LTS databricks runtime version

179019
New Contributor

Hi everyone,

I recently upgraded the runtime version of one of the databricks job to 10.4 LTS but Pattern Matching is not working as expected the same code is working in 7.3 LTS.

Basically doing this and returning Left or Right:

val result = spark.sql(sqlQuery)

   if(result.count > 0) Left(result) else Right(true)

this will return Right

then:

match {

 case Right(true) => println("Right")

     case _ => println("Other")

    }

but here instead running case Right it goes into case _ always.

So I am not sure what I am doing wrong here. If you can help me with this.

Thanks