def wrapper(*args, memory_pool=None): if arity is not Ellipsis and len(args) != arity: raise TypeError( f"{func_name} takes {arity} positional argument(s), " f"but {len(args)} were given") if args and isinstance(args[0], Expression): return Expression._call(func_name, list(args)) return func.call(args, None, memory_pool)
def field(*name_or_index): """Reference a column of the dataset. Stores only the field's name. Type and other information is known only when the expression is bound to a dataset having an explicit scheme. Nested references are allowed by passing multiple names or a tuple of names. For example ``('foo', 'bar')`` references the field named "bar" inside the field named "foo". Parameters ---------- *name_or_index : string, multiple strings, tuple or int The name or index of the (possibly nested) field the expression references to. Returns ------- field_expr : Expression Examples -------- >>> import pyarrow.compute as pc >>> pc.field("a") <pyarrow.compute.Expression a> >>> pc.field(1) <pyarrow.compute.Expression FieldPath(1)> >>> pc.field(("a", "b")) <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ... >>> pc.field("a", "b") <pyarrow.compute.Expression FieldRef.Nested(FieldRef.Name(a) ... """ n = len(name_or_index) if n == 1: if isinstance(name_or_index[0], (str, int)): return Expression._field(name_or_index[0]) elif isinstance(name_or_index[0], tuple): return Expression._nested_field(name_or_index[0]) else: raise TypeError( "field reference should be str, multiple str, tuple or " f"integer, got {type(name_or_index[0])}") # In case of multiple strings not supplied in a tuple else: return Expression._nested_field(name_or_index)
def scalar(value): """Expression representing a scalar value. Parameters ---------- value : bool, int, float or string Python value of the scalar. Note that only a subset of types are currently supported. Returns ------- scalar_expr : Expression """ return Expression._scalar(value)
def wrapper(*args, memory_pool=None, options=None, **kwargs): if arity is not Ellipsis: if len(args) < arity: raise TypeError( f"{func_name} takes {arity} positional argument(s), " f"but {len(args)} were given") option_args = args[arity:] args = args[:arity] else: option_args = () options = _handle_options(func_name, options_class, options, option_args, kwargs) if args and isinstance(args[0], Expression): return Expression._call(func_name, list(args), options) return func.call(args, options, memory_pool)
def field(name): """Reference a named column of the dataset. Stores only the field's name. Type and other information is known only when the expression is bound to a dataset having an explicit scheme. Parameters ---------- name : string The name of the field the expression references to. Returns ------- field_expr : Expression """ return Expression._field(name)