Skip to content

[native] Enable sidecar in presto-native-tests module #25174

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/prestocpp-linux-build-and-unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> extraProperties, String storageFormat)
public static QueryRunner createNativeQueryRunner(Map<String, String> extraProperties, String storageFormat, boolean isCoordinatorSidecarEnabled)
throws Exception
{
int cacheMaxSize = 0;
Expand All @@ -439,7 +439,7 @@ public static QueryRunner createNativeQueryRunner(Map<String, String> extraPrope
storageFormat,
true,
false,
false,
isCoordinatorSidecarEnabled,
false,
false,
false,
Expand Down
20 changes: 20 additions & 0 deletions presto-native-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
<artifactId>testng</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-common</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-main-base</artifactId>
Expand Down Expand Up @@ -54,6 +60,20 @@
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-native-sidecar-plugin</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.facebook.presto</groupId>
<artifactId>presto-native-sidecar-plugin</artifactId>
<scope>test</scope>
<type>test-jar</type>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
}
}
Loading