-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-32258][SQL] NormalizeFloatingNumbers directly normalizes IF/CaseWhen/Coalesce child expressions #29061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f1652aa
ba0ea32
5046337
78b8667
d5dce7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
|
|
||
| package org.apache.spark.sql.catalyst.optimizer | ||
|
|
||
| import org.apache.spark.sql.catalyst.expressions.{Alias, And, ArrayTransform, CreateArray, CreateMap, CreateNamedStruct, CreateStruct, EqualTo, ExpectsInputTypes, Expression, GetStructField, If, IsNull, KnownFloatingPointNormalized, LambdaFunction, Literal, NamedLambdaVariable, UnaryExpression} | ||
| import org.apache.spark.sql.catalyst.expressions.{Alias, And, ArrayTransform, CaseWhen, Coalesce, CreateArray, CreateMap, CreateNamedStruct, CreateStruct, EqualTo, ExpectsInputTypes, Expression, GetStructField, If, IsNull, KnownFloatingPointNormalized, LambdaFunction, Literal, NamedLambdaVariable, UnaryExpression} | ||
| import org.apache.spark.sql.catalyst.expressions.codegen.{CodegenContext, ExprCode} | ||
| import org.apache.spark.sql.catalyst.planning.ExtractEquiJoinKeys | ||
| import org.apache.spark.sql.catalyst.plans.logical.{LogicalPlan, Subquery, Window} | ||
|
|
@@ -116,6 +116,15 @@ object NormalizeFloatingNumbers extends Rule[LogicalPlan] { | |
| case CreateMap(children, useStringTypeWhenEmpty) => | ||
| CreateMap(children.map(normalize), useStringTypeWhenEmpty) | ||
|
|
||
| case If(cond, trueValue, falseValue) => | ||
| If(cond, normalize(trueValue), normalize(falseValue)) | ||
|
|
||
| case CaseWhen(branches, elseVale) => | ||
dongjoon-hyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| CaseWhen(branches.map(br => (br._1, normalize(br._2))), elseVale.map(normalize)) | ||
|
|
||
dongjoon-hyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| case Coalesce(children) => | ||
| Coalesce(children.map(normalize)) | ||
|
|
||
| case _ if expr.dataType == FloatType || expr.dataType == DoubleType => | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shall we put these new cases after this case? The main goal of this optimization is to avoid constructing a new
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay. |
||
| KnownFloatingPointNormalized(NormalizeNaNAndZero(expr)) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.