Skip to content

Commit

Permalink
wiki
Browse files Browse the repository at this point in the history
  • Loading branch information
yliuuuu committed Sep 27, 2023
1 parent fbeb45e commit 1d79af5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,29 @@ Example
CAST(5 as decimal(3,2)) % CAST(2 as DECIMAL(3,2)) -- 1
-- IN HONOR PARAMETER MODE
CAST(5 as decimal(3,2)) % CAST(2 as DECIMAL(3,2)) -- 1.00
```

### Bitwise And
Performs a bitwise logical AND operation between two integer values.

Syntax
: `expression & expression`

Example:
```sql
2 & 6 -- 0010 & 0110 = 0010 = 2
```

Return Type:
: If one operand is of `INT` type, returns `INT` type.
: Else if one operand is of INT8 type, returns `INT8` type.
: Else if one operand is of INT4 type, returns `INT4` type.
: Else return `INT2` type.

Note:
: Type precedence of the bitwise operator is lower than the plus/minus operator and higher than the predicates.

```sql
2 & 6 + 1 -- 2 & (6 + 1) = 2 & 7 = 2
(2 & 6) + 1 -- 2 + 1 = 3
```
2 changes: 1 addition & 1 deletion partiql-parser/src/main/antlr/PartiQL.g4
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ joinType
* 2. Unary plus, minus (ex: -a, +a)
* 3. Multiplication, Division, Modulo (ex: a * b)
* 4. Addition, Subtraction (ex: a + b)
* 5. Other operators (ex: a || b)
* 5. Other operators (ex: a || b, a & b)
* 6. Predicates (ex: a LIKE b, a < b, a IN b, a = b)
* 7. IS true/false. Not yet implemented in PartiQL, but defined in SQL-92. (ex: a IS TRUE)
* 8. NOT (ex: NOT a)
Expand Down

0 comments on commit 1d79af5

Please sign in to comment.