From 3fb45abe2739fb8084f56dccafa2e83fb1cb0974 Mon Sep 17 00:00:00 2001 From: Richard Tia Date: Fri, 2 Sep 2022 15:01:42 -0500 Subject: [PATCH] refactor: update functions to use List --- extensions/functions_comparison.yaml | 284 ++++++++++----------------- 1 file changed, 101 insertions(+), 183 deletions(-) diff --git a/extensions/functions_comparison.yaml b/extensions/functions_comparison.yaml index 32cd8fe59..434bcf066 100644 --- a/extensions/functions_comparison.yaml +++ b/extensions/functions_comparison.yaml @@ -3,97 +3,178 @@ scalar_functions: - name: "not_equal" - description: Whether two values are not_equal (nulls are considered not 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. impls: - args: - value: any1 + name: x - value: any1 + name: y return: BOOLEAN - name: "equal" - description: Whether two values are equal (nulls are considered unequal). + description: > + Whether two values are equal. + + `equal(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: "is_not_distinct_from" - description: Whether two values are equal (nulls are considered equal). + 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. impls: - args: - value: any1 + name: x - value: any1 + name: y return: BOOLEAN - name: "lt" - description: Less than + description: > + Less than. + + lt(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: "gt" - description: Greater than + description: > + Greater than. + + gt(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: "lte" - description: Less than or equal to + description: > + Less than or equal to. + + lte(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: "gte" - description: Greater than or equal to + 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. 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. + description: Whether a value is null. NaN is not null. impls: - args: - value: any1 + name: x return: BOOLEAN nullability: DECLARED_OUTPUT - name: "is_not_null" - description: Whether a value is not null. + description: Whether a value is not null. NaN 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. + description: > + Whether a value is not a number. + + If `x` is `null`, `null` is returned. 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). + description: > + Whether a value is finite (neither infinite nor NaN). + + If `x` is `null`, `null` is returned. impls: - args: - value: fp32 - nullability: DECLARED_OUTPUT + name: x return: BOOLEAN - args: - value: fp64 - nullability: DECLARED_OUTPUT + name: x return: BOOLEAN - name: "is_infinite" @@ -136,186 +217,23 @@ scalar_functions: - name: "least" description: >- - Returns the smallest value from a list of arguments. Only return null if 'all' arguments evaluate to null. + Returns the smallest value in `List`. 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" - variadic: - min: 1 - return: "fixedchar" - - args: - - value: "varchar" - variadic: - min: 1 - return: "varchar" - - args: - - value: "fixedbinary" - variadic: - min: 1 - return: "fixedbinary" - - args: - - value: decimal - variadic: - min: 1 - return: decimal + - value: List + return: T + - name: "greatest" description: >- - Returns the largest value from a list of arguments. Only return null if 'all' arguments evaluate to null. + Returns the largest value in `List`. 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" - variadic: - min: 1 - return: "fixedchar" - - args: - - value: "varchar" - variadic: - min: 1 - return: "varchar" - - args: - - value: "fixedbinary" - variadic: - min: 1 - return: "fixedbinary" - - args: - - value: decimal - variadic: - min: 1 - return: decimal + - value: List + return: T