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

[SPARK-49995][SQL] Add named argument support to more TVFs #48503

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ueshin
Copy link
Member

@ueshin ueshin commented Oct 16, 2024

What changes were proposed in this pull request?

Add named argument support to more TVFs.

SELECT * FROM inline(input => array(struct(1, 'a'), struct(2, 'b')));
SELECT * FROM inline_outer(input => array(struct(1, 'a'), struct(2, 'b')));

SELECT * FROM posexplode(collection => array(1, 2));
SELECT * FROM posexplode_outer(collection => map('a', 1, 'b', 2));

SELECT * FROM variant_explode(input => parse_json('["hello", "world"]'));
SELECT * FROM variant_explode_outer(input => parse_json('{"a": true, "b": 3.14}'));

Why are the changes needed?

The following TVFs should support named argument as same as explode:

  • inline
  • posexplode
  • variant_explode

and their _outer variations.

Does this PR introduce any user-facing change?

Yes, the above functions support named arguments.

How was this patch tested?

Added the related tests.

Was this patch authored or co-authored using generative AI tooling?

No.

@ueshin
Copy link
Member Author

ueshin commented Oct 16, 2024

cc @dtenedor @chenhao-db @srielau

Copy link
Contributor

@allisonwang-db allisonwang-db left a comment

Choose a reason for hiding this comment

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

Looks great!

1 a
2 b
""",
since = "2.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm I don't think we can use them as table functions since 2.0. SELECT * FROM inline(...) is added recently (in spark 3.4 or 3.5)

Copy link
Member Author

@ueshin ueshin Oct 16, 2024

Choose a reason for hiding this comment

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

That's a good point. Now that we have separate definitions, we can maybe mention each of them in each definition.
Also the named arguments should be supported later than the tvfs were added, I guess? Do we have a way to mention about the updates?

Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this should be fine. Users will only see the updated usage for the function in the latest version.

@@ -665,6 +650,53 @@ case class VariantExplode(child: Expression) extends UnaryExpression with Genera
}
}

trait VariantExplodeGeneratorBuilderBase extends GeneratorBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants