-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SQL: Introduce Coalesce function (#35253)
Add Coalesce conditional for replacing null values Fix #35060
- Loading branch information
Showing
31 changed files
with
560 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// | ||
// Null expressions | ||
// | ||
|
||
dateTimeOverNull | ||
SELECT YEAR(CAST(NULL AS DATE)) d; | ||
|
||
d:i | ||
null | ||
; | ||
|
||
addOfNull | ||
SELECT CAST(NULL AS INT) + CAST(NULL AS FLOAT) AS n; | ||
|
||
n:d | ||
null | ||
; | ||
|
||
|
||
divOfCastedNull | ||
SELECT 5 / CAST(NULL AS FLOAT) + 10 AS n; | ||
|
||
n:d | ||
null | ||
; | ||
|
||
divNoNull | ||
SELECT 5 / null + 1 AS n; | ||
|
||
n:i | ||
null | ||
; | ||
|
||
coalesceJustWithNull | ||
SELECT COALESCE(null, null, null) AS c; | ||
|
||
c | ||
null | ||
; | ||
|
||
coalesceFirstNotNull | ||
SELECT COALESCE(123) AS c; | ||
|
||
c | ||
123 | ||
; | ||
|
||
|
||
coalesceWithFirstNullOfString | ||
SELECT COALESCE(null, 'first') AS c; | ||
|
||
c:s | ||
first | ||
; | ||
|
||
coalesceWithFirstNullOfNumber | ||
SELECT COALESCE(null, 123) AS c; | ||
|
||
c:i | ||
123 | ||
; | ||
|
||
coalesceMixed | ||
SELECT COALESCE(null, 123, null, 321) AS c; | ||
|
||
c:i | ||
123 | ||
; | ||
|
||
coalesceScalar | ||
SELECT COALESCE(null, ABS(123) + 1) AS c; | ||
|
||
c:i | ||
124 | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// Null expressions | ||
// | ||
|
||
coalesceField | ||
SELECT COALESCE(null, ABS(emp_no) + 1) AS c FROM test_emp ORDER BY emp_no LIMIT 5; | ||
|
||
coalesceHaving | ||
SELECT COALESCE(null, ABS(MAX(emp_no)) + 1, 123) AS c FROM test_emp GROUP BY languages HAVING c > 100 ORDER BY languages LIMIT 5; | ||
|
||
coalesceWhere | ||
SELECT COALESCE(null, ABS(emp_no) + 1, 123) AS c FROM test_emp WHERE COALESCE(null, ABS(emp_no) + 1, 123, 321) > 100 ORDER BY emp_no NULLS FIRST LIMIT 5; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.