From 176a1d982231258b819b5649d059c6b62cd6e6fa Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Wed, 24 Jul 2024 16:11:21 -0700 Subject: [PATCH 1/7] Batch04 - Bitwise numeric functions --- docs/querying/sql-functions.md | 168 ++++++++++++++++++++++++++++----- 1 file changed, 145 insertions(+), 23 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index f5219f6a4b27..f4bb8b6c64c9 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -336,68 +336,190 @@ Performs a bitwise XOR operation on all input values. ## BITWISE_AND -`BITWISE_AND(expr1, expr2)` +Returns the bitwise AND between two expressions, that is, `expr1 & expr2`. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +* **Syntax:** `BITWISE_AND(expr1, expr2)` +* **Function type:** Scalar, numeric -Returns the bitwise AND between the two expressions, that is, `expr1 & expr2`. +
Example -## BITWISE_COMPLEMENT +The following example performs the bitwise AND operation `12 & 10`. -`BITWISE_COMPLEMENT(expr)` +```sql +SELECT BITWISE_AND(12, 10) AS "bitwise_and" +``` +Returns the following: -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +| `bitwise_and` | +| -- | +| 8 | +
+ +[Learn more](sql-scalar.md#numeric-functions) + +## BITWISE_COMPLEMENT Returns the bitwise NOT for the expression, that is, `~expr`. -## BITWISE_CONVERT_DOUBLE_TO_LONG_BITS +* **Syntax:** `BITWISE_COMPLEMENT(expr)` +* **Function type:** Scalar, numeric + +
Example -`BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(expr)` +The following example performs the bitwise complement operation `~12`. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +```sql +SELECT BITWISE_COMPLEMENT(12) AS "bitwise_complement" +``` +Returns the following: + +| `bitwise_complement` | +| -- | +| -13 | +
+ +[Learn more](sql-scalar.md#numeric-functions) + +## BITWISE_CONVERT_DOUBLE_TO_LONG_BITS Converts the bits of an IEEE 754 floating-point double value to a long. -## BITWISE_CONVERT_LONG_BITS_TO_DOUBLE +* **Syntax:**`BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(expr)` +* **Function type:** Scalar, numeric -`BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(expr)` +
Example -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +The following example returns the IEEE 754 floating-point double representation of 255 as a long. + +```sql +SELECT BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(255) AS "ieee_754_double_to_long" +``` +Returns the following: + +| `ieee_754_double_to_long` | +| -- | +| `4643176031446892544` | +
+ +[Learn more](sql-scalar.md#numeric-functions) + +## BITWISE_CONVERT_LONG_BITS_TO_DOUBLE Converts a long to the IEEE 754 floating-point double specified by the bits stored in the long. -## BITWISE_OR +* **Syntax:**`BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(expr)` +* **Function type:** Scalar, numeric -`BITWISE_OR(expr1, expr2)` +
Example -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +The following example returns the long representation of 4643176031446892544 as an IEEE 754 floating-point double. + +```sql +SELECT BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(4643176031446892544) AS "long_to_ieee_754_double" +``` +Returns the following: + +| `long_to_ieee_754_double` | +| -- | +| `255` | +
+ +[Learn more](sql-scalar.md#numeric-functions) + +## BITWISE_OR Returns the bitwise OR between the two expressions, that is, `expr1 | expr2`. +* **Syntax:** `BITWISE_OR(expr1, expr2)` +* **Function type:** Scalar, numeric + +
Example + +The following example performs the bitwise OR operation `12 | 10`. + +```sql +SELECT BITWISE_OR(12, 10) AS "bitwise_or" +``` +Returns the following: + +| `bitwise_or` | +| -- | +| `14` | +
+ +[Learn more](sql-scalar.md#numeric-functions) + ## BITWISE_SHIFT_LEFT -`BITWISE_SHIFT_LEFT(expr1, expr2)` +Returns x bitwise left shifts of an expr, That is, `expr << x`. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +* **Syntax:** `BITWISE_SHIFT_LEFT(expr, x)` +* **Function type:** Scalar, numeric + +
Example + +The following example performs the bitwise SHIFT operation `2 << 3`. + +```sql +SELECT BITWISE_SHIFT_LEFT(2, 3) AS "bitwise_shift_left" +``` +Returns the following: -Returns a bitwise left shift of expr1, that is, `expr1 << expr2`. +| `bitwise_shift_left` | +| -- | +| `16` | +
+ +[Learn more](sql-scalar.md#numeric-functions) ## BITWISE_SHIFT_RIGHT `BITWISE_SHIFT_RIGHT(expr1, expr2)` -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +Returns x bitwise right shifts of an expr, That is, `expr >> x`. -Returns a bitwise right shift of expr1, that is, `expr1 >> expr2`. +* **Syntax:** `BITWISE_SHIFT_RIGHT(expr, x)` +* **Function type:** Scalar, numeric -## BITWISE_XOR +
Example -`BITWISE_XOR(expr1, expr2)` +The following example performs the bitwise SHIFT operation `16 >> 3`. -**Function type:** [Scalar, numeric](sql-scalar.md#numeric-functions) +```sql +SELECT BITWISE_SHIFT_RIGHT(16, 3) AS "bitwise_shift_right" +``` +Returns the following: + +| `bitwise_shift_left` | +| -- | +| `2` | +
+ +[Learn more](sql-scalar.md#numeric-functions) + +## BITWISE_XOR Returns the bitwise exclusive OR between the two expressions, that is, `expr1 ^ expr2`. +* **Syntax:** `BITWISE_XOR(expr1, expr2)` +* **Function type:** Scalar, numeric + +
Example + +The following example performs the bitwise XOR operation `12 ^ 10`. + +```sql +SELECT BITWISE_XOR(12, 10) AS "bitwise_xor" +``` +Returns the following: + +| `bitwise_xor` | +| -- | +| `6` | +
+ +[Learn more](sql-scalar.md#numeric-functions) + ## BLOOM_FILTER `BLOOM_FILTER(expr, )` From db36cc5fa7bd72bde9c94a50d946714d005c84c3 Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Wed, 24 Jul 2024 16:41:37 -0700 Subject: [PATCH 2/7] Batch04 - Bitwise numeric functions --- docs/querying/sql-functions.md | 42 ++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index f4bb8b6c64c9..87fde40d6798 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -382,7 +382,26 @@ Returns the following: ## BITWISE_CONVERT_DOUBLE_TO_LONG_BITS -Converts the bits of an IEEE 754 floating-point double value to a long. +Converts the bits of an IEEE 754 floating-point double value to long. + +* **Syntax:**`BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(expr)` +* **Function type:** Scalar, numeric + +
Example + +The following example returns the IEEE 754 floating-point double representation of 255 as a long. + +```sql +SELECT BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(255) AS "ieee_754_double_to_long" +``` +Returns the following: + +| `ieee_754_double_to_long` | +| -- | +| `4643176031446892544` | +
+ +[Learn more](sql-scalar.md#numeric-functions) * **Syntax:**`BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(expr)` * **Function type:** Scalar, numeric @@ -405,7 +424,26 @@ Returns the following: ## BITWISE_CONVERT_LONG_BITS_TO_DOUBLE -Converts a long to the IEEE 754 floating-point double specified by the bits stored in the long. +Converts the bits of a long to IEEE 754 floating-point double. + +* **Syntax:**`BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(expr)` +* **Function type:** Scalar, numeric + +
Example + +The following example returns the long representation of 4643176031446892544 as an IEEE 754 floating-point double. + +```sql +SELECT BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(4643176031446892544) AS "long_to_ieee_754_double" +``` +Returns the following: + +| `long_to_ieee_754_double` | +| -- | +| `255` | +
+ +[Learn more](sql-scalar.md#numeric-functions) * **Syntax:**`BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(expr)` * **Function type:** Scalar, numeric From b93c841d674ae4b19990636511abb819eb25ea3c Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Thu, 25 Jul 2024 15:09:40 -0700 Subject: [PATCH 3/7] minor fixes --- docs/querying/sql-functions.md | 49 ++++------------------------------ 1 file changed, 5 insertions(+), 44 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 87fde40d6798..f829d08eeae9 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -359,7 +359,7 @@ Returns the following: ## BITWISE_COMPLEMENT -Returns the bitwise NOT for the expression, that is, `~expr`. +Returns the bitwise complement (bitwise not) for the expression, that is, `~expr`. * **Syntax:** `BITWISE_COMPLEMENT(expr)` * **Function type:** Scalar, numeric @@ -389,7 +389,7 @@ Converts the bits of an IEEE 754 floating-point double value to long.
Example -The following example returns the IEEE 754 floating-point double representation of 255 as a long. +The following example returns the IEEE 754 floating-point double representation of `255` as a long. ```sql SELECT BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(255) AS "ieee_754_double_to_long" @@ -403,54 +403,17 @@ Returns the following: [Learn more](sql-scalar.md#numeric-functions) -* **Syntax:**`BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(expr)` -* **Function type:** Scalar, numeric - -
Example - -The following example returns the IEEE 754 floating-point double representation of 255 as a long. - -```sql -SELECT BITWISE_CONVERT_DOUBLE_TO_LONG_BITS(255) AS "ieee_754_double_to_long" -``` -Returns the following: - -| `ieee_754_double_to_long` | -| -- | -| `4643176031446892544` | -
- -[Learn more](sql-scalar.md#numeric-functions) ## BITWISE_CONVERT_LONG_BITS_TO_DOUBLE -Converts the bits of a long to IEEE 754 floating-point double. +Converts the bits of a long value to IEEE 754 floating-point double. * **Syntax:**`BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(expr)` * **Function type:** Scalar, numeric
Example -The following example returns the long representation of 4643176031446892544 as an IEEE 754 floating-point double. - -```sql -SELECT BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(4643176031446892544) AS "long_to_ieee_754_double" -``` -Returns the following: - -| `long_to_ieee_754_double` | -| -- | -| `255` | -
- -[Learn more](sql-scalar.md#numeric-functions) - -* **Syntax:**`BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(expr)` -* **Function type:** Scalar, numeric - -
Example - -The following example returns the long representation of 4643176031446892544 as an IEEE 754 floating-point double. +The following example returns the long representation of `4643176031446892544` as an IEEE 754 floating-point double. ```sql SELECT BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(4643176031446892544) AS "long_to_ieee_754_double" @@ -512,8 +475,6 @@ Returns the following: ## BITWISE_SHIFT_RIGHT -`BITWISE_SHIFT_RIGHT(expr1, expr2)` - Returns x bitwise right shifts of an expr, That is, `expr >> x`. * **Syntax:** `BITWISE_SHIFT_RIGHT(expr, x)` @@ -528,7 +489,7 @@ SELECT BITWISE_SHIFT_RIGHT(16, 3) AS "bitwise_shift_right" ``` Returns the following: -| `bitwise_shift_left` | +| `bitwise_shift_right` | | -- | | `2` |
From be615eaf18bbd54b63bfb9a9ef453ef657594db9 Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Fri, 26 Jul 2024 11:25:41 -0700 Subject: [PATCH 4/7] rewording bitwise_shift functions --- docs/querying/sql-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index f829d08eeae9..9ab6430a1907 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -452,7 +452,7 @@ Returns the following: ## BITWISE_SHIFT_LEFT -Returns x bitwise left shifts of an expr, That is, `expr << x`. +Returns bitwise left shift by x positions of an expr, That is, `expr << x`. * **Syntax:** `BITWISE_SHIFT_LEFT(expr, x)` * **Function type:** Scalar, numeric @@ -475,7 +475,7 @@ Returns the following: ## BITWISE_SHIFT_RIGHT -Returns x bitwise right shifts of an expr, That is, `expr >> x`. +Returns bitwise right shift by x positions of an expr, That is, `expr >> x`. * **Syntax:** `BITWISE_SHIFT_RIGHT(expr, x)` * **Function type:** Scalar, numeric From ce6f1f3d1559b55719d820396a779e2e40e6bb6c Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Fri, 26 Jul 2024 11:26:44 -0700 Subject: [PATCH 5/7] rewording bitwise_shift functions --- docs/querying/sql-functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 9ab6430a1907..39488eb85aa5 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -452,7 +452,7 @@ Returns the following: ## BITWISE_SHIFT_LEFT -Returns bitwise left shift by x positions of an expr, That is, `expr << x`. +Returns the bitwise left shift by x positions of an expr, that is, `expr << x`. * **Syntax:** `BITWISE_SHIFT_LEFT(expr, x)` * **Function type:** Scalar, numeric @@ -475,7 +475,7 @@ Returns the following: ## BITWISE_SHIFT_RIGHT -Returns bitwise right shift by x positions of an expr, That is, `expr >> x`. +Returns the bitwise right shift by x positions of an expr, that is, `expr >> x`. * **Syntax:** `BITWISE_SHIFT_RIGHT(expr, x)` * **Function type:** Scalar, numeric From 633a174e378be7610833e4c813eb0cf016c77346 Mon Sep 17 00:00:00 2001 From: Benedict Jin Date: Mon, 29 Jul 2024 15:08:29 +0800 Subject: [PATCH 6/7] Update docs/querying/sql-functions.md --- docs/querying/sql-functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 39488eb85aa5..8191778bc784 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -413,7 +413,7 @@ Converts the bits of a long value to IEEE 754 floating-point double.
Example -The following example returns the long representation of `4643176031446892544` as an IEEE 754 floating-point double. +The following example returns the long representation of `4643176031446892544` as an IEEE 754 floating-point double. ```sql SELECT BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(4643176031446892544) AS "long_to_ieee_754_double" From 399a4c95d1435b434304ed913f0e1d3ef39850fd Mon Sep 17 00:00:00 2001 From: edgar2020 Date: Mon, 29 Jul 2024 13:38:12 -0700 Subject: [PATCH 7/7] applying suggestions --- docs/querying/sql-functions.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/querying/sql-functions.md b/docs/querying/sql-functions.md index 8191778bc784..b749d79d6c45 100644 --- a/docs/querying/sql-functions.md +++ b/docs/querying/sql-functions.md @@ -336,7 +336,7 @@ Performs a bitwise XOR operation on all input values. ## BITWISE_AND -Returns the bitwise AND between two expressions, that is, `expr1 & expr2`. +Returns the bitwise AND between two expressions: `expr1 & expr2`. * **Syntax:** `BITWISE_AND(expr1, expr2)` * **Function type:** Scalar, numeric @@ -359,7 +359,7 @@ Returns the following: ## BITWISE_COMPLEMENT -Returns the bitwise complement (bitwise not) for the expression, that is, `~expr`. +Returns the bitwise complement (bitwise not) for the expression: `~expr`. * **Syntax:** `BITWISE_COMPLEMENT(expr)` * **Function type:** Scalar, numeric @@ -406,7 +406,7 @@ Returns the following: ## BITWISE_CONVERT_LONG_BITS_TO_DOUBLE -Converts the bits of a long value to IEEE 754 floating-point double. +Converts a long to the IEEE 754 floating-point double specified by the bits stored in the long. * **Syntax:**`BITWISE_CONVERT_LONG_BITS_TO_DOUBLE(expr)` * **Function type:** Scalar, numeric @@ -429,7 +429,7 @@ Returns the following: ## BITWISE_OR -Returns the bitwise OR between the two expressions, that is, `expr1 | expr2`. +Returns the bitwise OR between the two expressions: `expr1 | expr2`. * **Syntax:** `BITWISE_OR(expr1, expr2)` * **Function type:** Scalar, numeric @@ -452,7 +452,7 @@ Returns the following: ## BITWISE_SHIFT_LEFT -Returns the bitwise left shift by x positions of an expr, that is, `expr << x`. +Returns the bitwise left shift by x positions of an expr: `expr << x`. * **Syntax:** `BITWISE_SHIFT_LEFT(expr, x)` * **Function type:** Scalar, numeric @@ -475,7 +475,7 @@ Returns the following: ## BITWISE_SHIFT_RIGHT -Returns the bitwise right shift by x positions of an expr, that is, `expr >> x`. +Returns the bitwise right shift by x positions of an expr: `expr >> x`. * **Syntax:** `BITWISE_SHIFT_RIGHT(expr, x)` * **Function type:** Scalar, numeric @@ -498,7 +498,7 @@ Returns the following: ## BITWISE_XOR -Returns the bitwise exclusive OR between the two expressions, that is, `expr1 ^ expr2`. +Returns the bitwise exclusive OR between the two expressions: `expr1 ^ expr2`. * **Syntax:** `BITWISE_XOR(expr1, expr2)` * **Function type:** Scalar, numeric