Skip to content

Commit 2aff98e

Browse files
Spaarshcomphead
andauthored
Added documentation for the Spaceship Operator (<=>) (apache#14214)
* Added documentation for the Spaceship Operator (<=>) * Fix Prettier formatting issues * Added Spaceship Operator (<=>) to the list of Comparision Operators * Update docs/source/user-guide/sql/operators.md Co-authored-by: Oleks V <[email protected]> * Update docs/source/user-guide/sql/operators.md Co-authored-by: Oleks V <[email protected]> --------- Co-authored-by: Oleks V <[email protected]>
1 parent 2f28327 commit 2aff98e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

docs/source/user-guide/sql/operators.md

+43
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ Modulo (remainder)
110110
- [<= (less than or equal to)](#op_le)
111111
- [> (greater than)](#op_gt)
112112
- [>= (greater than or equal to)](#op_ge)
113+
- [<=> (three-way comparison, alias for IS NOT DISTINCT FROM)](#op_spaceship)
113114
- [IS DISTINCT FROM](#is-distinct-from)
114115
- [IS NOT DISTINCT FROM](#is-not-distinct-from)
115116
- [~ (regex match)](#op_re_match)
@@ -207,6 +208,48 @@ Greater Than or Equal To
207208
+----------------------+
208209
```
209210

211+
(op_spaceship)=
212+
213+
### `<=>`
214+
215+
Three-way comparison operator. A NULL-safe operator that returns true if both operands are equal or both are NULL, false otherwise.
216+
217+
```sql
218+
> SELECT NULL <=> NULL;
219+
+--------------------------------+
220+
| NULL IS NOT DISTINCT FROM NULL |
221+
+--------------------------------+
222+
| true |
223+
+--------------------------------+
224+
```
225+
226+
```sql
227+
> SELECT 1 <=> NULL;
228+
+------------------------------------+
229+
| Int64(1) IS NOT DISTINCT FROM NULL |
230+
+------------------------------------+
231+
| false |
232+
+------------------------------------+
233+
```
234+
235+
```sql
236+
> SELECT 1 <=> 2;
237+
+----------------------------------------+
238+
| Int64(1) IS NOT DISTINCT FROM Int64(2) |
239+
+----------------------------------------+
240+
| false |
241+
+----------------------------------------+
242+
```
243+
244+
```sql
245+
> SELECT 1 <=> 1;
246+
+----------------------------------------+
247+
| Int64(1) IS NOT DISTINCT FROM Int64(1) |
248+
+----------------------------------------+
249+
| true |
250+
+----------------------------------------+
251+
```
252+
210253
### `IS DISTINCT FROM`
211254

212255
Guarantees the result of a comparison is `true` or `false` and not an empty set

0 commit comments

Comments
 (0)