-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow empty values within partitioned fragment
In some cases, a subplan containing a remote exchange (which results in a partitioned fragment) can be replaced with an empty Values node. In the process, the remote exchange is removed, which leaves the Values node within the downstream partitioned fragment. The plan fragmenter cannot currently deal with that scenario. It fails with an error indicating the partitioning is already set. However, it is for an empty Values to appear within a partitioned fragment, since there are no issues with rows being "replicated" across multiple fragments.
- Loading branch information
Showing
3 changed files
with
120 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestIssue14317.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* 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 io.trino.plugin.hive; | ||
|
||
import io.trino.sql.query.QueryAssertions; | ||
import io.trino.testing.DistributedQueryRunner; | ||
import org.testng.annotations.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Test for https://github.com/trinodb/trino/issues/14317 | ||
* <p> | ||
* The only known reproduction involves a connector that exposes partitioned tables | ||
* and supports predicate pushdown. | ||
*/ | ||
public class TestIssue14317 | ||
{ | ||
@Test | ||
public void test() | ||
throws Exception | ||
{ | ||
HiveQueryRunner.Builder<?> builder = HiveQueryRunner.builder() | ||
.setCreateTpchSchemas(false); | ||
|
||
try (DistributedQueryRunner queryRunner = builder.build(); | ||
QueryAssertions assertions = new QueryAssertions(queryRunner);) { | ||
queryRunner.execute("CREATE SCHEMA s"); | ||
|
||
queryRunner.execute("CREATE TABLE s.t (a bigint, b bigint)"); | ||
queryRunner.execute("CREATE TABLE s.u (c bigint, d bigint) WITH (partitioned_by = array['d'])"); | ||
queryRunner.execute("CREATE TABLE s.v (e bigint, f bigint)"); | ||
|
||
queryRunner.execute("INSERT INTO s.t VALUES (5, 6)"); | ||
queryRunner.execute("INSERT INTO s.u VALUES (5, 6)"); | ||
queryRunner.execute("INSERT INTO s.v VALUES (5, 6)"); | ||
|
||
assertThat(assertions.query(""" | ||
WITH t1 AS ( | ||
SELECT a | ||
FROM ( | ||
SELECT a, ROW_NUMBER() OVER (PARTITION BY a) AS rn | ||
FROM s.t) | ||
WHERE rn = 1), | ||
t2 AS (SELECT c FROM s.u WHERE d - 5 = 8) | ||
SELECT v.e | ||
FROM s.v | ||
INNER JOIN t1 on v.e = t1.a | ||
INNER JOIN t2 ON v.e = t2.c | ||
""")) | ||
.returnsEmptyResult(); | ||
|
||
queryRunner.execute("DROP TABLE s.t"); | ||
queryRunner.execute("DROP TABLE s.u"); | ||
queryRunner.execute("DROP TABLE s.v"); | ||
queryRunner.execute("DROP SCHEMA s"); | ||
} | ||
} | ||
} |