From 2f9cabbe03addb14f1fa6bac9f19fd1b57351ad7 Mon Sep 17 00:00:00 2001 From: Spaarsh-root Date: Mon, 20 Jan 2025 23:37:44 +0530 Subject: [PATCH 1/5] Added documentation for the Spaceship Operator (<=>) --- docs/source/user-guide/sql/operators.md | 39 +++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/source/user-guide/sql/operators.md b/docs/source/user-guide/sql/operators.md index b0263ebe989a..077f715ad93a 100644 --- a/docs/source/user-guide/sql/operators.md +++ b/docs/source/user-guide/sql/operators.md @@ -207,6 +207,45 @@ Greater Than or Equal To +----------------------+ ``` +(op_spaceship)= + +### `<=>` + +Three-way comparision operator. A NULL-safe operator that returns true if both operands are equal or both are NULL, false otherwise. + +```sql +> SELECT NULL <=> NULL; ++--------------------------------+ +| NULL IS NOT DISTINCT FROM NULL | ++--------------------------------+ +| true | ++--------------------------------+ +``` +```sql +> SELECT 1 <=> NULL; ++------------------------------------+ +| Int64(1) IS NOT DISTINCT FROM NULL | ++------------------------------------+ +| false | ++------------------------------------+ +``` +```sql +> SELECT 1 <=> 2; ++----------------------------------------+ +| Int64(1) IS NOT DISTINCT FROM Int64(2) | ++----------------------------------------+ +| false | ++----------------------------------------+ +``` +```sql +> SELECT 1 <=> 1; ++----------------------------------------+ +| Int64(1) IS NOT DISTINCT FROM Int64(1) | ++----------------------------------------+ +| true | ++----------------------------------------+ +``` + ### `IS DISTINCT FROM` Guarantees the result of a comparison is `true` or `false` and not an empty set From 75e57b7e7ea7d5f91ff3a03662746b913b7456e5 Mon Sep 17 00:00:00 2001 From: Spaarsh-root Date: Tue, 21 Jan 2025 00:01:05 +0530 Subject: [PATCH 2/5] Fix Prettier formatting issues --- docs/source/user-guide/sql/operators.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/source/user-guide/sql/operators.md b/docs/source/user-guide/sql/operators.md index 077f715ad93a..06b5ac90f8d9 100644 --- a/docs/source/user-guide/sql/operators.md +++ b/docs/source/user-guide/sql/operators.md @@ -221,6 +221,7 @@ Three-way comparision operator. A NULL-safe operator that returns true if both o | true | +--------------------------------+ ``` + ```sql > SELECT 1 <=> NULL; +------------------------------------+ @@ -229,6 +230,7 @@ Three-way comparision operator. A NULL-safe operator that returns true if both o | false | +------------------------------------+ ``` + ```sql > SELECT 1 <=> 2; +----------------------------------------+ @@ -237,6 +239,7 @@ Three-way comparision operator. A NULL-safe operator that returns true if both o | false | +----------------------------------------+ ``` + ```sql > SELECT 1 <=> 1; +----------------------------------------+ From 4b37a7194b637a922901a39029b98908e31a8ed2 Mon Sep 17 00:00:00 2001 From: Spaarsh-root Date: Tue, 21 Jan 2025 00:16:53 +0530 Subject: [PATCH 3/5] Added Spaceship Operator (<=>) to the list of Comparision Operators --- docs/source/user-guide/sql/operators.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/user-guide/sql/operators.md b/docs/source/user-guide/sql/operators.md index 06b5ac90f8d9..74d7d45cd558 100644 --- a/docs/source/user-guide/sql/operators.md +++ b/docs/source/user-guide/sql/operators.md @@ -110,6 +110,7 @@ Modulo (remainder) - [<= (less than or equal to)](#op_le) - [> (greater than)](#op_gt) - [>= (greater than or equal to)](#op_ge) +- [<=> (three-way comparision, alias for IS NOT DISTINCT FROM)](#op_spaceship) - [IS DISTINCT FROM](#is-distinct-from) - [IS NOT DISTINCT FROM](#is-not-distinct-from) - [~ (regex match)](#op_re_match) From 88a2b82df113a41d61e5f9f59781cbb77454ff61 Mon Sep 17 00:00:00 2001 From: Spaarsh <67336892+Spaarsh@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:01:09 +0530 Subject: [PATCH 4/5] Update docs/source/user-guide/sql/operators.md Co-authored-by: Oleks V --- docs/source/user-guide/sql/operators.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-guide/sql/operators.md b/docs/source/user-guide/sql/operators.md index 74d7d45cd558..b4fbcc1d0c71 100644 --- a/docs/source/user-guide/sql/operators.md +++ b/docs/source/user-guide/sql/operators.md @@ -212,7 +212,7 @@ Greater Than or Equal To ### `<=>` -Three-way comparision operator. A NULL-safe operator that returns true if both operands are equal or both are NULL, false otherwise. +Three-way comparison operator. A NULL-safe operator that returns true if both operands are equal or both are NULL, false otherwise. ```sql > SELECT NULL <=> NULL; From 85ccc2725033f72aebe67dbd7c1f07ac95ac5692 Mon Sep 17 00:00:00 2001 From: Spaarsh <67336892+Spaarsh@users.noreply.github.com> Date: Tue, 21 Jan 2025 22:01:26 +0530 Subject: [PATCH 5/5] Update docs/source/user-guide/sql/operators.md Co-authored-by: Oleks V --- docs/source/user-guide/sql/operators.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-guide/sql/operators.md b/docs/source/user-guide/sql/operators.md index b4fbcc1d0c71..51f1a26d0b61 100644 --- a/docs/source/user-guide/sql/operators.md +++ b/docs/source/user-guide/sql/operators.md @@ -110,7 +110,7 @@ Modulo (remainder) - [<= (less than or equal to)](#op_le) - [> (greater than)](#op_gt) - [>= (greater than or equal to)](#op_ge) -- [<=> (three-way comparision, alias for IS NOT DISTINCT FROM)](#op_spaceship) +- [<=> (three-way comparison, alias for IS NOT DISTINCT FROM)](#op_spaceship) - [IS DISTINCT FROM](#is-distinct-from) - [IS NOT DISTINCT FROM](#is-not-distinct-from) - [~ (regex match)](#op_re_match)