Skip to content

[EPIC] Implement expressions as ScalarUDFImpl #1819

@andygrove

Description

@andygrove

What is the problem the feature request solves?

Many of Comet's Spark-compatible DataFusion expressions are currently implemented as PhysicalExpr. We would like to update them to implement ScalarUDFImpl instead as a first step to contributing these expressions upstream to the datafusion-spark crate.

We should create one issue/PR per expression.

Here is a list of expressions based on a quick grep - it may not be complete, and it may not make sense to try and upstream some expressions.

$ find . -name *.rs -exec grep "impl PhysicalExpr" {} \;
impl PhysicalExpr for IfExpr {
impl PhysicalExpr for Cast {
impl PhysicalExpr for ToJson {
impl PhysicalExpr for ListExtract {
impl PhysicalExpr for ArrayInsert {
impl PhysicalExpr for GetArrayStructFields {
impl PhysicalExpr for RLike {
impl PhysicalExpr for NegativeExpr {
impl PhysicalExpr for CheckOverflow {
impl PhysicalExpr for NormalizeNaNAndZero {
impl PhysicalExpr for TimestampTruncExpr {
impl PhysicalExpr for DateTruncExpr {
impl PhysicalExpr for HourExpr {
impl PhysicalExpr for SecondExpr {
impl PhysicalExpr for MinuteExpr {
impl PhysicalExpr for StringSpaceExpr {
impl PhysicalExpr for SubstringExpr {
        impl PhysicalExpr for $name {
impl PhysicalExpr for UnboundColumn {
impl PhysicalExpr for GetStructField {
impl PhysicalExpr for CreateNamedStruct {
impl PhysicalExpr for BitwiseNotExpr {
impl PhysicalExpr for BloomFilterMightContain {
impl PhysicalExpr for Subquery {

$ find . -name *.rs -exec grep "make_predicate_function" {} \;
macro_rules! make_predicate_function {
make_predicate_function!(Like, like_dyn, like_utf8_scalar_dyn);
make_predicate_function!(StartsWith, starts_with_dyn, starts_with_utf8_scalar_dyn);
make_predicate_function!(EndsWith, ends_with_dyn, ends_with_utf8_scalar_dyn);
make_predicate_function!(Contains, contains_dyn, contains_utf8_scalar_dyn);

Describe the potential solution

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions