-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
[SPARK-9192][SQL] add initialization phase for nondeterministic expression #7535
Changes from all commits
86fee36
b4a4fc7
bb7d838
9eac85e
ef68ff4
6c6f332
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 |
---|---|---|
|
@@ -19,7 +19,6 @@ package org.apache.spark.sql.catalyst.analysis | |
|
||
import org.apache.spark.sql.AnalysisException | ||
import org.apache.spark.sql.catalyst.expressions._ | ||
import org.apache.spark.sql.catalyst.expressions.aggregate.AggregateExpression2 | ||
import org.apache.spark.sql.catalyst.plans.logical._ | ||
import org.apache.spark.sql.types._ | ||
|
||
|
@@ -38,10 +37,10 @@ trait CheckAnalysis { | |
throw new AnalysisException(msg) | ||
} | ||
|
||
def containsMultipleGenerators(exprs: Seq[Expression]): Boolean = { | ||
protected def containsMultipleGenerators(exprs: Seq[Expression]): Boolean = { | ||
exprs.flatMap(_.collect { | ||
case e: Generator => true | ||
}).nonEmpty | ||
case e: Generator => e | ||
}).length > 1 | ||
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. a un-related but small fix: check multiple should use 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. oops |
||
} | ||
|
||
def checkAnalysis(plan: LogicalPlan): Unit = { | ||
|
@@ -137,13 +136,21 @@ trait CheckAnalysis { | |
s""" | ||
|Failure when resolving conflicting references in Join: | ||
|$plan | ||
|Conflicting attributes: ${conflictingAttributes.mkString(",")} | ||
|""".stripMargin) | ||
|Conflicting attributes: ${conflictingAttributes.mkString(",")} | ||
|""".stripMargin) | ||
|
||
case o if !o.resolved => | ||
failAnalysis( | ||
s"unresolved operator ${operator.simpleString}") | ||
|
||
case o if o.expressions.exists(!_.deterministic) && | ||
!o.isInstanceOf[Project] && !o.isInstanceOf[Filter] => | ||
failAnalysis( | ||
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. you make it seem like a user error here, but if we get here, we have a bug in the system. maybe we should just add throw illegalstateexception 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. I'd like to do it in another PR, as here in not the only place that need to update in CheckAnalysis. 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. Hi, @cloud-fan .Can it support for join operator? Sometimes we can use some SELECT src.key, src.value, src1.value
FROM src
JOIN src1
ON UPPER((CASE WHEN (src.key IS NULL OR src.key = '' ) THEN CAST( (-RAND() * 10000000 ) AS string ) ELSE src.key END )) = UPPER(src1.key) What do you think? 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. We have 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. Yep, we need to change this sql manually after this behavior. |
||
s"""nondeterministic expressions are only allowed in Project or Filter, found: | ||
| ${o.expressions.map(_.prettyString).mkString(",")} | ||
|in operator ${operator.simpleString} | ||
""".stripMargin) | ||
|
||
case _ => // Analysis successful! | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @marmbrus / @yhuai