apache / apache/datafusion-comet

[EPIC] Implement expressions as ScalarUDFImpl

Open
#1,819 3 comments 2 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
Scala
Stars
1.3k
Forks
373
Avg merge
2d 4h
Merged PRs (30d)
198

Description

### 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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.