Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,8 @@ object NullPropagation extends Rule[LogicalPlan] {

def apply(plan: LogicalPlan): LogicalPlan = plan transform {
case q: LogicalPlan => q transformExpressionsUp {
case e @ WindowExpression(Cast(Literal(0L, _), _), _) =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a unit test suite for NullPropagation?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I can't find that. I think there does not exist.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you for review, @rxin .

Cast(Literal(0L), e.dataType)
case e @ AggregateExpression(Count(exprs), _, _, _) if !exprs.exists(nonNullLiteral) =>
Cast(Literal(0L), e.dataType)
case e @ IsNull(c) if !c.nullable => Literal.create(false, BooleanType)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

-- count(null) should be 0
SELECT COUNT(NULL) FROM VALUES 1, 2, 3;
SELECT COUNT(1 + NULL) FROM VALUES 1, 2, 3;

-- count(null) on window should be 0
SELECT COUNT(NULL) OVER () FROM VALUES 1, 2, 3;
SELECT COUNT(1 + NULL) OVER () FROM VALUES 1, 2, 3;

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 4


-- !query 0
SELECT COUNT(NULL) FROM VALUES 1, 2, 3
-- !query 0 schema
struct<count(NULL):bigint>
-- !query 0 output
0


-- !query 1
SELECT COUNT(1 + NULL) FROM VALUES 1, 2, 3
-- !query 1 schema
struct<count((1 + CAST(NULL AS INT))):bigint>
-- !query 1 output
0


-- !query 2
SELECT COUNT(NULL) OVER () FROM VALUES 1, 2, 3
-- !query 2 schema
struct<count(NULL) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING):bigint>
-- !query 2 output
0
0
0


-- !query 3
SELECT COUNT(1 + NULL) OVER () FROM VALUES 1, 2, 3
-- !query 3 schema
struct<count((1 + CAST(NULL AS INT))) OVER (ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING):bigint>
-- !query 3 output
0
0
0