Skip to content

Commit

Permalink
feat: add least and greatest functions
Browse files Browse the repository at this point in the history
  • Loading branch information
richtia committed Sep 2, 2022
1 parent 6b8191f commit cb7759c
Showing 1 changed file with 199 additions and 94 deletions.
293 changes: 199 additions & 94 deletions extensions/functions_comparison.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,178 +3,97 @@
scalar_functions:
-
name: "not_equal"
description: >
Whether two values are not_equal.
`not_equal(x, y) := (x != y)`
If either/both of `x` and `y` are `null`, `null` is returned.
description: Whether two values are not_equal (nulls are considered not not-equal).
impls:
- args:
- value: any1
name: x
- value: any1
name: y
return: BOOLEAN
-
name: "equal"
description: >
Whether two values are equal.
`equal(x, y) := (x == y)`
If either/both of `x` and `y` are `null`, `null` is returned.
description: Whether two values are equal (nulls are considered unequal).
impls:
- args:
- value: any1
name: x
- value: any1
name: y
return: BOOLEAN
-
name: "is_not_distinct_from"
description: >
Whether two values are equal.
This function treats `null` values as comparable, so
`is_not_distinct_from(null, null) == True`
This is in contrast to `equal`, in which `null` values do not compare.
description: Whether two values are equal (nulls are considered equal).
impls:
- args:
- value: any1
name: x
- value: any1
name: y
return: BOOLEAN
-
name: "lt"
description: >
Less than.
lt(x, y) := (x < y)
If either/both of `x` and `y` are `null`, `null` is returned.
description: Less than
impls:
- args:
- value: any1
name: x
- value: any1
name: y
return: BOOLEAN
-
name: "gt"
description: >
Greater than.
gt(x, y) := (x > y)
If either/both of `x` and `y` are `null`, `null` is returned.
description: Greater than
impls:
- args:
- value: any1
name: x
- value: any1
name: y
return: BOOLEAN
-
name: "lte"
description: >
Less than or equal to.
lte(x, y) := (x <= y)
If either/both of `x` and `y` are `null`, `null` is returned.
description: Less than or equal to
impls:
- args:
- value: any1
name: x
- value: any1
name: y
return: BOOLEAN
-
name: "gte"
description: >
Greater than or equal to.
gte(x, y) := (x >= y)
If either/both of `x` and `y` are `null`, `null` is returned.
impls:
- args:
- value: any1
name: x
- value: any1
name: y
return: BOOLEAN
-
name: "between"
description: >-
Whether the `expression` is greater than or equal to `low` and less than or equal to `high`.
`expression` BETWEEN `low` AND `high`
If `low`, `high`, or `expression` are `null`, `null` is returned.
description: Greater than or equal to
impls:
- args:
- value: any1
name: expression
description: The expression to test for in the range defined by `low` and `high`.
- value: any1
name: low
description: The value to check if greater than or equal to.
- value: any1
name: high
description: The value to check if less than or equal to.
return: BOOLEAN
-
name: "is_null"
description: Whether a value is null. NaN is not null.
description: Whether a value is null.
impls:
- args:
- value: any1
name: x
return: BOOLEAN
nullability: DECLARED_OUTPUT
-
name: "is_not_null"
description: Whether a value is not null. NaN is not null.
description: Whether a value is not null.
impls:
- args:
- value: any1
name: x
return: BOOLEAN
nullability: DECLARED_OUTPUT
-
name: "is_nan"
description: >
Whether a value is not a number.
If `x` is `null`, `null` is returned.
description: Whether a value is not a number.
impls:
- args:
- value: fp32
name: x
return: BOOLEAN
- args:
- value: fp64
name: x
return: BOOLEAN
-
name: "is_finite"
description: >
Whether a value is finite (neither infinite nor NaN).
If `x` is `null`, `null` is returned.
description: Whether a value is finite (neither infinite nor NaN).
impls:
- args:
- value: fp32
name: x
nullability: DECLARED_OUTPUT
return: BOOLEAN
- args:
- value: fp64
name: x
nullability: DECLARED_OUTPUT
return: BOOLEAN
-
name: "is_infinite"
Expand Down Expand Up @@ -214,3 +133,189 @@ scalar_functions:
variadic:
min: 2
return: any1
-
name: "least"
description: >-
Returns the smallest value from a list of arguments. Only return null if 'all' arguments evaluate to null.
String comparison is done in lexicographical ordering, one character at a time, from left to right.
Uppercase letters are less than lowercase letters.
impls:
- args:
- value: i8
variadic:
min: 1
return: i8
- args:
- value: i16
variadic:
min: 1
return: i16
- args:
- value: i32
variadic:
min: 1
return: i32
- args:
- value: i64
variadic:
min: 1
return: i64
- args:
- value: fp32
variadic:
min: 1
return: fp32
- args:
- value: fp64
variadic:
min: 1
return: fp64
- args:
- value: "string"
variadic:
min: 1
return: "string"
- args:
- value: binary
variadic:
min: 1
return: binary
- args:
- value: timestamp
variadic:
min: 1
return: timestamp
- args:
- value: timestamp_tz
variadic:
min: 1
return: timestamp_tz
- args:
- value: date
variadic:
min: 1
return: date
- args:
- value: time
variadic:
min: 1
return: time
- args:
- value: uuid
variadic:
min: 1
return: uuid
- args:
- value: "fixedchar<l1>"
variadic:
min: 1
return: "fixedchar<l1>"
- args:
- value: "varchar<L1>"
variadic:
min: 1
return: "varchar<L1>"
- args:
- value: "fixedbinary<L1>"
variadic:
min: 1
return: "fixedbinary<L1>"
- args:
- value: decimal<P1,S1>
variadic:
min: 1
return: decimal<P1,S1>
-
name: "greatest"
description: >-
Returns the largest value from a list of arguments. Only return null if 'all' arguments evaluate to null.
String comparison is done in lexicographical ordering, one character at a time, from left to right.
Uppercase letters are less than lowercase letters.
impls:
- args:
- value: i8
variadic:
min: 1
return: i8
- args:
- value: i16
variadic:
min: 1
return: i16
- args:
- value: i32
variadic:
min: 1
return: i32
- args:
- value: i64
variadic:
min: 1
return: i64
- args:
- value: fp32
variadic:
min: 1
return: fp32
- args:
- value: fp64
variadic:
min: 1
return: fp64
- args:
- value: "string"
variadic:
min: 1
return: "string"
- args:
- value: binary
variadic:
min: 1
return: binary
- args:
- value: timestamp
variadic:
min: 1
return: timestamp
- args:
- value: timestamp_tz
variadic:
min: 1
return: timestamp_tz
- args:
- value: date
variadic:
min: 1
return: date
- args:
- value: time
variadic:
min: 1
return: time
- args:
- value: uuid
variadic:
min: 1
return: uuid
- args:
- value: "fixedchar<l1>"
variadic:
min: 1
return: "fixedchar<l1>"
- args:
- value: "varchar<L1>"
variadic:
min: 1
return: "varchar<L1>"
- args:
- value: "fixedbinary<L1>"
variadic:
min: 1
return: "fixedbinary<L1>"
- args:
- value: decimal<P1,S1>
variadic:
min: 1
return: decimal<P1,S1>

0 comments on commit cb7759c

Please sign in to comment.