Skip to content

Add example of using Expr::field in 37.1.0 - #10183

Closed
alamb wants to merge 3 commits into
apache:branch-37from
alamb:alamb/example_expr
Closed

Add example of using Expr::field in 37.1.0#10183
alamb wants to merge 3 commits into
apache:branch-37from
alamb:alamb/example_expr

Conversation

@alamb

Copy link
Copy Markdown
Contributor

I don't intend to merge this, but I want to put it up to illustrate how to use the 37.1.0 API to do this reasonably

Which issue does this PR close?

Part of #10181

Rationale for this change

Some users create expressions outside the context of a query that has an analyzer, etc. Some expressions now can only be used via udfs.

What changes are included in this PR?

Add example of using Expr::field in 37.1.0

Are these changes tested?

Are there any user-facing changes?

let expr = expr
.transform_up(&|expr| {
Ok(match expr {
Expr::GetIndexedField(GetIndexedField {

@alambalambApr 22, 2024

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically inlines the necessary code from

Expr::GetIndexedField(GetIndexedField{
expr,
field:GetFieldAccess::NamedStructField{ name },
}) => {
let expr = *expr.clone();
let name = Expr::Literal(name);
Transformed::yes(get_field(expr, name.clone()))

@alamb

alamb commented May 6, 2024

Copy link
Copy Markdown
ContributorAuthor

Here is the proposed public API that should complete this actual issue: #10330

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@alamb