Skip to content

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

Closed
Tangruilin wants to merge 1 commit into
apache:mainfrom
Tangruilin:task#9512
Closed

[task#9512] move from_unixtime, now, current_date, current_time to da…#9513
Tangruilin wants to merge 1 commit into
apache:mainfrom
Tangruilin:task#9512

Conversation

@Tangruilin

@TangruilinTangruilin commented Mar 9, 2024

Copy link
Copy Markdown
Contributor

…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-actionsgithub-actionsBot added logical-expr Logical plan and expressions physical-expr Changes to the physical-expr crates labels Mar 9, 2024
@Tangruilin

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor
// 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:pubfncreate_physical_expr(fun:&ScalarUDF,input_phy_exprs:&[Arc<dynPhysicalExpr>],return_type:DataType,) -> Result<Arc<dynPhysicalExpr>>{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

alamb commented Mar 9, 2024

Copy link
Copy Markdown
Contributor

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 ExecutionPropshttps://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

alamb commented Mar 9, 2024

Copy link
Copy Markdown
Contributor

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

@alamb

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Dup of #9537

@Tangruilin

Copy link
Copy Markdown
ContributorAuthor

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

@alambalamb closed this Mar 11, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

logical-exprLogical plan and expressionsphysical-exprChanges to the physical-expr crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Tangruilin@alamb@Omega359