def _prepare_contains_options(options): if isinstance(options, ir.AnyScalar): # TODO(kszucs): it would be better if we could pass an arrow # ListScalar to datafusions in_list function return [df.literal(v) for v in options.op().value] else: return translate(options)
def count(op, expr): op_arg = op.arg if isinstance(op_arg, ir.TableExpr): arg = df.literal(1) else: arg = translate(op_arg) return df.functions.count(arg)
def literal(op, expr): if isinstance(op.value, (set, frozenset)): value = list(op.value) else: value = op.value arrow_type = to_pyarrow_type(op.dtype) arrow_scalar = pa.scalar(value, type=arrow_type) return df.literal(arrow_scalar)