Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0b293db
[SPARK-29774][SQL] Date and Timestamp type +/- null should be null as…
yaooqinn Nov 6, 2019
f726297
Merge branch 'master' into SPARK-29774
yaooqinn Nov 27, 2019
e7225a3
regen golden file
yaooqinn Nov 27, 2019
b925517
null - dates
yaooqinn Nov 27, 2019
cd49411
Merge branch 'master' into SPARK-29774
yaooqinn Dec 2, 2019
57b13e9
support +/-
yaooqinn Dec 2, 2019
eab6a83
support ×/÷
yaooqinn Dec 2, 2019
e8b75ba
import
yaooqinn Dec 2, 2019
02b3738
childResolved required
yaooqinn Dec 2, 2019
e89d806
regen golden file
yaooqinn Dec 2, 2019
0694e07
update comments
yaooqinn Dec 2, 2019
0f5618b
fix tests
yaooqinn Dec 3, 2019
efab3ec
fix tests
yaooqinn Dec 3, 2019
1c27be1
refine case match pattern
yaooqinn Dec 3, 2019
5df6980
fix ut
yaooqinn Dec 3, 2019
9817d2d
hack assert Equal
yaooqinn Dec 3, 2019
9808b9c
regen g f
yaooqinn Dec 3, 2019
b190612
AnalysisTest
yaooqinn Dec 3, 2019
e544137
regen g f
yaooqinn Dec 3, 2019
83705fd
fix test
yaooqinn Dec 4, 2019
846802d
date add/sub only work for int/smallint/tinyint
yaooqinn Dec 4, 2019
4af7edb
regen g f
yaooqinn Dec 4, 2019
a67be30
refine
yaooqinn Dec 4, 2019
9a1affd
type coercion for subtract timestamp
yaooqinn Dec 4, 2019
ae70022
add and reorgnize tests in datetime.sql
yaooqinn Dec 4, 2019
571225b
DateExpressionsSuite
yaooqinn Dec 4, 2019
6052e5a
fix py
yaooqinn Dec 4, 2019
928fd86
fix py
yaooqinn Dec 4, 2019
254d2d2
Revert "fix py"
yaooqinn Dec 5, 2019
5dd632c
fix py
yaooqinn Dec 5, 2019
c84d46e
rm unresolved binary arithmetic
yaooqinn Dec 5, 2019
a44948e
import
yaooqinn Dec 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix tests
  • Loading branch information
yaooqinn committed Dec 3, 2019
commit 0f5618b09a8d6527cee6f568b764b4ff059c4e0d
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ package object dsl {
def unary_! : Predicate = Not(expr)
def unary_~ : Expression = BitwiseNot(expr)

def + (other: Expression): Expression = Add(expr, other)
def - (other: Expression): Expression = Subtract(expr, other)
def * (other: Expression): Expression = Multiply(expr, other)
def / (other: Expression): Expression = Divide(expr, other)
def + (other: Expression): Expression = UnresolvedAdd(expr, other)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have to change the DSL? mostly + means Add, we can write UnresolvedAdd directly when necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, I will change this back, I'am suffering tests fail with this change.

def - (other: Expression): Expression = UnresolvedSubtract(expr, other)
def * (other: Expression): Expression = UnresolvedMultiply(expr, other)
def / (other: Expression): Expression = UnresolvedDivide(expr, other)
def div (other: Expression): Expression = IntegralDivide(expr, other)
def % (other: Expression): Expression = Remainder(expr, other)
def & (other: Expression): Expression = BitwiseAnd(expr, other)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1696,9 +1696,12 @@ class AstBuilder(conf: SQLConf) extends SqlBaseBaseVisitor[AnyRef] with Logging
*/
override def visitFrameBound(ctx: FrameBoundContext): Expression = withOrigin(ctx) {
def value: Expression = {
val e = expression(ctx.expression)
validate(e.resolved && e.foldable, "Frame bound value must be a literal.", ctx)
e
expression(ctx.expression) match {
case u: UnresolvedBinaryExpression if u.childrenResolved && u.foldable => u
case e =>
validate(e.resolved && e.foldable, "Frame bound value must be a literal.", ctx)
e
}
}

ctx.boundType.getType match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,11 @@ class ExpressionParserSuite extends AnalysisTest {
("unbounded preceding", UnboundedPreceding, CurrentRow),
("2147483648 preceding", -Literal(2147483648L), CurrentRow),
("10 preceding", -Literal(10), CurrentRow),
("3 + 1 preceding", -Add(Literal(3), Literal(1)), CurrentRow),
("3 + 1 preceding", -UnresolvedAdd(Literal(3), Literal(1)), CurrentRow),
("0 preceding", -Literal(0), CurrentRow),
("current row", CurrentRow, CurrentRow),
("0 following", Literal(0), CurrentRow),
("3 + 1 following", Add(Literal(3), Literal(1)), CurrentRow),
("3 + 1 following", UnresolvedAdd(Literal(3), Literal(1)), CurrentRow),
("10 following", Literal(10), CurrentRow),
("2147483649 following", Literal(2147483649L), CurrentRow),
("unbounded following", UnboundedFollowing, CurrentRow), // Will fail during analysis
Expand All @@ -320,26 +320,28 @@ class ExpressionParserSuite extends AnalysisTest {
("between unbounded preceding and 5 following",
UnboundedPreceding, Literal(5)),
("between unbounded preceding and 3 + 1 following",
UnboundedPreceding, Add(Literal(3), Literal(1))),
UnboundedPreceding, UnresolvedAdd(Literal(3), Literal(1))),
("between unbounded preceding and 2147483649 following",
UnboundedPreceding, Literal(2147483649L)),
("between unbounded preceding and current row", UnboundedPreceding, CurrentRow),
("between 2147483648 preceding and current row", -Literal(2147483648L), CurrentRow),
("between 10 preceding and current row", -Literal(10), CurrentRow),
("between 3 + 1 preceding and current row", -Add(Literal(3), Literal(1)), CurrentRow),
("between 3 + 1 preceding and current row", -UnresolvedAdd(Literal(3), Literal(1)),
CurrentRow),
("between 0 preceding and current row", -Literal(0), CurrentRow),
("between current row and current row", CurrentRow, CurrentRow),
("between current row and 0 following", CurrentRow, Literal(0)),
("between current row and 5 following", CurrentRow, Literal(5)),
("between current row and 3 + 1 following", CurrentRow, Add(Literal(3), Literal(1))),
("between current row and 3 + 1 following", CurrentRow,
UnresolvedAdd(Literal(3), Literal(1))),
("between current row and 2147483649 following", CurrentRow, Literal(2147483649L)),
("between current row and unbounded following", CurrentRow, UnboundedFollowing),
("between 2147483648 preceding and unbounded following",
-Literal(2147483648L), UnboundedFollowing),
("between 10 preceding and unbounded following",
-Literal(10), UnboundedFollowing),
("between 3 + 1 preceding and unbounded following",
-Add(Literal(3), Literal(1)), UnboundedFollowing),
-UnresolvedAdd(Literal(3), Literal(1)), UnboundedFollowing),
("between 0 preceding and unbounded following", -Literal(0), UnboundedFollowing),

// Between partial and full range
Expand Down