Skip to content

Commit 9cf57f9

Browse files
pdabre12facebook-github-bot
authored andcommitted
Sidecar native built in demo 1 (prestodb#25661)
Summary: …ceManager for registering sql invoked functions ## Description ## Motivation and Context ## Impact Test Plan: <!---Please fill in how you tested your change--> ## Contributor checklist - [ ] Please make sure your submission complies with our [contributing guide](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md), in particular [code style](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#code-style) and [commit standards](https://github.com/prestodb/presto/blob/master/CONTRIBUTING.md#commit-standards). - [ ] PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced. - [ ] Documented new properties (with its default value), SQL syntax, functions, or other functionality. - [ ] If release notes are required, they follow the [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines). - [ ] Adequate tests were added if applicable. - [ ] CI passed. ## Release Notes Please follow [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines) and fill in the release notes below. ``` == RELEASE NOTES == General Changes * ... * ... Hive Connector Changes * ... * ... ``` If release note is NOT required, use: ``` == NO RELEASE NOTE == ``` Rollback Plan: Differential Revision: D79301760 Pulled By: kevintang2022
1 parent 829a792 commit 9cf57f9

24 files changed

+777
-88
lines changed

presto-main-base/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191
<artifactId>bootstrap</artifactId>
9292
</dependency>
9393

94+
<dependency>
95+
<groupId>com.facebook.airlift</groupId>
96+
<artifactId>http-client</artifactId>
97+
</dependency>
98+
9499
<dependency>
95100
<groupId>io.airlift</groupId>
96101
<artifactId>aircompressor</artifactId>

presto-main-base/src/main/java/com/facebook/presto/metadata/BuiltInFunctionHandle.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,16 @@ public class BuiltInFunctionHandle
3030
implements FunctionHandle
3131
{
3232
private final Signature signature;
33+
private final boolean isBuiltInNativeFunction;
3334

3435
@JsonCreator
35-
public BuiltInFunctionHandle(@JsonProperty("signature") Signature signature)
36+
public BuiltInFunctionHandle(
37+
@JsonProperty("signature") Signature signature,
38+
@JsonProperty("isBuiltInNativeFunction") boolean isBuiltInNativeFunction)
3639
{
3740
this.signature = requireNonNull(signature, "signature is null");
3841
checkArgument(signature.getTypeVariableConstraints().isEmpty(), "%s has unbound type parameters", signature);
42+
this.isBuiltInNativeFunction = isBuiltInNativeFunction;
3943
}
4044

4145
@JsonProperty
@@ -62,6 +66,13 @@ public List<TypeSignature> getArgumentTypes()
6266
return signature.getArgumentTypes();
6367
}
6468

69+
@JsonProperty
70+
@Override
71+
public boolean isBuiltInNativeFunction()
72+
{
73+
return isBuiltInNativeFunction;
74+
}
75+
6576
@Override
6677
public CatalogSchemaName getCatalogSchemaName()
6778
{
@@ -78,13 +89,14 @@ public boolean equals(Object o)
7889
return false;
7990
}
8091
BuiltInFunctionHandle that = (BuiltInFunctionHandle) o;
81-
return Objects.equals(signature, that.signature);
92+
return Objects.equals(signature, that.signature)
93+
&& Objects.equals(isBuiltInNativeFunction, that.isBuiltInNativeFunction);
8294
}
8395

8496
@Override
8597
public int hashCode()
8698
{
87-
return Objects.hash(signature);
99+
return Objects.hash(signature, isBuiltInNativeFunction);
88100
}
89101

90102
@Override

presto-main-base/src/main/java/com/facebook/presto/metadata/BuiltInNativeFunctionNamespaceManager.java

Lines changed: 337 additions & 0 deletions
Large diffs are not rendered by default.

presto-main-base/src/main/java/com/facebook/presto/metadata/BuiltInTypeAndFunctionNamespaceManager.java

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@
292292
import com.google.common.cache.CacheLoader;
293293
import com.google.common.cache.LoadingCache;
294294
import com.google.common.collect.ImmutableList;
295-
import com.google.common.collect.ImmutableListMultimap;
296-
import com.google.common.collect.Multimap;
297-
import com.google.common.collect.Multimaps;
298295
import com.google.common.util.concurrent.UncheckedExecutionException;
299296
import io.airlift.slice.Slice;
300297

@@ -1133,7 +1130,7 @@ public Collection<SqlFunction> getFunctions(Optional<? extends FunctionNamespace
11331130
@Override
11341131
public FunctionHandle getFunctionHandle(Optional<? extends FunctionNamespaceTransactionHandle> transactionHandle, Signature signature)
11351132
{
1136-
return new BuiltInFunctionHandle(signature);
1133+
return new BuiltInFunctionHandle(signature, false);
11371134
}
11381135

11391136
@Override
@@ -1396,44 +1393,6 @@ private static class EmptyTransactionHandle
13961393
{
13971394
}
13981395

1399-
private static class FunctionMap
1400-
{
1401-
private final Multimap<QualifiedObjectName, SqlFunction> functions;
1402-
1403-
public FunctionMap()
1404-
{
1405-
functions = ImmutableListMultimap.of();
1406-
}
1407-
1408-
public FunctionMap(FunctionMap map, Iterable<? extends SqlFunction> functions)
1409-
{
1410-
this.functions = ImmutableListMultimap.<QualifiedObjectName, SqlFunction>builder()
1411-
.putAll(map.functions)
1412-
.putAll(Multimaps.index(functions, function -> function.getSignature().getName()))
1413-
.build();
1414-
1415-
// Make sure all functions with the same name are aggregations or none of them are
1416-
for (Map.Entry<QualifiedObjectName, Collection<SqlFunction>> entry : this.functions.asMap().entrySet()) {
1417-
Collection<SqlFunction> values = entry.getValue();
1418-
long aggregations = values.stream()
1419-
.map(function -> function.getSignature().getKind())
1420-
.filter(kind -> kind == AGGREGATE)
1421-
.count();
1422-
checkState(aggregations == 0 || aggregations == values.size(), "'%s' is both an aggregation and a scalar function", entry.getKey());
1423-
}
1424-
}
1425-
1426-
public List<SqlFunction> list()
1427-
{
1428-
return ImmutableList.copyOf(functions.values());
1429-
}
1430-
1431-
public Collection<SqlFunction> get(QualifiedObjectName name)
1432-
{
1433-
return functions.get(name);
1434-
}
1435-
}
1436-
14371396
/**
14381397
* TypeSignature but has overridden equals(). Here, we compare exact signature of any underlying distinct
14391398
* types. Some distinct types may have extra information on their lazily loaded parents, and same parent
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.facebook.presto.metadata;
15+
16+
import com.google.inject.BindingAnnotation;
17+
18+
import java.lang.annotation.Retention;
19+
20+
import static java.lang.annotation.RetentionPolicy.RUNTIME;
21+
22+
@Retention(RUNTIME)
23+
@BindingAnnotation
24+
public @interface ForSidecarInfo
25+
{
26+
}

0 commit comments

Comments
 (0)