From 64210912b5938c0d4f6497f698d4e7ffe9e6d21e Mon Sep 17 00:00:00 2001 From: Pratik Joseph Dabre Date: Thu, 26 Sep 2024 22:46:25 -0700 Subject: [PATCH] [native] Add e2e native function validation tests with Presto sidecar Co-authored-by: Tim Meehan --- .../HiveExternalWorkerQueryRunner.java | 2 +- .../nativeworker/NativeQueryRunnerUtils.java | 9 ++ .../PrestoNativeQueryRunnerUtils.java | 45 ++++--- presto-native-sidecar-plugin/pom.xml | 97 +++++++++++++++ .../NativeSidecarPluginQueryRunner.java | 48 +++++++ .../NativeSidecarPluginQueryRunnerUtils.java | 33 +++++ .../sidecar/TestNativeSidecarPlugin.java | 45 ------- ...SidecarPluginFunctionNamespaceManager.java | 93 ++++++++++++++ .../UnimplementedFunctionMetadataManager.java | 36 ------ .../sidecar/UnimplementedNodeManager.java | 117 ------------------ .../sidecar/UnimplementedTypeManager.java | 43 ------- 11 files changed, 310 insertions(+), 258 deletions(-) create mode 100644 presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunner.java create mode 100644 presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java delete mode 100644 presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPlugin.java create mode 100644 presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPluginFunctionNamespaceManager.java delete mode 100644 presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedFunctionMetadataManager.java delete mode 100644 presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedNodeManager.java delete mode 100644 presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedTypeManager.java diff --git a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/HiveExternalWorkerQueryRunner.java b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/HiveExternalWorkerQueryRunner.java index cd3bfa11353a..6d9392a26d22 100644 --- a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/HiveExternalWorkerQueryRunner.java +++ b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/HiveExternalWorkerQueryRunner.java @@ -34,7 +34,7 @@ public static void main(String[] args) javaQueryRunner.close(); // Launch distributed runner. - DistributedQueryRunner queryRunner = (DistributedQueryRunner) PrestoNativeQueryRunnerUtils.createQueryRunner(false); + DistributedQueryRunner queryRunner = (DistributedQueryRunner) PrestoNativeQueryRunnerUtils.createQueryRunner(false, false); Thread.sleep(10); Logger log = Logger.get(DistributedQueryRunner.class); log.info("======== SERVER STARTED ========"); diff --git a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/NativeQueryRunnerUtils.java b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/NativeQueryRunnerUtils.java index 64d9d9851b83..cefc02f8a349 100644 --- a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/NativeQueryRunnerUtils.java +++ b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/NativeQueryRunnerUtils.java @@ -56,6 +56,15 @@ public static Map getNativeWorkerSystemProperties() .build(); } + public static Map getNativeSidecarProperties() + { + return ImmutableMap.builder() + .put("coordinator-sidecar-enabled", "true") + .put("list-built-in-functions-only", "false") + .put("presto.default-namespace", "native.default") + .build(); + } + /** * Creates all tables for local testing, except for bench tables. * diff --git a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/PrestoNativeQueryRunnerUtils.java b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/PrestoNativeQueryRunnerUtils.java index 69bb2433b3f1..7bf5303bade5 100644 --- a/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/PrestoNativeQueryRunnerUtils.java +++ b/presto-native-execution/src/test/java/com/facebook/presto/nativeworker/PrestoNativeQueryRunnerUtils.java @@ -37,6 +37,7 @@ import static com.facebook.presto.hive.HiveTestUtils.getProperty; import static com.facebook.presto.iceberg.IcebergQueryRunner.createIcebergQueryRunner; +import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.getNativeSidecarProperties; import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.getNativeWorkerHiveProperties; import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.getNativeWorkerIcebergProperties; import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.getNativeWorkerSystemProperties; @@ -55,9 +56,10 @@ public class PrestoNativeQueryRunnerUtils private static final Logger log = Logger.get(PrestoNativeQueryRunnerUtils.class); private static final String DEFAULT_STORAGE_FORMAT = "DWRF"; + private PrestoNativeQueryRunnerUtils() {} - public static QueryRunner createQueryRunner(boolean addStorageFormatToPath) + public static QueryRunner createQueryRunner(boolean addStorageFormatToPath, boolean isCoordinatorSidecarEnabled) throws Exception { int cacheMaxSize = 4096; // 4GB size cache @@ -68,7 +70,8 @@ public static QueryRunner createQueryRunner(boolean addStorageFormatToPath) nativeQueryRunnerParameters.workerCount, cacheMaxSize, DEFAULT_STORAGE_FORMAT, - addStorageFormatToPath); + addStorageFormatToPath, + isCoordinatorSidecarEnabled); } public static QueryRunner createQueryRunner( @@ -77,7 +80,8 @@ public static QueryRunner createQueryRunner( Optional workerCount, int cacheMaxSize, String storageFormat, - boolean addStorageFormatToPath) + boolean addStorageFormatToPath, + boolean isCoordinatorSidecarEnabled) throws Exception { QueryRunner defaultQueryRunner = createJavaQueryRunner(dataDirectory, storageFormat, addStorageFormatToPath); @@ -88,7 +92,7 @@ public static QueryRunner createQueryRunner( defaultQueryRunner.close(); - return createNativeQueryRunner(dataDirectory.get().toString(), prestoServerPath.get(), workerCount, cacheMaxSize, true, Optional.empty(), storageFormat, addStorageFormatToPath, false); + return createNativeQueryRunner(dataDirectory.get().toString(), prestoServerPath.get(), workerCount, cacheMaxSize, true, Optional.empty(), storageFormat, addStorageFormatToPath, false, isCoordinatorSidecarEnabled); } public static QueryRunner createJavaQueryRunner() @@ -251,7 +255,7 @@ public static QueryRunner createNativeIcebergQueryRunner( false, false, OptionalInt.of(workerCount.orElse(4)), - getExternalWorkerLauncher("iceberg", prestoServerPath, cacheMaxSize, remoteFunctionServerUds, false), + getExternalWorkerLauncher("iceberg", prestoServerPath, cacheMaxSize, remoteFunctionServerUds, false, false), dataDirectory, addStorageFormatToPath); } @@ -265,7 +269,8 @@ public static QueryRunner createNativeQueryRunner( Optional remoteFunctionServerUds, String storageFormat, boolean addStorageFormatToPath, - Boolean failOnNestedLoopJoin) + Boolean failOnNestedLoopJoin, + boolean isCoordinatorSidecarEnabled) throws Exception { // The property "hive.allow-drop-table" needs to be set to true because security is always "legacy" in NativeQueryRunner. @@ -282,13 +287,14 @@ public static QueryRunner createNativeQueryRunner( .put("http-server.http.port", "8081") .put("experimental.internal-communication.thrift-transport-enabled", String.valueOf(useThrift)) .putAll(getNativeWorkerSystemProperties()) + .putAll(isCoordinatorSidecarEnabled ? getNativeSidecarProperties() : ImmutableMap.of()) .build(), ImmutableMap.of(), "legacy", hiveProperties, workerCount, Optional.of(Paths.get(addStorageFormatToPath ? dataDirectory + "/" + storageFormat : dataDirectory)), - getExternalWorkerLauncher("hive", prestoServerPath, cacheMaxSize, remoteFunctionServerUds, failOnNestedLoopJoin)); + getExternalWorkerLauncher("hive", prestoServerPath, cacheMaxSize, remoteFunctionServerUds, failOnNestedLoopJoin, isCoordinatorSidecarEnabled)); } public static QueryRunner createNativeCteQueryRunner(boolean useThrift, String storageFormat) @@ -331,13 +337,13 @@ public static QueryRunner createNativeCteQueryRunner(boolean useThrift, String s hiveProperties, workerCount, Optional.of(Paths.get(addStorageFormatToPath ? dataDirectory + "/" + storageFormat : dataDirectory)), - getExternalWorkerLauncher("hive", prestoServerPath, cacheMaxSize, Optional.empty(), false)); + getExternalWorkerLauncher("hive", prestoServerPath, cacheMaxSize, Optional.empty(), false, false)); } public static QueryRunner createNativeQueryRunner(String remoteFunctionServerUds) throws Exception { - return createNativeQueryRunner(false, DEFAULT_STORAGE_FORMAT, Optional.ofNullable(remoteFunctionServerUds), false); + return createNativeQueryRunner(false, DEFAULT_STORAGE_FORMAT, Optional.ofNullable(remoteFunctionServerUds), false, false); } public static QueryRunner createNativeQueryRunner(boolean useThrift) @@ -349,16 +355,16 @@ public static QueryRunner createNativeQueryRunner(boolean useThrift) public static QueryRunner createNativeQueryRunner(boolean useThrift, boolean failOnNestedLoopJoin) throws Exception { - return createNativeQueryRunner(useThrift, DEFAULT_STORAGE_FORMAT, Optional.empty(), failOnNestedLoopJoin); + return createNativeQueryRunner(useThrift, DEFAULT_STORAGE_FORMAT, Optional.empty(), failOnNestedLoopJoin, false); } public static QueryRunner createNativeQueryRunner(boolean useThrift, String storageFormat) throws Exception { - return createNativeQueryRunner(useThrift, storageFormat, Optional.empty(), false); + return createNativeQueryRunner(useThrift, storageFormat, Optional.empty(), false, false); } - public static QueryRunner createNativeQueryRunner(boolean useThrift, String storageFormat, Optional remoteFunctionServerUds, Boolean failOnNestedLoopJoin) + public static QueryRunner createNativeQueryRunner(boolean useThrift, String storageFormat, Optional remoteFunctionServerUds, Boolean failOnNestedLoopJoin, boolean isCoordinatorSidecarEnabled) throws Exception { int cacheMaxSize = 0; @@ -372,7 +378,8 @@ public static QueryRunner createNativeQueryRunner(boolean useThrift, String stor remoteFunctionServerUds, storageFormat, true, - failOnNestedLoopJoin); + failOnNestedLoopJoin, + isCoordinatorSidecarEnabled); } // Start the remote function server. Return the UDS path used to communicate with it. @@ -399,10 +406,10 @@ public static String startRemoteFunctionServer(String remoteFunctionServerBinary public static NativeQueryRunnerParameters getNativeQueryRunnerParameters() { Path prestoServerPath = Paths.get(getProperty("PRESTO_SERVER") - .orElse("_build/debug/presto_cpp/main/presto_server")) + .orElse("_build/debug/presto_cpp/main/presto_server")) .toAbsolutePath(); Path dataDirectory = Paths.get(getProperty("DATA_DIR") - .orElse("target/velox_data")) + .orElse("target/velox_data")) .toAbsolutePath(); Optional workerCount = getProperty("WORKER_COUNT").map(Integer::parseInt); @@ -419,7 +426,7 @@ public static NativeQueryRunnerParameters getNativeQueryRunnerParameters() return new NativeQueryRunnerParameters(prestoServerPath, dataDirectory, workerCount); } - public static Optional> getExternalWorkerLauncher(String catalogName, String prestoServerPath, int cacheMaxSize, Optional remoteFunctionServerUds, Boolean failOnNestedLoopJoin) + public static Optional> getExternalWorkerLauncher(String catalogName, String prestoServerPath, int cacheMaxSize, Optional remoteFunctionServerUds, Boolean failOnNestedLoopJoin, boolean isCoordinatorSidecarEnabled) { return Optional.of((workerIndex, discoveryUri) -> { @@ -436,6 +443,12 @@ public static Optional> getExternalWorkerLaunc "system-memory-gb=4%n" + "http-server.http.port=%d", discoveryUri, port); + if (isCoordinatorSidecarEnabled) { + configProperties = format("%s%n" + + "native-sidecar=true%n" + + "presto.default-namespace=native.default%n", configProperties); + } + if (remoteFunctionServerUds.isPresent()) { String jsonSignaturesPath = Resources.getResource(REMOTE_FUNCTION_JSON_SIGNATURES).getFile(); configProperties = format("%s%n" + diff --git a/presto-native-sidecar-plugin/pom.xml b/presto-native-sidecar-plugin/pom.xml index 7a3d0cfefc96..dccdc60ce5a3 100644 --- a/presto-native-sidecar-plugin/pom.xml +++ b/presto-native-sidecar-plugin/pom.xml @@ -54,6 +54,11 @@ log + + com.facebook.airlift + log-manager + + com.facebook.presto @@ -125,5 +130,97 @@ http-client + + com.facebook.presto + presto-tests + test + test-jar + 0.290-SNAPSHOT + + + + com.facebook.presto + presto-tests + test + + + + com.facebook.presto + presto-native-execution + test + test-jar + 0.290-SNAPSHOT + + + + com.facebook.presto + presto-main + test + test-jar + + + + com.facebook.presto + presto-main + test + + + + com.facebook.presto + presto-tpcds + test + + + + com.facebook.airlift + jaxrs + test + + + + com.facebook.presto + presto-client + test + + + + com.facebook.airlift + jaxrs-testing + test + + + org.jetbrains + annotations + test + + + + + + + org.basepom.maven + duplicate-finder-maven-plugin + + + parquet.thrift + about.html + mozilla/public-suffix-list.txt + iceberg-build.properties + org.apache.avro.data/Json.avsc + + + com.esotericsoftware.kryo.* + com.esotericsoftware.minlog.Log + com.esotericsoftware.reflectasm.* + module-info + META-INF.versions.9.module-info + org.apache.avro.* + com.github.benmanes.caffeine.* + org.roaringbitmap.* + + + + + \ No newline at end of file diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunner.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunner.java new file mode 100644 index 000000000000..45142a0a217b --- /dev/null +++ b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunner.java @@ -0,0 +1,48 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.sidecar; + +import com.facebook.airlift.log.Logger; +import com.facebook.airlift.log.Logging; +import com.facebook.presto.nativeworker.NativeQueryRunnerUtils; +import com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils; +import com.facebook.presto.testing.QueryRunner; +import com.facebook.presto.tests.DistributedQueryRunner; + +import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin; + +public class NativeSidecarPluginQueryRunner +{ + private NativeSidecarPluginQueryRunner() {} + + public static void main(String[] args) + throws Exception + { + // You need to add "--user user" to your CLI for your queries to work. + Logging.initialize(); + + // Create tables before launching distributed runner. + QueryRunner javaQueryRunner = PrestoNativeQueryRunnerUtils.createJavaQueryRunner(false); + NativeQueryRunnerUtils.createAllTables(javaQueryRunner); + javaQueryRunner.close(); + + // Launch distributed runner. + DistributedQueryRunner queryRunner = (DistributedQueryRunner) PrestoNativeQueryRunnerUtils.createQueryRunner(false, true); + setupNativeSidecarPlugin(queryRunner); + Thread.sleep(10); + Logger log = Logger.get(DistributedQueryRunner.class); + log.info("======== SERVER STARTED ========"); + log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl()); + } +} diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java new file mode 100644 index 000000000000..1b6a9e54408d --- /dev/null +++ b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/NativeSidecarPluginQueryRunnerUtils.java @@ -0,0 +1,33 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.sidecar; +import com.facebook.presto.sidecar.functionNamespace.NativeFunctionNamespaceManagerFactory; +import com.facebook.presto.testing.QueryRunner; +import com.google.common.collect.ImmutableMap; + +public class NativeSidecarPluginQueryRunnerUtils +{ + private NativeSidecarPluginQueryRunnerUtils() {}; + + public static void setupNativeSidecarPlugin(QueryRunner queryRunner) + { + queryRunner.installCoordinatorPlugin(new NativeSidecarPlugin()); + queryRunner.loadNativeFunctionNamespaceManager( + NativeFunctionNamespaceManagerFactory.NAME, + "native", + ImmutableMap.of( + "supported-function-languages", "CPP", + "function-implementation-type", "CPP")); + } +} diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPlugin.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPlugin.java deleted file mode 100644 index bf8e0e29abcc..000000000000 --- a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPlugin.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.sidecar; - -import com.facebook.presto.spi.CoordinatorPlugin; -import com.facebook.presto.spi.function.FunctionNamespaceManagerContext; -import com.facebook.presto.spi.function.FunctionNamespaceManagerFactory; -import com.google.common.collect.ImmutableMap; -import org.testng.annotations.Test; - -import java.util.Optional; - -import static com.google.common.collect.Iterables.getOnlyElement; - -public class TestNativeSidecarPlugin -{ - private final CoordinatorPlugin plugin = new NativeSidecarPlugin(); - - @Test - public void testLoadNativeFunctionNamespaceManagerPlugin() - { - Iterable functionNamespaceManagerFactories = plugin.getFunctionNamespaceManagerFactories(); - FunctionNamespaceManagerFactory factory = getOnlyElement(functionNamespaceManagerFactories); - factory.create( - "unit-test", - ImmutableMap.of( - "function-implementation-type", "CPP", - "supported-function-languages", "CPP"), - new FunctionNamespaceManagerContext( - new UnimplementedTypeManager(), - Optional.of(new UnimplementedNodeManager()), - Optional.of(new UnimplementedFunctionMetadataManager()))); - } -} diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPluginFunctionNamespaceManager.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPluginFunctionNamespaceManager.java new file mode 100644 index 000000000000..71b841e470b7 --- /dev/null +++ b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/TestNativeSidecarPluginFunctionNamespaceManager.java @@ -0,0 +1,93 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.facebook.presto.sidecar; + +import com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils; +import com.facebook.presto.testing.MaterializedResult; +import com.facebook.presto.testing.MaterializedRow; +import com.facebook.presto.testing.QueryRunner; +import com.facebook.presto.tests.AbstractTestQueryFramework; +import com.facebook.presto.tests.DistributedQueryRunner; +import org.intellij.lang.annotations.Language; +import org.testng.annotations.Test; + +import java.util.List; +import java.util.regex.Pattern; + +import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createNation; +import static com.facebook.presto.nativeworker.NativeQueryRunnerUtils.createOrders; +import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin; +import static java.lang.String.format; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.fail; + +@Test(singleThreaded = true) +public class TestNativeSidecarPluginFunctionNamespaceManager + extends AbstractTestQueryFramework +{ + private static final String REGEX_FUNCTION_NAMESPACE = "native.default.*"; + private static final int FUNCTION_COUNT = 1375; + + @Override + protected void createTables() + { + QueryRunner queryRunner = (QueryRunner) getExpectedQueryRunner(); + createNation(queryRunner); + createOrders(queryRunner); + } + + @Override + protected QueryRunner createQueryRunner() + throws Exception + { + DistributedQueryRunner queryRunner = (DistributedQueryRunner) PrestoNativeQueryRunnerUtils.createQueryRunner(false, true); + setupNativeSidecarPlugin(queryRunner); + return queryRunner; + } + + @Override + protected QueryRunner createExpectedQueryRunner() + throws Exception + { + return PrestoNativeQueryRunnerUtils.createJavaQueryRunner(); + } + + @Test + public void testShowFunctions() + { + @Language("SQL") String sql = "SHOW FUNCTIONS"; + MaterializedResult actualResult = computeActual(sql); + List actualRows = actualResult.getMaterializedRows(); + assertEquals(actualRows.size(), FUNCTION_COUNT); + for (MaterializedRow actualRow : actualRows) { + List row = actualRow.getFields(); + String functionName = row.get(0).toString(); + if (Pattern.matches(REGEX_FUNCTION_NAMESPACE, functionName)) { + continue; + } + fail(format("No namespace match found for row: %s", row)); + } + } + + @Test + public void testBasicQueries() + { + assertQuery("select corr(nation.nationkey, nation.nationkey) from nation"); + assertQuery("select count(comment) from orders"); + assertQuery("select count(*) from nation"); + assertQuery("select lower(comment) from nation"); + assertQuery("select array[nationkey], array_constructor(comment) from nation"); + assertQuery("select count(abs(orderkey) between 1 and 60000) from orders group by orderkey"); + } +} diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedFunctionMetadataManager.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedFunctionMetadataManager.java deleted file mode 100644 index fd75c8b4b086..000000000000 --- a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedFunctionMetadataManager.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.sidecar; - -import com.facebook.presto.spi.function.FunctionHandle; -import com.facebook.presto.spi.function.FunctionMetadata; -import com.facebook.presto.spi.function.FunctionMetadataManager; -import com.facebook.presto.spi.function.Signature; -import com.facebook.presto.spi.function.SqlFunctionSupplier; - -class UnimplementedFunctionMetadataManager - implements FunctionMetadataManager -{ - @Override - public FunctionMetadata getFunctionMetadata(FunctionHandle functionHandle) - { - throw new UnsupportedOperationException(); - } - - @Override - public SqlFunctionSupplier getSpecializedFunctionKey(Signature signature) - { - throw new UnsupportedOperationException(); - } -} diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedNodeManager.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedNodeManager.java deleted file mode 100644 index 38f16b9d8c95..000000000000 --- a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedNodeManager.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.sidecar; - -import com.facebook.presto.spi.HostAddress; -import com.facebook.presto.spi.Node; -import com.facebook.presto.spi.NodeManager; -import com.facebook.presto.spi.NodePoolType; - -import java.net.URI; -import java.util.Set; - -class UnimplementedNodeManager - implements NodeManager -{ - @Override - public Set getAllNodes() - { - throw new UnsupportedOperationException(); - } - - @Override - public Set getWorkerNodes() - { - throw new UnsupportedOperationException(); - } - - @Override - public Node getCurrentNode() - { - return new Node() - { - @Override - public String getHost() - { - throw new UnsupportedOperationException(); - } - - @Override - public HostAddress getHostAndPort() - { - throw new UnsupportedOperationException(); - } - - @Override - public URI getHttpUri() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getNodeIdentifier() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getVersion() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isCoordinator() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isResourceManager() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isCatalogServer() - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean isCoordinatorSidecar() - { - throw new UnsupportedOperationException(); - } - - @Override - public NodePoolType getPoolType() - { - throw new UnsupportedOperationException(); - } - }; - } - - @Override - public Node getSidecarNode() - { - throw new UnsupportedOperationException(); - } - - @Override - public String getEnvironment() - { - throw new UnsupportedOperationException(); - } -} diff --git a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedTypeManager.java b/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedTypeManager.java deleted file mode 100644 index 61d6e9a6453c..000000000000 --- a/presto-native-sidecar-plugin/src/test/java/com/facebook/presto/sidecar/UnimplementedTypeManager.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.facebook.presto.sidecar; - -import com.facebook.presto.common.type.Type; -import com.facebook.presto.common.type.TypeManager; -import com.facebook.presto.common.type.TypeSignature; -import com.facebook.presto.common.type.TypeSignatureParameter; - -import java.util.List; - -public class UnimplementedTypeManager - implements TypeManager -{ - @Override - public Type getType(TypeSignature signature) - { - throw new UnsupportedOperationException(); - } - - @Override - public Type getParameterizedType(String baseTypeName, List typeParameters) - { - throw new UnsupportedOperationException(); - } - - @Override - public boolean canCoerce(Type actualType, Type expectedType) - { - throw new UnsupportedOperationException(); - } -}