Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[task#9512] move from_unixtime, now, current_date, current_time to da… #9513

Closed
wants to merge 1 commit into from

Conversation

Tangruilin
Copy link
Contributor

@Tangruilin Tangruilin commented Mar 9, 2024

…tafusion_functions

Which issue does this PR close?

Closes part of #9512.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

…tafusion_functions

Signed-off-by: tangruilin <tang.ruilin@foxmail.com>
@github-actions github-actions bot added logical-expr Logical plan and expressions physical-expr Physical Expressions labels Mar 9, 2024
@Tangruilin
Copy link
Contributor Author

now, current_date, current_time need to get query_execution_start_time.

But Now I see there is no query_execution_start_time in ScalarUDFImpl
@alamb

@Tangruilin
Copy link
Contributor Author

now, current_date, current_time need to get query_execution_start_time.

But Now I see there is no query_execution_start_time in ScalarUDFImpl @alamb

I Think ExecutionProps can be added into ScalarUDF.

@Tangruilin
Copy link
Contributor Author

// TODO: add execution_props in ScalarUDF, so that we can get some params like query_execution_start_time
/// Create a physical expression of the UDF.
///
/// Arguments:
pub fn create_physical_expr(
    fun: &ScalarUDF,
    input_phy_exprs: &[Arc<dyn PhysicalExpr>],
    return_type: DataType,
) -> Result<Arc<dyn PhysicalExpr>> {
    Ok(Arc::new(ScalarFunctionExpr::new(
        fun.name(),
        fun.fun(),
        input_phy_exprs.to_vec(),
        return_type,
        fun.monotonicity()?,
        fun.signature().type_signature.supports_zero_argument(),
    )))
}

I think I can add execution_props in ScalarUDF, so that we can get some params like query_execution_start_time in next PR

how do you think of it?

@alamb
Copy link
Contributor

alamb commented Mar 9, 2024

how do you think of it?

I think we can use ScalarUdfImpl::simplify in this case: https://github.com/apache/arrow-datafusion/blob/b1d8082c6271e49c1de6e20002b853ca1503ffde/datafusion/expr/src/udf.rs#L373-L380

Specifically, the SimplifyInfo gets passed ExecutionProps https://github.com/apache/arrow-datafusion/blob/b1d8082c6271e49c1de6e20002b853ca1503ffde/datafusion/expr/src/simplify.rs#L39

Thus for a function like now(), that would look like

  1. The simplify() call should rewrite now() to a ScalarValue::TimestampNano
  2. The invoke() call should error with a "internal error"

Does that make sense?

@alamb
Copy link
Contributor

alamb commented Mar 9, 2024

(thank you for working on this, by the way @Tangruilin 🙏 )

@alamb
Copy link
Contributor

alamb commented Mar 10, 2024

Marking as draft as I think this PR is no longer waiting on feedback. Please mark it as ready for review when it is ready for another look

@alamb alamb marked this pull request as draft March 10, 2024 09:43
@Omega359
Copy link
Contributor

Dup of #9537

@Tangruilin
Copy link
Contributor Author

Marking as draft as I think this PR is no longer waiting on feedback. Please mark it as ready for review when it is ready for another look

Maybe you need to close this

@alamb alamb closed this Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions physical-expr Physical Expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants