Skip to content

Commit

Permalink
feat: add arithmetic function for bitwise(AND/OR/XOR) operation with …
Browse files Browse the repository at this point in the history
…decimal arguments (#675)
  • Loading branch information
anshuldata authored Aug 1, 2024
1 parent d9fb1e3 commit a70cf72
Showing 1 changed file with 40 additions and 2 deletions.
42 changes: 40 additions & 2 deletions extensions/functions_arithmetic_decimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,53 @@ scalar_functions:
scale_after_borrow = max(init_scale - delta, min_scale)
scale = init_prec > 38 ? scale_after_borrow : init_scale
DECIMAL<prec, scale>
-
-
name: "abs"
description: Calculate the absolute value of the argument.
impls:
- args:
- name: x
value: decimal<P,S>
return: decimal<P,S>

- name: "bitwise_and"
description: >
Return the bitwise AND result for two decimal inputs.
In inputs scale must be 0 (i.e. only integer types are allowed)
impls:
- args:
- name: x
value: "DECIMAL<P1,0>"
- name: y
value: "DECIMAL<P2,0>"
return: |-
max_precision = max(P1, P2)
DECIMAL<max_precision, 0>
- name: "bitwise_or"
description: >
Return the bitwise OR result for two given decimal inputs.
In inputs scale must be 0 (i.e. only integer types are allowed)
impls:
- args:
- name: x
value: "DECIMAL<P1,0>"
- name: y
value: "DECIMAL<P2,0>"
return: |-
max_precision = max(P1, P2)
DECIMAL<max_precision, 0>
- name: "bitwise_xor"
description: >
Return the bitwise XOR result for two given decimal inputs.
In inputs scale must be 0 (i.e. only integer types are allowed)
impls:
- args:
- name: x
value: "DECIMAL<P1,0>"
- name: y
value: "DECIMAL<P2,0>"
return: |-
max_precision = max(P1, P2)
DECIMAL<max_precision, 0>
aggregate_functions:
- name: "sum"
description: Sum a set of values.
Expand Down

0 comments on commit a70cf72

Please sign in to comment.