diff --git a/.github/workflows/prestocpp-linux-build-and-unit-test.yml b/.github/workflows/prestocpp-linux-build-and-unit-test.yml index 1746d28ddb465..74a002f5b7898 100644 --- a/.github/workflows/prestocpp-linux-build-and-unit-test.yml +++ b/.github/workflows/prestocpp-linux-build-and-unit-test.yml @@ -172,6 +172,7 @@ jobs: fail-fast: false matrix: storage-format: [ "PARQUET", "DWRF" ] + enable-sidecar: [ "true", "false" ] container: image: prestodb/presto-native-dependency:0.293-20250522140509-484b00e env: @@ -235,6 +236,7 @@ jobs: ${MAVEN_TEST} \ -pl 'presto-native-tests' \ -DstorageFormat=${{ matrix.storage-format }} \ + -DsidecarEnabled=${{ matrix.enable-sidecar }} \ -Dtest="${TESTCLASSES}" \ -DPRESTO_SERVER=${PRESTO_SERVER_PATH} \ -DDATA_DIR=${RUNNER_TEMP} \ 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 acd0244e054f5..ed6da41339c42 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 @@ -424,7 +424,7 @@ public static QueryRunner createNativeQueryRunner(String remoteFunctionServerUds return createNativeQueryRunner(false, DEFAULT_STORAGE_FORMAT, Optional.ofNullable(remoteFunctionServerUds), false, false, false, false, false); } - public static QueryRunner createNativeQueryRunner(Map extraProperties, String storageFormat) + public static QueryRunner createNativeQueryRunner(Map extraProperties, String storageFormat, boolean isCoordinatorSidecarEnabled) throws Exception { int cacheMaxSize = 0; @@ -439,7 +439,7 @@ public static QueryRunner createNativeQueryRunner(Map extraPrope storageFormat, true, false, - false, + isCoordinatorSidecarEnabled, false, false, false, diff --git a/presto-native-tests/pom.xml b/presto-native-tests/pom.xml index ac0e0ff548421..d3479aba0f783 100644 --- a/presto-native-tests/pom.xml +++ b/presto-native-tests/pom.xml @@ -22,6 +22,12 @@ testng + + com.facebook.presto + presto-common + test + + com.facebook.presto presto-main-base @@ -54,6 +60,20 @@ com.google.guava guava + + + com.facebook.presto + presto-native-sidecar-plugin + test + + + + com.facebook.presto + presto-native-sidecar-plugin + test + test-jar + ${project.version} + diff --git a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestDistributedEngineOnlyQueries.java b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestDistributedEngineOnlyQueries.java index e0ae26b31fd65..b1195dc941c80 100644 --- a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestDistributedEngineOnlyQueries.java +++ b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestDistributedEngineOnlyQueries.java @@ -28,18 +28,33 @@ import java.time.format.DateTimeFormatter; import java.util.Objects; +import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin; import static com.google.common.base.Preconditions.checkState; +import static java.lang.Boolean.parseBoolean; public class TestDistributedEngineOnlyQueries extends AbstractTestEngineOnlyQueries { - private static final String timeTypeUnsupportedError = ".*Failed to parse type \\[time.*"; + private static final String timeTypeUnsupportedErrorWithSidecarDisabled = ".*Failed to parse type \\[time.*"; + private static final String timeTypeUnsupportedErrorWithSidecarEnabled = "^Unknown type time.*"; + private String timeTypeUnsupportedError; - @Parameters("storageFormat") + @Parameters({"storageFormat", "sidecarEnabled"}) @Override protected QueryRunner createQueryRunner() throws Exception { - return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat")); + if (parseBoolean(System.getProperty("sidecarEnabled"))) { + timeTypeUnsupportedError = timeTypeUnsupportedErrorWithSidecarEnabled; + QueryRunner queryRunner = + PrestoNativeQueryRunnerUtils.createNativeQueryRunner( + ImmutableMap.of(), + System.getProperty("storageFormat"), + true); + setupNativeSidecarPlugin(queryRunner); + return queryRunner; + } + timeTypeUnsupportedError = timeTypeUnsupportedErrorWithSidecarDisabled; + return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat"), false); } @Parameters("storageFormat") diff --git a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestOrderByQueries.java b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestOrderByQueries.java index ec8f32b2261fd..b5b92e5acaf04 100644 --- a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestOrderByQueries.java +++ b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestOrderByQueries.java @@ -21,14 +21,26 @@ import org.testng.annotations.Parameters; import org.testng.annotations.Test; +import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin; +import static java.lang.Boolean.parseBoolean; + public class TestOrderByQueries extends AbstractTestOrderByQueries { - @Parameters("storageFormat") + @Parameters({"storageFormat", "sidecarEnabled"}) @Override protected QueryRunner createQueryRunner() throws Exception { - return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat")); + if (parseBoolean(System.getProperty("sidecarEnabled"))) { + QueryRunner queryRunner = + PrestoNativeQueryRunnerUtils.createNativeQueryRunner( + ImmutableMap.of(), + System.getProperty("storageFormat"), + true); + setupNativeSidecarPlugin(queryRunner); + return queryRunner; + } + return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat"), false); } @Parameters("storageFormat") diff --git a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueries.java b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueries.java index ebc8f19105c09..a013fd7b5d8aa 100644 --- a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueries.java +++ b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueries.java @@ -20,14 +20,26 @@ import com.google.common.collect.ImmutableMap; import org.testng.annotations.Parameters; +import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin; +import static java.lang.Boolean.parseBoolean; + public class TestRepartitionQueries extends AbstractTestRepartitionQueries { - @Parameters("storageFormat") + @Parameters({"storageFormat", "sidecarEnabled"}) @Override protected QueryRunner createQueryRunner() throws Exception { - return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat")); + if (parseBoolean(System.getProperty("sidecarEnabled"))) { + QueryRunner queryRunner = + PrestoNativeQueryRunnerUtils.createNativeQueryRunner( + ImmutableMap.of(), + System.getProperty("storageFormat"), + true); + setupNativeSidecarPlugin(queryRunner); + return queryRunner; + } + return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat"), false); } @Parameters("storageFormat") diff --git a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueriesWithSmallPages.java b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueriesWithSmallPages.java index 5e354f3cd3cf6..c119616c0c780 100644 --- a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueriesWithSmallPages.java +++ b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestRepartitionQueriesWithSmallPages.java @@ -20,17 +20,32 @@ import com.google.common.collect.ImmutableMap; import org.testng.annotations.Parameters; +import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin; +import static java.lang.Boolean.parseBoolean; + public class TestRepartitionQueriesWithSmallPages extends AbstractTestRepartitionQueries { - @Parameters("storageFormat") + @Parameters({"storageFormat", "sidecarEnabled"}) @Override - protected QueryRunner createQueryRunner() throws Exception + protected QueryRunner createQueryRunner() + throws Exception { + if (parseBoolean(System.getProperty("sidecarEnabled"))) { + QueryRunner queryRunner = + PrestoNativeQueryRunnerUtils.createNativeQueryRunner( + // Use small SerializedPages to force flushing + ImmutableMap.of("driver.max-page-partitioning-buffer-size", "200B"), + System.getProperty("storageFormat"), + true); + setupNativeSidecarPlugin(queryRunner); + return queryRunner; + } return PrestoNativeQueryRunnerUtils.createNativeQueryRunner( // Use small SerializedPages to force flushing ImmutableMap.of("driver.max-page-partitioning-buffer-size", "200B"), - System.getProperty("storageFormat")); + System.getProperty("storageFormat"), + false); } @Parameters("storageFormat") diff --git a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestWindowQueries.java b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestWindowQueries.java index 6f173e80419f8..b775cec34e58d 100644 --- a/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestWindowQueries.java +++ b/presto-native-tests/src/test/java/com/facebook/presto/nativetests/TestWindowQueries.java @@ -15,22 +15,41 @@ import com.facebook.presto.nativeworker.NativeQueryRunnerUtils; import com.facebook.presto.nativeworker.PrestoNativeQueryRunnerUtils; +import com.facebook.presto.testing.MaterializedResult; import com.facebook.presto.testing.QueryRunner; import com.facebook.presto.tests.AbstractTestWindowQueries; import com.google.common.collect.ImmutableMap; +import org.testng.SkipException; import org.testng.annotations.Parameters; import org.testng.annotations.Test; +import static com.facebook.presto.common.type.BigintType.BIGINT; +import static com.facebook.presto.common.type.VarcharType.createVarcharType; +import static com.facebook.presto.sidecar.NativeSidecarPluginQueryRunnerUtils.setupNativeSidecarPlugin; +import static com.facebook.presto.testing.MaterializedResult.resultBuilder; +import static com.facebook.presto.testing.assertions.Assert.assertEquals; +import static java.lang.Boolean.parseBoolean; + public class TestWindowQueries extends AbstractTestWindowQueries { private static final String frameTypeDiffersError = ".*Window frame of type RANGE does not match types of the ORDER BY and frame column.*"; - @Parameters("storageFormat") + @Parameters({"storageFormat", "sidecarEnabled"}) @Override - protected QueryRunner createQueryRunner() throws Exception + protected QueryRunner createQueryRunner() + throws Exception { - return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat")); + if (parseBoolean(System.getProperty("sidecarEnabled"))) { + QueryRunner queryRunner = + PrestoNativeQueryRunnerUtils.createNativeQueryRunner( + ImmutableMap.of(), + System.getProperty("storageFormat"), + true); + setupNativeSidecarPlugin(queryRunner); + return queryRunner; + } + return PrestoNativeQueryRunnerUtils.createNativeQueryRunner(ImmutableMap.of(), System.getProperty("storageFormat"), false); } @Parameters("storageFormat") @@ -177,13 +196,13 @@ public void testMultipleWindowFunctions() "(3, ARRAY[DATE '2222-01-01', DATE '3333-01-01'], 5.5)"); assertQueryFails("SELECT x, array_agg(a) OVER(ORDER BY x RANGE BETWEEN 2 PRECEDING AND CURRENT ROW), array_agg(a) OVER(ORDER BY x RANGE BETWEEN CURRENT ROW AND 2 FOLLOWING) " + - "FROM (VALUES " + - "(1.0, 1), " + - "(2.0, 2), " + - "(3.0, 3), " + - "(4.0, 4), " + - "(5.0, 5), " + - "(6.0, 6)) T(x, a)", frameTypeDiffersError); + "FROM (VALUES " + + "(1.0, 1), " + + "(2.0, 2), " + + "(3.0, 3), " + + "(4.0, 4), " + + "(5.0, 5), " + + "(6.0, 6)) T(x, a)", frameTypeDiffersError); } /// The first query in this test fails because the Window's ORDER BY column type differs from the frame bound type. @@ -230,4 +249,27 @@ public void testTypes() "(INTERVAL '2' month, ARRAY[INTERVAL '1' month, INTERVAL '2' month]), " + "(INTERVAL '5' year, ARRAY[INTERVAL '5' year])"); } + + // Todo: Enable this test case when support for varchar(N) is added in native execution. + // The return types do not match on the native query runner : types=[varchar, bigint] and the java query runner: types=[varchar(3), bigint]. + @Override + @Parameters("sidecarEnabled") + @Test + public void testWindowFunctionWithGroupBy() + { + if (parseBoolean(System.getProperty("sidecarEnabled"))) { + throw new SkipException("Skipping this test because sidecar is enabled"); + } + + MaterializedResult actual = computeActual("" + + "SELECT *, rank() OVER (PARTITION BY x)\n" + + "FROM (SELECT 'foo' x)\n" + + "GROUP BY 1"); + + MaterializedResult expected = resultBuilder(getSession(), createVarcharType(3), BIGINT) + .row("foo", 1L) + .build(); + + assertEquals(actual, expected); + } }