Michael-J-Ward commented on code in PR #750:
URL: https://github.com/apache/datafusion-python/pull/750#discussion_r1671263993


##########
python/datafusion/functions.py:
##########
@@ -15,9 +15,1731 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import annotations
 
-from ._internal import functions
+# from datafusion._internal.context import SessionContext
+# from datafusion._internal.expr import Expr
+# from datafusion._internal.expr.conditional_expr import CaseBuilder
+# from datafusion._internal.expr.window import WindowFrame
 
+from datafusion._internal import functions as f, common
+from datafusion.expr import CaseBuilder, Expr, WindowFrame
+from datafusion.context import SessionContext
 
-def __getattr__(name):
-    return getattr(functions, name)
+
+def isnan(expr: Expr) -> Expr:
+    """
+    Returns true if a given number is +NaN or -NaN otherwise returns false.
+    """
+    return Expr(f.isnan(expr.expr))
+
+
+def nullif(expr1: Expr, expr2: Expr) -> Expr:
+    """
+    Returns NULL if expr1 equals expr2; otherwise it returns expr1. This can 
be used to perform the inverse operation of the COALESCE expression.
+    """
+    return Expr(f.nullif(expr1.expr, expr2.expr))
+
+
+def encode(input: Expr, encoding: Expr) -> Expr:
+    """
+    Encode the `input`, using the `encoding`. encoding can be base64 or hex.
+    """
+    return Expr(f.encode(input.expr, encoding.expr))
+
+
+def decode(input: Expr, encoding: Expr) -> Expr:
+    """
+    Decode the `input`, using the `encoding`. encoding can be base64 or hex.
+    """
+    return Expr(f.decode(input.expr, encoding.expr))
+
+
+def array_to_string(expr: Expr, delimiter: Expr) -> Expr:
+    """
+    Converts each element to its text representation.
+    """
+    return Expr(f.array_to_string(expr.expr, delimiter.expr))
+
+
+def array_join(expr: Expr, delimiter: Expr) -> Expr:
+    """
+    Converts each element to its text representation.
+    This is an alias for :func:`array_to_string`.
+    """
+    return array_to_string(expr, delimiter)
+
+
+def list_to_string(expr: Expr, delimiter: Expr) -> Expr:
+    """
+    Converts each element to its text representation.
+    This is an alias for :func:`array_to_string`.
+    """
+    return array_to_string(expr, delimiter)
+
+
+def list_join(expr: Expr, delimiter: Expr) -> Expr:
+    """
+    Converts each element to its text representation.
+    This is an alias for :func:`array_to_string`.
+    """
+    return array_to_string(expr, delimiter)
+
+
+def in_list(arg: Expr, values: list[Expr], negated: bool = False) -> Expr:
+    """
+    Returns whether the argument is contained within the list `values`.
+    """
+    values = [v.expr for v in values]
+    return Expr(f.in_list(arg.expr, values, negated))
+
+
+def digest(value: Expr, method: Expr) -> Expr:
+    """
+    Computes the binary hash of an expression using the specified algorithm.
+    Standard algorithms are md5, sha224, sha256, sha384, sha512, blake2s, 
blake2b, and blake3.
+    """
+    return Expr(f.digest(value.expr, method.expr))
+
+
+def concat(*args: Expr) -> Expr:
+    """
+    Concatenates the text representations of all the arguments. NULL arguments 
are ignored.
+    """
+    args = [arg.expr for arg in args]
+    return Expr(f.concat(*args))
+
+
+def concat_ws(separator: str, *args: Expr) -> Expr:
+    """
+    Concatenates the list `args` with the separator. `NULL` arugments are 
ignored. `separator` should not be `NULL`.
+    """
+    args = [arg.expr for arg in args]
+    return Expr(f.concat_ws(separator, *args))
+
+
+def order_by(expr: Expr, ascending: bool = True, nulls_first: bool = True) -> 
Expr:
+    """
+    Creates a new sort expression.
+    """
+    return Expr(f.order_by(expr.expr, ascending, nulls_first))
+
+
+def alias(expr: Expr, name: str) -> Expr:
+    """
+    Creates an alias expression.
+    """
+    return Expr(f.alias(expr.expr, name))
+
+
+def col(name: str) -> Expr:
+    """
+    Creates a column reference expression.
+    """
+    return Expr(f.col(name))
+
+
+def count_star() -> Expr:
+    """
+    Create a COUNT(1) aggregate expression.
+    """
+    return Expr(f.count_star())
+
+
+def case(expr: Expr) -> CaseBuilder:
+    """
+    Create a CASE WHEN statement with literal WHEN expressions for comparison 
to the base expression.
+    """
+    return CaseBuilder(f.case(expr.expr))
+
+
+def window(
+    name: str,
+    args: list[Expr],
+    partition_by: list[Expr] | None = None,
+    order_by: list[Expr] | None = None,
+    window_frame: WindowFrame | None = None,
+    ctx: SessionContext | None = None,
+) -> Expr:
+    """
+    Creates a new Window function expression.
+    """
+    args = [a.expr for a in args]
+    partition_by = [e.expr for e in partition_by] if partition_by is not None 
else None
+    order_by = [o.expr for o in order_by] if order_by is not None else None
+    window_frame = window_frame.window_frame if window_frame is not None else 
None
+    return Expr(f.window(name, args, partition_by, order_by, window_frame, 
ctx))
+
+
+# scalar functions
+def abs(arg: Expr) -> Expr:
+    """
+    Return the absolute value of a given number.
+
+    Returns
+    -------
+    Expr
+        A new expression representing the absolute value of the input 
expression.
+    """
+    return Expr(f.abs(arg.expr))
+
+
+def acos(arg: Expr) -> Expr:
+    """
+    Returns the arc cosine or inverse cosine of a number.
+
+    Returns
+    -------
+    Expr
+        A new expression representing the arc cosine of the input expression.
+    """
+    return Expr(f.acos(arg.expr))
+
+
+def acosh(arg: Expr) -> Expr:
+    """
+    Returns inverse hyperbolic cosine.
+    """
+    return Expr(f.acosh(arg.expr))
+
+
+def ascii(arg: Expr) -> Expr:
+    """
+    Returns the numeric code of the first character of the argument.
+    """
+    return Expr(f.ascii(arg.expr))
+
+
+def asin(arg: Expr) -> Expr:
+    """
+    Returns the arc sine or inverse sine of a number.
+    """
+    return Expr(f.asin(arg.expr))
+
+
+def asinh(arg: Expr) -> Expr:
+    """
+    Returns inverse hyperbolic sine.
+    """
+    return Expr(f.asinh(arg.expr))
+
+
+def atan(arg: Expr) -> Expr:
+    """
+    Returns inverse tangent of a number.
+    """
+    return Expr(f.atan(arg.expr))
+
+
+def atanh(arg: Expr) -> Expr:
+    """
+    Returns inverse hyperbolic tangent.
+    """
+    return Expr(f.atanh(arg.expr))
+
+
+def atan2(y: Expr, x: Expr) -> Expr:
+    """
+    Returns inverse tangent of a division given in the argument.
+    """
+    return Expr(f.atan2(y.expr, x.expr))
+
+
+def bit_length(arg: Expr) -> Expr:
+    """
+    Returns the number of bits in the string argument.
+    """
+    return Expr(f.bit_length(arg.expr))
+
+
+def btrim(arg: Expr) -> Expr:
+    """
+    Removes all characters, spaces by default, from both sides of a string.
+    """
+    return Expr(f.btrim(arg.expr))
+
+
+def cbrt(arg: Expr) -> Expr:
+    """
+    Returns the cube root of a number.
+    """
+    return Expr(f.cbrt(arg.expr))
+
+
+def ceil(arg: Expr) -> Expr:
+    """
+    Returns the nearest integer greater than or equal to argument.
+    """
+    return Expr(f.ceil(arg.expr))
+
+
+def character_length(arg: Expr) -> Expr:
+    """
+    Returns the number of characters in the argument.
+    """
+    return Expr(f.character_length(arg.expr))
+
+
+def length(string: Expr) -> Expr:
+    """
+    The number of characters in the `string`
+    """
+    return Expr(f.length(string.expr))
+
+
+def char_length(string: Expr) -> Expr:
+    """
+    The number of characters in the `string`.
+    """
+    return Expr(f.char_length(string.expr))
+
+
+def chr(arg: Expr) -> Expr:
+    """
+    Converts the Unicode code point to a UTF8 character.
+    """
+    return Expr(f.chr(arg.expr))
+
+
+def coalesce(*args: Expr) -> Expr:
+    """
+    Returns `coalesce(args...)`, which evaluates to the value of the first 
expr which is not NULL.
+    """
+    args = [arg.expr for arg in args]
+    return Expr(f.coalesce(*args))
+
+
+def cos(arg: Expr) -> Expr:
+    """
+    Returns the cosine of the argument.
+    """
+    return Expr(f.cos(arg.expr))
+
+
+def cosh(arg: Expr) -> Expr:
+    """
+    Returns the hyperbolic cosine of the argument.
+    """
+    return Expr(f.cosh(arg.expr))
+
+
+def cot(arg: Expr) -> Expr:
+    """
+    Returns the cotangent of the argument.
+    """
+    return Expr(f.cot(arg.expr))
+
+
+def degrees(arg: Expr) -> Expr:
+    """
+    Converts the argument from radians to degrees.
+    """
+    return Expr(f.degrees(arg.expr))
+
+
+def ends_with(arg: Expr, suffix: Expr) -> Expr:
+    """
+    Returns true if the `string` ends with the `suffix`, false otherwise.
+    """
+    return Expr(f.ends_with(arg.expr, suffix.expr))
+
+
+def exp(arg: Expr) -> Expr:
+    """
+    Returns the exponential of the arugment.
+    """
+    return Expr(f.exp(arg.expr))
+
+
+def factorial(arg: Expr) -> Expr:
+    """
+    Returns the factorial of the argument.
+    """
+    return Expr(f.factorial(arg.expr))
+
+
+def find_in_set(string: Expr, string_list: Expr) -> Expr:
+    """
+    Returns a value in the range of 1 to N if the string is in the string list 
`string_list` consisting of N substrings.
+    The string list is a string composed of substrings separated by `,` 
characters.
+    """
+    return Expr(f.find_in_set(string.expr, string_list.expr))
+
+
+def floor(arg: Expr) -> Expr:
+    """
+    Returns the nearest integer less than or equal to the argument.
+    """
+    return Expr(f.floor(arg.expr))
+
+
+def gcd(x: Expr, y: Expr) -> Expr:
+    """
+    Returns the greatest common divisor.
+    """
+    return Expr(f.gcd(x.expr, y.expr))
+
+
+def initcap(string: Expr) -> Expr:
+    """
+    Converts the first letter of each word in `string` in uppercase and the 
remaining characters in lowercase.
+    """
+    return Expr(f.initcap(string.expr))
+
+
+def instr(string: Expr, substring: Expr) -> Expr:
+    """
+    Finds the position from where the `substring` matches the `string`.
+    This is an alias for :func:`strpos`.
+    """
+    return strpos(string, substring)
+
+
+def iszero(arg: Expr) -> Expr:
+    """
+    Returns true if a given number is +0.0 or -0.0 otherwise returns false.
+    """
+    return Expr(f.iszero(arg.expr))
+
+
+def lcm(x: Expr, y: Expr) -> Expr:
+    """
+    Returns the least common multiple.
+    """
+    return Expr(f.lcm(x.expr, y.expr))
+
+
+def left(string: Expr, n: Expr) -> Expr:
+    """
+    Returns the first `n` characters in the `string`.
+    """
+    return Expr(f.left(string.expr, n.expr))
+
+
+def levenshtein(string1: Expr, string2: Expr) -> Expr:
+    """
+    Returns the Levenshtein distance between the two given strings
+    """
+    return Expr(f.levenshtein(string1.expr, string2.expr))
+
+
+def ln(arg: Expr) -> Expr:
+    """
+    Returns the natural logarithm (base e) of the argument.
+    """
+    return Expr(f.ln(arg.expr))
+
+
+def log(base: Expr, num: Expr) -> Expr:
+    """
+    Returns the logarithm of a number for a particular `base`
+    """
+    return Expr(f.log(base.expr, num.expr))
+
+
+def log10(arg: Expr) -> Expr:
+    """
+    Base 10 logarithm of the argument.
+    """
+    return Expr(f.log10(arg.expr))
+
+
+def log2(arg: Expr) -> Expr:
+    """
+    Base 2 logarithm of the argument.
+    """
+    return Expr(f.log2(arg.expr))
+
+
+def lower(arg: Expr) -> Expr:
+    """
+    Converts a string to lowercase.
+    """
+    return Expr(f.lower(arg.expr))
+
+
+def lpad(string: Expr, count: Expr, characters: Expr | None = None) -> Expr:
+    """
+    Extends the string to length length by prepending the characters fill (a 
space by default). If the string is already longer than length then it is 
truncated (on the right).
+    """
+    characters = characters if characters is not None else Expr.literal(" ")
+    return Expr(f.lpad(string.expr, count.expr, characters.expr))
+
+
+def ltrim(arg: Expr) -> Expr:
+    """
+    Removes all characters, spaces by default, from the beginning of a string.
+    """
+    return Expr(f.ltrim(arg.expr))
+
+
+def md5(arg: Expr) -> Expr:
+    """
+    Computes an MD5 128-bit checksum for a string expression.
+    """
+    return Expr(f.md5(arg.expr))
+
+
+def nanvl(x: Expr, y: Expr) -> Expr:
+    """
+    Returns `x` if `x` is not `NaN`. Otherwise returns `y`.
+    """
+    return Expr(f.nanvl(x.expr, y.expr))
+
+
+def octet_length(arg: Expr) -> Expr:
+    """
+    Returns the number of bytes of a string.
+    """
+    return Expr(f.octet_length(arg.expr))
+
+
+# TODO: `overlay` in datafusion needs to be updated from generic `args` 
definition, and then exposed in this repo.
+# def overlay(string: Expr, substring: Expr, start: Expr, length: Expr | None 
= None) -> Expr:
+#     """
+#     Replace the substring of string that starts at the `start`'th character 
and extends for `length` characters with new substring
+#     """
+#     return Expr()
+
+
+def pi() -> Expr:
+    """
+    Returns an approximate value of π.
+    """
+    return Expr(f.pi())
+
+
+def position(string: Expr, substring: Expr) -> Expr:
+    """
+    Finds the position from where the `substring` matches the `string`.
+    This is an alias for :func:`strpos`.
+    """
+    return strpos(string, substring)
+
+
+def power(base: Expr, exponent: Expr) -> Expr:
+    """
+    Returns `base` raised to the power of `exponent`.
+    """
+    return Expr(f.power(base.expr, exponent.expr))
+
+
+def pow(base: Expr, exponent: Expr) -> Expr:
+    """
+    Returns `base` raised to the power of `exponent`.
+    This is an alias of `power`.
+    """
+    return power(base, exponent)
+
+
+def radians(arg: Expr) -> Expr:
+    """
+    Converts the argument from degrees to radians.
+    """
+    return Expr(f.radians(arg.expr))
+
+
+def regexp_like(string: Expr, regex: Expr, flags: Expr | None = None) -> Expr:
+    """
+    Tests a string using a regular expression returning true if at
+    least one match, false otherwise.
+    """
+    if flags is not None:
+        flags = flags.expr
+    return Expr(f.regexp_like(string.expr, regex.expr, flags))
+
+
+def regexp_match(string: Expr, regex: Expr, flags: Expr | None = None) -> Expr:
+    """
+    Returns an array with each element containing the leftmost-first
+    match of the corresponding index in `regex` to string in `string`
+
+    If there is no match, the list element is NULL.
+
+    If a match is found, and the pattern contains no capturing parenthesized 
subexpressions,
+    then the list element is a single-element [`GenericStringArray`] 
containing the substring
+    matching the whole pattern.
+
+    If a match is found, and the pattern contains capturing parenthesized 
subexpressions, then the
+    list element is a [`GenericStringArray`] whose n'th element is the 
substring matching
+    the n'th capturing parenthesized subexpression of the pattern.
+    """
+
+    # TODO VALIDATE THIS IS CORRECT FOR DATAFRAME RESULTS
+    if flags is not None:
+        flags = flags.expr
+    return Expr(f.regexp_match(string.expr, regex.expr, flags))
+
+
+def regexp_replace(
+    string: Expr, pattern: Expr, replacement: Expr, flags: Expr | None = None
+) -> Expr:
+    """
+    Replaces substring(s) matching a PCRE-like regular expression.
+
+    The full list of supported features and syntax can be found at
+    <https://docs.rs/regex/latest/regex/#syntax>
+
+    Supported flags with the addition of 'g' can be found at
+    <https://docs.rs/regex/latest/regex/#grouping-and-flags>
+    """
+    if flags is not None:
+        flags = flags.expr
+    return Expr(f.regexp_replace(string.expr, pattern.expr, replacement.expr, 
flags))
+
+
+def repeat(string: Expr, n: Expr) -> Expr:
+    """
+    Repeats the `string` to `n` times.
+    """
+    return Expr(f.repeat(string.expr, n.expr))
+
+
+def replace(string: Expr, from_val: Expr, to_val: Expr) -> Expr:
+    """
+    Replaces all occurrences of `from` with `to` in the `string`.
+    """
+    return Expr(f.replace(string.expr, from_val.expr, to_val.expr))
+
+
+def reverse(arg: Expr) -> Expr:
+    """
+    Reverse the string argument.
+    """
+    return Expr(f.reverse(arg.expr))
+
+
+def right(string: Expr, n: Expr) -> Expr:
+    """
+    Returns the last `n` characters in the `string`.
+    """
+    return Expr(f.right(string.expr, n.expr))
+
+
+def round(arg: Expr) -> Expr:
+    """
+    Round the argument to the nearest integer.
+    """
+    return Expr(f.round(arg.expr))
+
+
+def rpad(string: Expr, count: Expr, characters: Expr | None = None) -> Expr:
+    """
+    Extends the string to length length by appending the characters fill (a 
space by default). If the string is already longer than length then it is 
truncated.
+    """
+    characters = characters if characters is not None else Expr.literal(" ")
+    return Expr(f.rpad(string.expr, count.expr, characters.expr))
+
+
+def rtrim(arg: Expr) -> Expr:
+    """
+    Removes all characters, spaces by default, from the end of a string.
+    """
+    return Expr(f.rtrim(arg.expr))
+
+
+def sha224(arg: Expr) -> Expr:
+    """
+    Computes the SHA-224 hash of a binary string.
+    """
+    return Expr(f.sha224(arg.expr))
+
+
+def sha256(arg: Expr) -> Expr:
+    """
+    Computes the SHA-256 hash of a binary string.
+    """
+    return Expr(f.sha256(arg.expr))
+
+
+def sha384(arg: Expr) -> Expr:
+    """
+    Computes the SHA-384 hash of a binary string.
+    """
+    return Expr(f.sha384(arg.expr))
+
+
+def sha512(arg: Expr) -> Expr:
+    """
+    Computes the SHA-512 hash of a binary string.
+    """
+    return Expr(f.sha512(arg.expr))
+
+
+def signum(arg: Expr) -> Expr:
+    """
+    Returns the sign of the argument (-1, 0, +1).
+    """
+    return Expr(f.signum(arg.expr))
+
+
+def sin(arg: Expr) -> Expr:
+    """
+    Returns the sine of the argument.
+    """
+    return Expr(f.sin(arg.expr))
+
+
+def sinh(arg: Expr) -> Expr:
+    """
+    Returns the hyperbolic sine of the argument.
+    """
+    return Expr(f.sinh(arg.expr))
+
+
+def split_part(string: Expr, delimiter: Expr, index: Expr) -> Expr:
+    """
+    Splits a string based on a delimiter and picks out the desired field based 
on the index.
+    """
+    return Expr(f.split_part(string.expr, delimiter.expr, index.expr))
+
+
+def sqrt(arg: Expr) -> Expr:
+    """
+    Returns the square root of the argument.
+    """
+    return Expr(f.sqrt(arg.expr))
+
+
+def starts_with(string: Expr, prefix: Expr) -> Expr:
+    """
+    Returns true if string starts with prefix.
+    """
+    return Expr(f.starts_with(string.expr, prefix.expr))
+
+
+def strpos(string: Expr, substring: Expr) -> Expr:
+    """
+    Finds the position from where the `substring` matches the `string`.
+    """
+    return Expr(f.strpos(string.expr, substring.expr))
+
+
+def substr(string: Expr, position: Expr) -> Expr:
+    """
+    Substring from the `position` to the end.
+    """
+    return Expr(f.substr(string.expr, position.expr))
+
+
+def substr_index(string: Expr, delimiter: Expr, count: Expr) -> Expr:
+    """
+    Returns the substring from `string` before `count` occurrences of 
`delimiter`.
+    """
+    return Expr(f.substr_index(string.expr, delimiter.expr, count.expr))
+
+
+def substring(string: Expr, position: Expr, length: Expr) -> Expr:
+    """
+    Substring from the `position` with `length` characters.
+    """
+    return Expr(f.substring(string.expr, position.expr, length.expr))
+
+
+def tan(arg: Expr) -> Expr:
+    """
+    Returns the tangent of the argument.
+    """
+    return Expr(f.tan(arg.expr))
+
+
+def tanh(arg: Expr) -> Expr:
+    """
+    Returns the hyperbolic tangent of the argument.
+    """
+    return Expr(f.tanh(arg.expr))
+
+
+def to_hex(arg: Expr) -> Expr:
+    """
+    Converts an integer to a hexadecimal string.
+    """
+    return Expr(f.to_hex(arg.expr))
+
+
+def now() -> Expr:
+    """
+    Returns the current timestamp in nanoseconds, using the same value for all 
instances of now() in same statement.
+    """
+    return Expr(f.now())
+
+
+def to_timestamp(arg: Expr, *formatters: Expr) -> Expr:
+    """
+    Converts a string and optional formats to a `Timestamp` in nanoseconds.
+    """
+    # TODO Add a detailed description of how to use formatters.
+    if formatters is None:
+        return f.to_timestamp(arg.expr)
+
+    formatters = [f.expr for f in formatters]
+    return Expr(f.to_timestamp(arg.expr, *formatters))
+
+
+def to_timestamp_millis(arg: Expr, *formatters: Expr) -> Expr:
+    """
+    Converts a string and optional formats to a `Timestamp` in milliseconds.
+    See `to_timestamp` for a description on how to use formatters.
+    """
+    return Expr(f.to_timestamp_millis(arg.expr, *formatters))
+
+
+def to_timestamp_micros(arg: Expr, *formatters: Expr) -> Expr:
+    """
+    Converts a string and optional formats to a `Timestamp` in microseconds.
+    See `to_timestamp` for a description on how to use formatters.
+    """
+    return Expr(f.to_timestamp_micros(arg.expr, *formatters))
+
+
+def to_timestamp_nanos(arg: Expr, *formatters: Expr) -> Expr:
+    """
+    Converts a string and optional formats to a `Timestamp` in nanoseconds.
+    See `to_timestamp` for a description on how to use formatters.
+    """
+    return Expr(f.to_timestamp_nanos(arg.expr, *formatters))
+
+
+def to_timestamp_seconds(arg: Expr, *formatters: Expr) -> Expr:
+    """
+    Converts a string and optional formats to a `Timestamp` in seconds.
+    See `to_timestamp` for a description on how to use formatters.
+    """
+    return Expr(f.to_timestamp_seconds(arg.expr, *formatters))
+
+
+def to_unixtime(string: Expr, *format_arguments: Expr) -> Expr:
+    """
+    Converts a string and optional formats to a Unixtime.
+    """
+    # TODO verify if the format arguments are the same as to_timestamp and 
update documentation appropriately.
+    args = [f.expr for f in format_arguments]
+    return Expr(f.to_unixtime(string.expr, *args))
+
+
+def current_date() -> Expr:
+    """
+    Returns current UTC date as a Date32 value.
+    """
+    return Expr(f.current_date())
+
+
+def current_time() -> Expr:
+    """
+    Returns current UTC time as a Time64 value.
+    """
+    return Expr(f.current_time())
+
+
+def datepart(part: Expr, date: Expr) -> Expr:
+    """
+    Return a specified part of a date.
+    This is an alias for `date_part`.
+    """
+    return date_part(part, date)
+
+
+def date_part(part: Expr, date: Expr) -> Expr:
+    """
+    Extracts a subfield from the date.
+    """
+    return Expr(f.date_part(part.expr, date.expr))
+
+
+def date_trunc(part: Expr, date: Expr) -> Expr:
+    """
+    Truncates the date to a specified level of precision.
+    """
+    return Expr(f.date_trunc(part.expr, date.expr))
+
+
+def datetrunc(part: Expr, date: Expr) -> Expr:
+    """
+    Truncates the date to a specified level of precision.
+    This is an alias for `date_trunc`.
+    """
+    return date_trunc(part, date)
+
+
+def date_bin(stride: Expr, source: Expr, origin: Expr) -> Expr:
+    """
+    Coerces an arbitrary timestamp to the start of the nearest specified 
interval.
+    """
+    return Expr(f.date_bin(stride.expr, source.expr, origin.expr))
+
+
+def make_date(year: Expr, month: Expr, day: Expr) -> Expr:
+    """
+    Make a date from year, month and day component parts.
+    """
+    return Expr(f.make_date(year.expr, month.expr, day.expr))
+
+
+def translate(string: Expr, from_val: Expr, to_val: Expr) -> Expr:
+    """
+    Replaces the characters in `from_val` with the counterpart in `to_val`.
+    """
+    return Expr(f.translate(string.expr, from_val.expr, to_val.expr))
+
+
+def trim(arg: Expr) -> Expr:
+    """
+    Removes all characters, spaces by default, from both sides of a string.
+    """
+    return Expr(f.trim(arg.expr))
+
+
+def trunc(num: Expr, precision: Expr | None = None) -> Expr:
+    """
+    Truncate the number toward zero with optional precision.
+    """
+    if precision is not None:
+        return Expr(f.trunc(num.expr, precision.expr))
+    return Expr(f.trunc(num.expr))
+
+
+def upper(arg: Expr) -> Expr:
+    """
+    Converts a string to uppercase.
+    """
+    return Expr(f.upper(arg.expr))
+
+
+def make_array(*args: Expr) -> Expr:
+    """
+    Returns an array using the specified input expressions.
+    """
+    args = [arg.expr for arg in args]
+    return Expr(f.make_array(*args))
+
+
+def array(*args: Expr) -> Expr:
+    """
+    Returns an array using the specified input expressions.
+    This is an alias for `make_array`.
+    """
+    return make_array(args)
+
+
+def range(start: Expr, stop: Expr, step: Expr) -> Expr:
+    """
+    Create a list of values in the range between start and stop.
+    """
+    return Expr(f.range(start.expr, stop.expr, step.expr))
+
+
+def uuid(arg: Expr) -> Expr:
+    """
+    Returns uuid v4 as a string value.
+    """
+    return Expr(f.uuid(arg.expr))
+
+
+def struct(*args: Expr) -> Expr:
+    """
+    Returns a struct with the given arguments.
+    """
+    args = [arg.expr for arg in args]
+    return Expr(f.struct(*args))
+
+
+def named_struct(name_pairs: list[(str, Expr)]) -> Expr:

Review Comment:
   Great improvement to the clunk Rust API for `named_struct`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to