spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kant kodali <kanth...@gmail.com>
Subject How does spark sql evaluate case statements?
Date Mon, 06 Apr 2020 07:55:23 GMT
Hi All,

I have the following query and I was wondering if spark sql evaluates the
same condition twice in the case statement below? I did .explain(true) and
all I get is a table scan so not sure if spark sql evaluates the same
condition twice? if it does, is there a way to return multiple values where
each value belongs to a separate column?

SELECT
  CASE WHEN <condition 1> THEN <a1> WHEN <condition 2> THEN <a2> ELSE
<a3> END AS result1,
  CASE WHEN <condition 1> THEN <b1> WHEN <condition 2> THEN <b2> ELSE
<b3> END AS result2FROM
  <table>


Thanks,

Mime
View raw message