Skip to content
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-24640][SQL] Return NULL from size(NULL) by default #26051

Closed
wants to merge 2 commits into from

Conversation

MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented Oct 8, 2019

What changes were proposed in this pull request?

Set the default value of the spark.sql.legacy.sizeOfNull config to false. That changes behavior of the size() function for NULL. The function will return NULL for NULL instead of -1.

Why are the changes needed?

There is the agreement in the PR #21598 (comment) to change behavior in Spark 3.0.

Does this PR introduce any user-facing change?

Yes.
Before:

spark-sql> select size(NULL);
-1

After:

spark-sql> select size(NULL);
NULL

How was this patch tested?

By the check outputs of expression examples test in SQLQuerySuite which runs expression examples.

@MaxGekk
Copy link
Member Author

MaxGekk commented Oct 8, 2019

@HyukjinKwon @cloud-fan @gatorsmile Please, take a look at the PR.

@SparkQA
Copy link

SparkQA commented Oct 8, 2019

Test build #111880 has finished for PR 26051 at commit a8a0a98.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@HyukjinKwon
Copy link
Member

Merged to master.

@gatorsmile
Copy link
Member

@MaxGekk Could you submit a follow-up PR to update the migration guide?

@MaxGekk
Copy link
Member Author

MaxGekk commented Oct 9, 2019

Here is the PR #26066 which updates the SQL migration guide.

@MaxGekk MaxGekk deleted the sizeof-null-returns-null branch October 15, 2019 19:57
atronchi pushed a commit to atronchi/spark that referenced this pull request Oct 23, 2019
### What changes were proposed in this pull request?
Set the default value of the `spark.sql.legacy.sizeOfNull` config to `false`. That changes behavior of the `size()` function for `NULL`. The function will return `NULL` for `NULL` instead of `-1`.

### Why are the changes needed?
There is the agreement in the PR apache#21598 (comment) to change behavior in Spark 3.0.

### Does this PR introduce any user-facing change?
Yes.
Before:
```sql
spark-sql> select size(NULL);
-1
```
After:
```sql
spark-sql> select size(NULL);
NULL
```

### How was this patch tested?
By the `check outputs of expression examples` test in `SQLQuerySuite` which runs expression examples.

Closes apache#26051 from MaxGekk/sizeof-null-returns-null.

Authored-by: Maxim Gekk <max.gekk@gmail.com>
Signed-off-by: HyukjinKwon <gurwls223@apache.org>
dongjoon-hyun pushed a commit that referenced this pull request Mar 11, 2020
…efault

### What changes were proposed in this pull request?

This PR reverts #26051 and #26066

### Why are the changes needed?

There is no standard requiring that `size(null)` must return null, and returning -1 looks reasonable as well. This is kind of a cosmetic change and we should avoid it if it breaks existing queries. This is similar to reverting TRIM function parameter order change.

### Does this PR introduce any user-facing change?

Yes, change the behavior of `size(null)` back to be the same as 2.4.

### How was this patch tested?

N/A

Closes #27834 from cloud-fan/revert.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
dongjoon-hyun pushed a commit that referenced this pull request Mar 11, 2020
…efault

### What changes were proposed in this pull request?

This PR reverts #26051 and #26066

### Why are the changes needed?

There is no standard requiring that `size(null)` must return null, and returning -1 looks reasonable as well. This is kind of a cosmetic change and we should avoid it if it breaks existing queries. This is similar to reverting TRIM function parameter order change.

### Does this PR introduce any user-facing change?

Yes, change the behavior of `size(null)` back to be the same as 2.4.

### How was this patch tested?

N/A

Closes #27834 from cloud-fan/revert.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
(cherry picked from commit 8efb710)
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
sjincho pushed a commit to sjincho/spark that referenced this pull request Apr 15, 2020
…efault

### What changes were proposed in this pull request?

This PR reverts apache#26051 and apache#26066

### Why are the changes needed?

There is no standard requiring that `size(null)` must return null, and returning -1 looks reasonable as well. This is kind of a cosmetic change and we should avoid it if it breaks existing queries. This is similar to reverting TRIM function parameter order change.

### Does this PR introduce any user-facing change?

Yes, change the behavior of `size(null)` back to be the same as 2.4.

### How was this patch tested?

N/A

Closes apache#27834 from cloud-fan/revert.

Authored-by: Wenchen Fan <wenchen@databricks.com>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
6 participants