You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by li...@apache.org on 2018/02/01 04:59:24 UTC
spark git commit: [SQL][MINOR] Inline
SpecifiedWindowFrame.defaultWindowFrame().
Repository: spark
Updated Branches:
refs/heads/master cc41245fa -> b6b50efc8
[SQL][MINOR] Inline SpecifiedWindowFrame.defaultWindowFrame().
## What changes were proposed in this pull request?
SpecifiedWindowFrame.defaultWindowFrame(hasOrderSpecification, acceptWindowFrame) was designed to handle the cases when some Window functions don't support setting a window frame (e.g. rank). However this param is never used.
We may inline the whole of this function to simplify the code.
## How was this patch tested?
Existing tests.
Author: Xingbo Jiang <xi...@databricks.com>
Closes #20463 from jiangxb1987/defaultWindowFrame.
Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/b6b50efc
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/b6b50efc
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/b6b50efc
Branch: refs/heads/master
Commit: b6b50efc854f298d5b3e11c05dca995a85bec962
Parents: cc41245
Author: Xingbo Jiang <xi...@databricks.com>
Authored: Wed Jan 31 20:59:19 2018 -0800
Committer: gatorsmile <ga...@gmail.com>
Committed: Wed Jan 31 20:59:19 2018 -0800
----------------------------------------------------------------------
.../spark/sql/catalyst/analysis/Analyzer.scala | 6 +++++-
.../expressions/windowExpressions.scala | 21 --------------------
.../catalyst/ExpressionSQLBuilderSuite.scala | 5 +----
3 files changed, 6 insertions(+), 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/spark/blob/b6b50efc/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
index 251099f..7848f88 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
@@ -2038,7 +2038,11 @@ class Analyzer(
WindowExpression(wf, s.copy(frameSpecification = wf.frame))
case we @ WindowExpression(e, s @ WindowSpecDefinition(_, o, UnspecifiedFrame))
if e.resolved =>
- val frame = SpecifiedWindowFrame.defaultWindowFrame(o.nonEmpty, acceptWindowFrame = true)
+ val frame = if (o.nonEmpty) {
+ SpecifiedWindowFrame(RangeFrame, UnboundedPreceding, CurrentRow)
+ } else {
+ SpecifiedWindowFrame(RowFrame, UnboundedPreceding, UnboundedFollowing)
+ }
we.copy(windowSpec = s.copy(frameSpecification = frame))
}
}
http://git-wip-us.apache.org/repos/asf/spark/blob/b6b50efc/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
----------------------------------------------------------------------
diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
index dd13d9a..78895f1 100644
--- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
+++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/windowExpressions.scala
@@ -265,27 +265,6 @@ case class SpecifiedWindowFrame(
}
}
-object SpecifiedWindowFrame {
- /**
- * @param hasOrderSpecification If the window spec has order by expressions.
- * @param acceptWindowFrame If the window function accepts user-specified frame.
- * @return the default window frame.
- */
- def defaultWindowFrame(
- hasOrderSpecification: Boolean,
- acceptWindowFrame: Boolean): SpecifiedWindowFrame = {
- if (hasOrderSpecification && acceptWindowFrame) {
- // If order spec is defined and the window function supports user specified window frames,
- // the default frame is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
- SpecifiedWindowFrame(RangeFrame, UnboundedPreceding, CurrentRow)
- } else {
- // Otherwise, the default frame is
- // ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING.
- SpecifiedWindowFrame(RowFrame, UnboundedPreceding, UnboundedFollowing)
- }
- }
-}
-
case class UnresolvedWindowExpression(
child: Expression,
windowSpec: WindowSpecReference) extends UnaryExpression with Unevaluable {
http://git-wip-us.apache.org/repos/asf/spark/blob/b6b50efc/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionSQLBuilderSuite.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionSQLBuilderSuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionSQLBuilderSuite.scala
index d9cf1f3..61f9179 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionSQLBuilderSuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionSQLBuilderSuite.scala
@@ -108,10 +108,7 @@ class ExpressionSQLBuilderSuite extends QueryTest with TestHiveSingleton {
}
test("window specification") {
- val frame = SpecifiedWindowFrame.defaultWindowFrame(
- hasOrderSpecification = true,
- acceptWindowFrame = true
- )
+ val frame = SpecifiedWindowFrame(RangeFrame, UnboundedPreceding, CurrentRow)
checkSQL(
WindowSpecDefinition('a.int :: Nil, Nil, frame),
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org