-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add a native function namespace manager #23358
Add a native function namespace manager #23358
Conversation
49d3b9d
to
5ed5a18
Compare
bcb09bc
to
ce7ca4b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! (docs)
Pull branch, new local doc build, the doc looks good. Thanks!
4d00991
to
c3ed29f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! (docs)
Pull updated branch, new local doc build, doc looks good. Thanks!
3fde055
to
ebfa361
Compare
f203d25
to
88e1152
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some initial comments
presto-common/src/main/java/com/facebook/presto/common/type/TypeSignature.java
Outdated
Show resolved
Hide resolved
...n/java/com/facebook/presto/functionNamespace/AbstractSqlInvokedFunctionNamespaceManager.java
Outdated
Show resolved
Hide resolved
...n/java/com/facebook/presto/functionNamespace/AbstractSqlInvokedFunctionNamespaceManager.java
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactored qualifyObjectName from static to instance method
✅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add utility functions to resolve intermediate type in aggregate funct…
❓
Thank you for the really extensive tests for this utility. I think the tests should be broken down to the various different types, because the tests are rather large.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[native] Fix bug when handling multiple params and no params aggregat…
❓
Can you help me understand when this bug manifests? Is there any way to add a unit test for it?
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Show resolved
Hide resolved
@@ -361,15 +379,18 @@ public void registerBuiltInFunctions(List<? extends SqlFunction> functions) | |||
public List<SqlFunction> listFunctions(Session session, Optional<String> likePattern, Optional<String> escape) | |||
{ | |||
ImmutableList.Builder<SqlFunction> functions = new ImmutableList.Builder<>(); | |||
if (!isListBuiltInFunctionsOnly(session)) { | |||
if (isListBuiltInFunctionsOnly(session)) { | |||
functions.addAll(functionNamespaceManagers.entrySet().stream() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the point of listing built in functions only is to not pay the cost of listing from some functionNamespaceManagers that are more geared to point lookups and very expensive to list all functions. can we instead only list from the functionNamespaceManager that is the default one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why stream the map and filter instead of getting the functionNamespacemanager directly?
functions.addAll(functionNamespaceManagers.get(
defaultNamespace.getCatalogName().listFunctions(likePattern,escape).stream()
.collect(toImmutableList())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are configuring function namespaces using .properties
files located under etc/function-namespace
.
The name of the .properties
file without the .properties
extension corresponds to the catalogName
, which is passed to the FunctionNamespaceManager
factories. These factories then create the respective function namespaces.
This catalogName
is subsequently registered as a ServingCatalog
within its corresponding FunctionNamespaceManager
.
In FunctionAndTypeManager
, we maintain a map of the FunctionNamespaceManager
instances, where:
• The key is the catalogName.
• The value is the corresponding FunctionNamespaceManager
.
For example: {"native": NativeFunctionNamespaceManager}
To retrieve builtiin functions from the defaultNamespace
,
We use defaultNamespace.getCatalogName()
to get the catalogName
. If the catalogName
exists in the map, we fetch the corresponding FunctionNamespaceManager
(e.g., NativeFunctionNamespaceManager
) and call getFunctions()
on it.
The only requirement for users to ensure is that the name of the file ({catalogName}.properties
) file used to load the functionNamespaces must match the catalog name of the presto.default-namespace
configuration property for the defaultNamespace, but its not a new requirement, even with the current implementation that is enforced.
Let me know if that works for you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, thanks for catching that. Changed it.
...in/java/com/facebook/presto/sql/planner/iterative/rule/CombineApproxPercentileFunctions.java
Outdated
Show resolved
Hide resolved
b0b9ddf
to
764b364
Compare
33ff47b
to
d7dec93
Compare
presto-spi/src/main/java/com/facebook/presto/spi/ConnectorSystemConfig.java
Outdated
Show resolved
Hide resolved
d7dec93
to
c4fe9ec
Compare
c4fe9ec
to
38edeb3
Compare
folly::split( | ||
'.', | ||
prestoDefaultNamespacePrefix, | ||
prestoDefaultNamespacePrefixParts, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add CHECK that prestoDefaultNamespacePrefixParts has only 2 parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pdabre12 : Have 2 minor comments.
|
||
std::vector<std::string> parts; | ||
folly::split('.', functionName, parts, true); | ||
if ((parts.size() != 3) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be a check instead ? Are there functions that don't follow since (since you added all the built-ins with prefixes) ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All the functions should have a prefix. Added the check, thanks.
#include "presto_cpp/main/types/TypeParser.h" | ||
#include "presto_cpp/presto_protocol/core/presto_protocol_core.h" | ||
#include "velox/core/Expressions.h" | ||
|
||
namespace { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider moving this to presto_cpp/main/common/Utils.h
38edeb3
to
63b7d00
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @pdabre12
Description
Adds a native function namespace manager
Motivation and Context
To help resolve : #23000
Impact
Test Plan
Unit and end-to-end tests. More comprehensive end-to-end tests will be written in the future.
Contributor checklist
Depends on : #23671