Skip to content

Support TypeSignature::Nullary #13354

New issue

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

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

Already on GitHub? # to your account

Merged
merged 4 commits into from
Nov 12, 2024
Merged

Support TypeSignature::Nullary #13354

merged 4 commits into from
Nov 12, 2024

Conversation

jayzhan211
Copy link
Contributor

@jayzhan211 jayzhan211 commented Nov 11, 2024

Which issue does this PR close?

Closes #.

Rationale for this change

Currently there are uniform(0), any(0), exact(0) 3 ways to describe zero argument signature. To avoid confusion, add TypeSignature::ZeroArg and disable 0 argument for those 3 signatures, they now require at least one argument.

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@github-actions github-actions bot added logical-expr Logical plan and expressions functions Changes to functions implementation labels Nov 11, 2024
@jayzhan211 jayzhan211 marked this pull request as ready for review November 11, 2024 10:35
@@ -135,6 +134,8 @@ pub enum TypeSignature {
/// Null is considerd as `Utf8` by default
/// Dictionary with string value type is also handled.
String(usize),
/// Zero argument
ZeroArg,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe NoArgs would be more explanatory? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see the difference 👀

Copy link
Contributor

Choose a reason for hiding this comment

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

Its choice of wording yes. Another option we can take from https://en.wikipedia.org/wiki/Arity and name it Nullary to be in sync with unary, binary functions we already use.

@findepi
Copy link
Member

findepi commented Nov 11, 2024

I think it would be nice to support a signature defined by something like Vec<LogicalType>
then ZeroArg / NoArgs would be just represented by an empty vec.
What do you think?

@jayzhan211
Copy link
Contributor Author

I think it would be nice to support a signature defined by something like Vec<LogicalType> then ZeroArg / NoArgs would be just represented by an empty vec. What do you think?

Signature::coercible(vec![], Volatility::Immutable) can represent this already. And you can also do Any(0), Uniform(0), so I want a standard representation for zero arg

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@jayzhan211 jayzhan211 changed the title Support TypeSignature::ZeroArg Support TypeSignature::Nullary Nov 12, 2024
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

lgtm thanks @jayzhan211 👍

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Copy link
Contributor

@2010YOUY01 2010YOUY01 left a comment

Choose a reason for hiding this comment

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

It's great to have only one case for defining a signature with zero arguments. This will make it easier to use and less error-prone.
(Though I think "ZeroArg" or "NoArg" would be slightly more friendly for non-native English speakers)

Copy link
Member

@Weijun-H Weijun-H left a comment

Choose a reason for hiding this comment

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

Ship it! Thanks @jayzhan211

@Weijun-H Weijun-H merged commit 8d6899e into apache:main Nov 12, 2024
25 checks passed
@Weijun-H
Copy link
Member

Thanks @2010YOUY01 and @comphead for review.

@jayzhan211 jayzhan211 deleted the zero-arg-sig branch November 13, 2024 00:46
alamb pushed a commit to alamb/datafusion that referenced this pull request Nov 13, 2024
* support zero arg

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* rename to nullary

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* rename

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

* tostring

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>

---------

Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
@alamb
Copy link
Contributor

alamb commented Dec 13, 2024

BTW I hit a usability rough edge due to this change I think:

@alamb alamb mentioned this pull request Dec 13, 2024
10 tasks
@@ -135,6 +134,8 @@ pub enum TypeSignature {
/// Null is considerd as `Utf8` by default
/// Dictionary with string value type is also handled.
String(usize),
/// Zero argument
NullAry,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the A here intended to be upper-case? I'd have expected Nullary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nullary looks good to me too

Copy link
Contributor

Choose a reason for hiding this comment

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
functions Changes to functions implementation logical-expr Logical plan and expressions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants