Skip to content

Commit 16c8d56

Browse files
ueshinrxin
authored andcommitted
[SPARK-2509][SQL] Add optimization for Substring.
`Substring` including `null` literal cases could be added to `NullPropagation`. Author: Takuya UESHIN <[email protected]> Closes #1428 from ueshin/issues/SPARK-2509 and squashes the following commits: d9eb85f [Takuya UESHIN] Add Substring cases to NullPropagation. (cherry picked from commit 9b38b7c) Signed-off-by: Reynold Xin <[email protected]>
1 parent 96fdc7c commit 16c8d56

File tree

1 file changed

+3
-0
lines changed
  • sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer

1 file changed

+3
-0
lines changed

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/Optimizer.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ object NullPropagation extends Rule[LogicalPlan] {
171171
case Literal(candidate, _) if candidate == v => true
172172
case _ => false
173173
})) => Literal(true, BooleanType)
174+
case e @ Substring(Literal(null, _), _, _) => Literal(null, e.dataType)
175+
case e @ Substring(_, Literal(null, _), _) => Literal(null, e.dataType)
176+
case e @ Substring(_, _, Literal(null, _)) => Literal(null, e.dataType)
174177
// Put exceptional cases above if any
175178
case e: BinaryArithmetic => e.children match {
176179
case Literal(null, _) :: right :: Nil => Literal(null, e.dataType)

0 commit comments

Comments
 (0)