Skip to content

Commit 5a7f638

Browse files
authored
Add expression chaining of single parameter scalar functions
1 parent 00dea11 commit 5a7f638

File tree

1 file changed

+289
-0
lines changed

1 file changed

+289
-0
lines changed

python/datafusion/expr.py

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
from typing import TYPE_CHECKING, Any, ClassVar, Optional
2626

27+
import functions as F
2728
import pyarrow as pa
2829

2930
try:
@@ -611,6 +612,294 @@ def over(self, window: Window) -> Expr:
611612
)
612613
)
613614

615+
def asin(self) -> Expr:
616+
"""Returns the arc sine or inverse sine of a number."""
617+
return F.asin(self)
618+
619+
def array_pop_back(self) -> Expr:
620+
"""Returns the array without the last element."""
621+
return F.array_pop_back(self)
622+
623+
def reverse(self) -> Expr:
624+
"""Reverse the string argument."""
625+
return F.reverse(self)
626+
627+
def bit_length(self) -> Expr:
628+
"""Returns the number of bits in the string argument."""
629+
return F.bit_length(self)
630+
631+
def array_length(self) -> Expr:
632+
"""Returns the length of the array."""
633+
return F.array_length(self)
634+
635+
def array_ndims(self) -> Expr:
636+
"""Returns the number of dimensions of the array."""
637+
return F.array_ndims(self)
638+
639+
def to_hex(self) -> Expr:
640+
"""Converts an integer to a hexadecimal string."""
641+
return F.to_hex(self)
642+
643+
def array_dims(self) -> Expr:
644+
"""Returns an array of the array's dimensions."""
645+
return F.array_dims(self)
646+
647+
def from_unixtime(self) -> Expr:
648+
"""Converts an integer to RFC3339 timestamp format string."""
649+
return F.from_unixtime(self)
650+
651+
def array_empty(self) -> Expr:
652+
"""Returns a boolean indicating whether the array is empty."""
653+
return F.array_empty(self)
654+
655+
def sin(self) -> Expr:
656+
"""Returns the sine of the argument."""
657+
return F.sin(self)
658+
659+
def log10(self) -> Expr:
660+
"""Base 10 logarithm of the argument."""
661+
return F.log10(self)
662+
663+
def initcap(self) -> Expr:
664+
"""Set the initial letter of each word to capital.
665+
666+
Converts the first letter of each word in ``string`` to uppercase and the remaining
667+
characters to lowercase.
668+
"""
669+
return F.initcap(self)
670+
671+
def list_distinct(self) -> Expr:
672+
"""Returns distinct values from the array after removing duplicates.
673+
674+
This is an alias for :py:func:`array_distinct`.
675+
"""
676+
return F.list_distinct(self)
677+
678+
def iszero(self) -> Expr:
679+
"""Returns true if a given number is +0.0 or -0.0 otherwise returns false."""
680+
return F.iszero(self)
681+
682+
def array_distinct(self) -> Expr:
683+
"""Returns distinct values from the array after removing duplicates."""
684+
return F.array_distinct(self)
685+
686+
def arrow_typeof(self) -> Expr:
687+
"""Returns the Arrow type of the expression."""
688+
return F.arrow_typeof(self)
689+
690+
def length(self) -> Expr:
691+
"""The number of characters in the ``string``."""
692+
return F.length(self)
693+
694+
def lower(self) -> Expr:
695+
"""Converts a string to lowercase."""
696+
return F.lower(self)
697+
698+
def acos(self) -> Expr:
699+
"""Returns the arc cosine or inverse cosine of a number.
700+
701+
Returns:
702+
--------
703+
Expr
704+
A new expression representing the arc cosine of the input expression.
705+
"""
706+
return F.acos(self)
707+
708+
def ascii(self) -> Expr:
709+
"""Returns the numeric code of the first character of the argument."""
710+
return F.ascii(self)
711+
712+
def sha384(self) -> Expr:
713+
"""Computes the SHA-384 hash of a binary string."""
714+
return F.sha384(self)
715+
716+
def isnan(self) -> Expr:
717+
"""Returns true if a given number is +NaN or -NaN otherwise returns false."""
718+
return F.isnan(self)
719+
720+
def degrees(self) -> Expr:
721+
"""Converts the argument from radians to degrees."""
722+
return F.degrees(self)
723+
724+
def cardinality(self) -> Expr:
725+
"""Returns the total number of elements in the array."""
726+
return F.cardinality(self)
727+
728+
def sha224(self) -> Expr:
729+
"""Computes the SHA-224 hash of a binary string."""
730+
return F.sha224(self)
731+
732+
def asinh(self) -> Expr:
733+
"""Returns inverse hyperbolic sine."""
734+
return F.asinh(self)
735+
736+
def flatten(self) -> Expr:
737+
"""Flattens an array of arrays into a single array."""
738+
return F.flatten(self)
739+
740+
def exp(self) -> Expr:
741+
"""Returns the exponential of the argument."""
742+
return F.exp(self)
743+
744+
def abs(self) -> Expr:
745+
"""Return the absolute value of a given number.
746+
747+
Returns:
748+
--------
749+
Expr
750+
A new expression representing the absolute value of the input expression.
751+
"""
752+
return F.abs(self)
753+
754+
def btrim(self) -> Expr:
755+
"""Removes all characters, spaces by default, from both sides of a string."""
756+
return F.btrim(self)
757+
758+
def md5(self) -> Expr:
759+
"""Computes an MD5 128-bit checksum for a string expression."""
760+
return F.md5(self)
761+
762+
def octet_length(self) -> Expr:
763+
"""Returns the number of bytes of a string."""
764+
return F.octet_length(self)
765+
766+
def cosh(self) -> Expr:
767+
"""Returns the hyperbolic cosine of the argument."""
768+
return F.cosh(self)
769+
770+
def radians(self) -> Expr:
771+
"""Converts the argument from degrees to radians."""
772+
return F.radians(self)
773+
774+
def sqrt(self) -> Expr:
775+
"""Returns the square root of the argument."""
776+
return F.sqrt(self)
777+
778+
def character_length(self) -> Expr:
779+
"""Returns the number of characters in the argument."""
780+
return F.character_length(self)
781+
782+
def tanh(self) -> Expr:
783+
"""Returns the hyperbolic tangent of the argument."""
784+
return F.tanh(self)
785+
786+
def atan(self) -> Expr:
787+
"""Returns inverse tangent of a number."""
788+
return F.atan(self)
789+
790+
def rtrim(self) -> Expr:
791+
"""Removes all characters, spaces by default, from the end of a string."""
792+
return F.rtrim(self)
793+
794+
def atanh(self) -> Expr:
795+
"""Returns inverse hyperbolic tangent."""
796+
return F.atanh(self)
797+
798+
def list_dims(self) -> Expr:
799+
"""Returns an array of the array's dimensions.
800+
801+
This is an alias for :py:func:`array_dims`.
802+
"""
803+
return F.list_dims(self)
804+
805+
def sha256(self) -> Expr:
806+
"""Computes the SHA-256 hash of a binary string."""
807+
return F.sha256(self)
808+
809+
def factorial(self) -> Expr:
810+
"""Returns the factorial of the argument."""
811+
return F.factorial(self)
812+
813+
def acosh(self) -> Expr:
814+
"""Returns inverse hyperbolic cosine."""
815+
return F.acosh(self)
816+
817+
def floor(self) -> Expr:
818+
"""Returns the nearest integer less than or equal to the argument."""
819+
return F.floor(self)
820+
821+
def ceil(self) -> Expr:
822+
"""Returns the nearest integer greater than or equal to argument."""
823+
return F.ceil(self)
824+
825+
def list_length(self) -> Expr:
826+
"""Returns the length of the array.
827+
828+
This is an alias for :py:func:`array_length`.
829+
"""
830+
return F.list_length(self)
831+
832+
def upper(self) -> Expr:
833+
"""Converts a string to uppercase."""
834+
return F.upper(self)
835+
836+
def chr(self) -> Expr:
837+
"""Converts the Unicode code point to a UTF8 character."""
838+
return F.chr(self)
839+
840+
def ln(self) -> Expr:
841+
"""Returns the natural logarithm (base e) of the argument."""
842+
return F.ln(self)
843+
844+
def tan(self) -> Expr:
845+
"""Returns the tangent of the argument."""
846+
return F.tan(self)
847+
848+
def array_pop_front(self) -> Expr:
849+
"""Returns the array without the first element."""
850+
return F.array_pop_front(self)
851+
852+
def cbrt(self) -> Expr:
853+
"""Returns the cube root of a number."""
854+
return F.cbrt(self)
855+
856+
def sha512(self) -> Expr:
857+
"""Computes the SHA-512 hash of a binary string."""
858+
return F.sha512(self)
859+
860+
def char_length(self) -> Expr:
861+
"""The number of characters in the ``string``."""
862+
return F.char_length(self)
863+
864+
def list_ndims(self) -> Expr:
865+
"""Returns the number of dimensions of the array.
866+
867+
This is an alias for :py:func:`array_ndims`.
868+
"""
869+
return F.list_ndims(self)
870+
871+
def trim(self) -> Expr:
872+
"""Removes all characters, spaces by default, from both sides of a string."""
873+
return F.trim(self)
874+
875+
def cos(self) -> Expr:
876+
"""Returns the cosine of the argument."""
877+
return F.cos(self)
878+
879+
def sinh(self) -> Expr:
880+
"""Returns the hyperbolic sine of the argument."""
881+
return F.sinh(self)
882+
883+
def empty(self) -> Expr:
884+
"""This is an alias for :py:func:`array_empty`."""
885+
return F.empty(self)
886+
887+
def ltrim(self) -> Expr:
888+
"""Removes all characters, spaces by default, from the beginning of a string."""
889+
return F.ltrim(self)
890+
891+
def signum(self) -> Expr:
892+
"""Returns the sign of the argument (-1, 0, +1)."""
893+
return F.signum(self)
894+
895+
def log2(self) -> Expr:
896+
"""Base 2 logarithm of the argument."""
897+
return F.log2(self)
898+
899+
def cot(self) -> Expr:
900+
"""Returns the cotangent of the argument."""
901+
return F.cot(self)
902+
614903

615904
class ExprFuncBuilder:
616905
def __init__(self, builder: expr_internal.ExprFuncBuilder) -> None:

0 commit comments

Comments
 (0)