-
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
base: master
Are you sure you want to change the base?
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?
d5ccae3
to
b229336
Compare
presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.h
Outdated
Show resolved
Hide resolved
#include "presto_cpp/main/types/TypeParser.h" | ||
#include "presto_cpp/presto_protocol/core/presto_protocol_core.h" | ||
#include "velox/core/Expressions.h" | ||
|
||
namespace { | ||
inline std::string formatDefaultNamespacePrefix( |
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.
Its bit odd this function has name formatDefaultNamespacePrefix and then takes the default namespace prefix as a parameter. Maybe you should call this addDefaultNamespace and pick up the default namespace in the function without passing it as a parameter everywhere.
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.
Yes, calling this addDefaultNamespace
makes sense.
I am confused about the picking up of the default namespace from the functions part, the functions passed down to the formatDefaultNamespacePrefix
function won't have any namespace attached.
For eg:
presto.default.$operator.$add
should map to {namespace-prefix}.add
, in this case native.default.add
{"presto.default.$operator$add", |
The call to the formatDefaultNamespacePrefix()
function will take in the default namespace prefix and the function name, add the default namespace prefix to the function name and return the string.
b229336
to
c748230
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.
A few nits
.../main/java/com/facebook/presto/sidecar/functionNamespace/NativeFunctionNamespaceManager.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionMetadataManager.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionNamespaceManagerContext.java
Show resolved
Hide resolved
.../main/java/com/facebook/presto/sidecar/functionNamespace/NativeFunctionNamespaceManager.java
Outdated
Show resolved
Hide resolved
f2c832d
to
d8a89d3
Compare
d8a89d3
to
f73aca4
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.
Almost there
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/StaticFunctionNamespaceStore.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/PlanOptimizers.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/AddExchanges.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/sql/relational/SqlToRowExpressionTranslator.java
Outdated
Show resolved
Hide resolved
presto-main/src/test/java/com/facebook/presto/sql/TestExpressionInterpreter.java
Outdated
Show resolved
Hide resolved
.../main/java/com/facebook/presto/sidecar/functionNamespace/NativeFunctionNamespaceManager.java
Outdated
Show resolved
Hide resolved
f73aca4
to
5567990
Compare
@rschlussel Can you please have another look? Thanks. |
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.
Only one minor thing.
@rschlussel would you like to have a look as well?
.../main/java/com/facebook/presto/spi/function/SqlInvokedAggregationFunctionImplementation.java
Outdated
Show resolved
Hide resolved
...s/src/main/java/com/facebook/presto/functionNamespace/json/JsonBasedUdfFunctionMetadata.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/StaticFunctionNamespaceStore.java
Outdated
Show resolved
Hide resolved
@@ -129,6 +131,7 @@ public class FunctionAndTypeManager | |||
private final LoadingCache<FunctionResolutionCacheKey, FunctionHandle> functionCache; | |||
private final CacheStatsMBean cacheStatsMBean; | |||
private final boolean nativeExecution; | |||
private CatalogSchemaName currentDefaultNamespace = DEFAULT_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.
this class isn't really thread safe anymore because this field is mutable, and there are no guards on how it is read/written. It might be better to set the default namespace in FunctionsConfig instead of in the config for any particular function namespace. Then we also wouldn't need to check that there is only one.
Downside is that we will only fail later (at runtime?) if the default namespace doesn't exist (never gets loaded).
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.
also, let's change this name to defaultNamespace, as this isn't something that we expect to be updated. and change the static variable DEFAULT_NAMESPACE to something that's clearer now, e.g. JAVA_BUILTIN_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.
Last comment about default_namespace, but have you checked all the things that are using DEFAULT_NAMESPACE right now? Is it still correct for them to do that?
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.
Added a config in FunctionsConfig
, the default value is going to be JAVA_BUILTIN_NAMESPACE
so we always have a default namespace configured.
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.
Yes, I went over usages of DEFAULT_NAMESPACE
(now JAVA_BUILTIN_NAMESPACE
), they are used in the right places.
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Outdated
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Outdated
Show resolved
Hide resolved
presto-spi/src/main/java/com/facebook/presto/spi/function/FunctionMetadataManager.java
Outdated
Show resolved
Hide resolved
@@ -698,7 +728,8 @@ private FunctionHandle resolveFunctionInternal(Optional<TransactionId> transacti | |||
|
|||
private FunctionHandle resolveBuiltInFunction(QualifiedObjectName functionName, List<TypeSignatureProvider> parameterTypes) | |||
{ | |||
checkArgument(functionName.getCatalogSchemaName().equals(DEFAULT_NAMESPACE), "Expect built-in functions"); | |||
checkArgument(functionName.getCatalogSchemaName().equals(currentDefaultNamespace) || |
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 do we use both DEFAULT_NAMESPACE and currentDefaultNamespace here?
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.
There might be some functions an eg: key_sampling_percent
function
presto/presto-main/src/main/java/com/facebook/presto/sql/planner/optimizations/KeyBasedSampler.java
Lines 151 to 155 in a391cec
sampledArg = call( | |
functionAndTypeManager, | |
QualifiedObjectName.valueOf(JAVA_BUILTIN_NAMESPACE, getKeyBasedSamplingFunction(session)), | |
DOUBLE, | |
ImmutableList.of(arg)); |
JAVA_BUILTIN_NAMESPACE
.
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Show resolved
Hide resolved
presto-main/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java
Show resolved
Hide resolved
I will get back to this soon. |
5567990
to
2d7cbe0
Compare
@rschlussel |
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