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

Adds Fn, FnProvider, Agg, and AggProvider APIs #1722

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

johnedquinn
Copy link
Member

@johnedquinn johnedquinn commented Jan 21, 2025

Description

  • Cleans up the Function and Aggregation APIs by creating distinct APIs for providing functions as well as implementing functions.
  • Adds Javadocs to each class/method. Performed the audit.

Reviewing

  • The functionality is the same. The APIs are now cleaned up to remove unnecessary methods, and the naming is more indicative of the underlying class's definition.

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@johnedquinn johnedquinn force-pushed the main-fn-agg-apis branch 2 times, most recently from 7ad1acc to 609f1ea Compare January 21, 2025 16:48
@johnedquinn johnedquinn marked this pull request as ready for review January 21, 2025 16:53
@johnedquinn johnedquinn requested a review from alancai98 January 21, 2025 16:54
partiql-spi/src/main/java/org/partiql/spi/function/Fn.java Outdated Show resolved Hide resolved
* @return the {@link Builder} instance.
*/
@NotNull
@SuppressWarnings("UnusedReturnValue")
Copy link
Member

Choose a reason for hiding this comment

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

unused suppression?

Copy link
Member Author

Choose a reason for hiding this comment

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

According to my IDE, it is used.

Comment on lines +27 to +34
/**
* Returns the name of the parameter.
* @return the name of the parameter.
*/
@NotNull
public String getName() {
return name;
}
Copy link
Member

Choose a reason for hiding this comment

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

What is the name property used for? As far as I can tell, they are defined or generated for all the functions but getName is not used.

Similarly for RoutineProviderParameter's getName

Copy link
Member Author

Choose a reason for hiding this comment

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

Discussed offline. The name is part of the signature (see SQL:1999 Section 21.25 "PARAMETERS base table").

CREATE FUNCTION FOO(bar INT) RETURNS INT ...;

Comment on lines 31 to 37
/**
* Returns an instance of the function for the given argument types.
* @param args the argument types.
* @return an instance of the function for the given argument types, or {@code null} if no such function exists.
*/
@Nullable
public abstract Fn getInstance(PType[] args);
Copy link
Member

Choose a reason for hiding this comment

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

Wonder if we want these args to just be a list rather than an array? The usages of getInstance in our library are already using lists and have to convert to an array using .toTypedArray().

Copy link
Member Author

Choose a reason for hiding this comment

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

For any instances of the internal planner logic using it, it's internal and can be updated. As for execution, I've updated internal logic to use arrays in the latest commit. See 0ab406b.

* @param type The type of the parameter.
* @return the {@link Builder} instance.
*/
@SuppressWarnings("UnusedReturnValue")
Copy link
Member

Choose a reason for hiding this comment

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

unused suppression

Copy link
Member Author

Choose a reason for hiding this comment

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

My IDE says it is used.

return "FN_${name}___${parameters}___$returnType"
}
@JvmStatic
fun static(
Copy link
Member

Choose a reason for hiding this comment

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

could rename to overload? I don't know what static is referring to here

Copy link
Member Author

Choose a reason for hiding this comment

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

This is an internal name that was already being used. Didn't change it as it is used many times in our codebase and would create an unnecessary diff for an internal API.

}
}
@JvmStatic
fun static(
Copy link
Member

Choose a reason for hiding this comment

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

nit since internal: could rename to overload? Not sure what static means here

Copy link
Member Author

Choose a reason for hiding this comment

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

Adds a RoutineSignature and RoutineProviderSignature

Adds a RoutineProviderParam

Adds scalar and aggregate function builders

Updates existing function implementations to use new APIs
Removes the RoutineProviderParameter in favor of PType

Updates Javadocs

Renames internal SUBSTRING name
Sign up for free to 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.

2 participants