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-tests/pom.xml b/presto-native-tests/pom.xml index 4520f543143fe..8304698c4a83d 100644 --- a/presto-native-tests/pom.xml +++ b/presto-native-tests/pom.xml @@ -54,6 +54,26 @@ com.google.guava guava + + + com.facebook.presto + presto-common + test + + + + 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 9f60d93f30312..873afbefea8d0 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 @@ -27,22 +27,34 @@ 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 timeTypeUnsupportedErrorWithoutSidecar = ".*Failed to parse type \\[time.*"; + private static final String timeTypeUnsupportedErrorWithSidecar = "^Unknown type time.*"; + private String timeTypeUnsupportedError = timeTypeUnsupportedErrorWithoutSidecar; - @Parameters("storageFormat") + @Parameters({"storageFormat", "sidecarEnabled"}) @Override - protected QueryRunner createQueryRunner() throws Exception + protected QueryRunner createQueryRunner() + throws Exception { - return PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder() + boolean sidecar = parseBoolean(System.getProperty("sidecarEnabled")); + QueryRunner queryRunner = PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder() .setStorageFormat(System.getProperty("storageFormat")) .setAddStorageFormatToPath(true) .setUseThrift(true) + .setCoordinatorSidecarEnabled(sidecar) .build(); + if (sidecar) { + timeTypeUnsupportedError = timeTypeUnsupportedErrorWithSidecar; + setupNativeSidecarPlugin(queryRunner); + } + return queryRunner; } @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 529d18e55ca6f..7a71581d3a294 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 @@ -20,18 +20,27 @@ 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.nativeHiveQueryRunnerBuilder() + boolean sidecar = parseBoolean(System.getProperty("sidecarEnabled")); + QueryRunner queryRunner = PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder() .setStorageFormat(System.getProperty("storageFormat")) .setAddStorageFormatToPath(true) .setUseThrift(true) + .setCoordinatorSidecarEnabled(sidecar) .build(); + if (sidecar) { + setupNativeSidecarPlugin(queryRunner); + } + return queryRunner; } @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 898649862193f..ba784f6c1a149 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 @@ -19,18 +19,27 @@ import com.facebook.presto.tests.AbstractTestRepartitionQueries; 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.nativeHiveQueryRunnerBuilder() + boolean sidecar = parseBoolean(System.getProperty("sidecarEnabled")); + QueryRunner queryRunner = PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder() .setStorageFormat(System.getProperty("storageFormat")) .setAddStorageFormatToPath(true) .setUseThrift(true) + .setCoordinatorSidecarEnabled(sidecar) .build(); + if (sidecar) { + setupNativeSidecarPlugin(queryRunner); + } + return queryRunner; } @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 14a0102edb249..9ef3a5df236eb 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,21 +20,30 @@ 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 { - return PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder() + boolean sidecar = parseBoolean(System.getProperty("sidecarEnabled")); + QueryRunner queryRunner = PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder() .setStorageFormat(System.getProperty("storageFormat")) .setAddStorageFormatToPath(true) .setUseThrift(true) .setExtraProperties( // Use small SerializedPages to force flushing ImmutableMap.of("driver.max-page-partitioning-buffer-size", "200B")) + .setCoordinatorSidecarEnabled(sidecar) .build(); + if (sidecar) { + setupNativeSidecarPlugin(queryRunner); + } + return queryRunner; } @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 86f40db18744e..906dcca24d49c 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,25 +15,42 @@ 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 org.intellij.lang.annotations.Language; 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.createUnboundedVarcharType; +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.nativeHiveQueryRunnerBuilder() + boolean sidecar = parseBoolean(System.getProperty("sidecarEnabled")); + QueryRunner queryRunner = PrestoNativeQueryRunnerUtils.nativeHiveQueryRunnerBuilder() .setStorageFormat(System.getProperty("storageFormat")) .setAddStorageFormatToPath(true) .setUseThrift(true) + .setCoordinatorSidecarEnabled(sidecar) .build(); + if (sidecar) { + setupNativeSidecarPlugin(queryRunner); + } + return queryRunner; } @Parameters("storageFormat") @@ -236,4 +253,30 @@ public void testTypes() "(INTERVAL '2' month, ARRAY[INTERVAL '1' month, INTERVAL '2' month]), " + "(INTERVAL '5' year, ARRAY[INTERVAL '5' year])"); } + + // Todo: Refactor 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() + { + @Language("SQL") String sql = "SELECT *, rank() OVER (PARTITION BY x)\n" + + "FROM (SELECT 'foo' x)\n" + + "GROUP BY 1"; + + MaterializedResult actual = computeActual(sql); + MaterializedResult expected; + if (parseBoolean(System.getProperty("sidecarEnabled"))) { + expected = resultBuilder(getSession(), createUnboundedVarcharType(), BIGINT) + .row("foo", 1L) + .build(); + } + else { + expected = resultBuilder(getSession(), createVarcharType(3), BIGINT) + .row("foo", 1L) + .build(); + } + assertEquals(actual, expected); + } }