-
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.
Fix failure when reading BigQuery views with Arrow
The size of 'vectors' and 'columns' in BigQueryArrowToPageConverter can be different when columns in predicates don't exist in projection when materializing BigQuery views.
- Loading branch information
Showing
3 changed files
with
69 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
67 changes: 67 additions & 0 deletions
67
...trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryArrowSerialization.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,67 @@ | ||
/* | ||
* 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.bigquery; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.ImmutableMap; | ||
import io.trino.plugin.bigquery.BigQueryQueryRunner.BigQuerySqlExecutor; | ||
import io.trino.testing.AbstractTestQueryFramework; | ||
import io.trino.testing.QueryRunner; | ||
import org.intellij.lang.annotations.Language; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.trino.testing.TestingNames.randomNameSuffix; | ||
|
||
public class TestBigQueryArrowSerialization | ||
extends AbstractTestQueryFramework | ||
{ | ||
private final BigQuerySqlExecutor bigQuerySqlExecutor; | ||
|
||
public TestBigQueryArrowSerialization() | ||
{ | ||
this.bigQuerySqlExecutor = new BigQuerySqlExecutor(); | ||
} | ||
|
||
@Override | ||
protected QueryRunner createQueryRunner() | ||
throws Exception | ||
{ | ||
return BigQueryQueryRunner.createQueryRunner( | ||
ImmutableMap.of(), | ||
ImmutableMap.of("bigquery.experimental.arrow-serialization.enabled", "true"), | ||
ImmutableList.of()); | ||
} | ||
|
||
@Test | ||
void testViewProjectionPredicates() | ||
{ | ||
// Run query that columns in WHERE clause don't exist in projections. | ||
// Columns in ReadSession.setRowRestriction in ReadSessionCreator must exist in selected fields. | ||
String viewName = "test_projection_predicates_" + randomNameSuffix(); | ||
|
||
onBigQuery("CREATE VIEW test." + viewName + " AS SELECT 1 AS id, 'test' AS data"); | ||
try { | ||
assertQuery("SELECT data FROM test." + viewName + " WHERE id = 1", "VALUES 'test'"); | ||
assertQuery("SELECT id FROM test." + viewName + " WHERE data = 'test'", "VALUES 1"); | ||
} | ||
finally { | ||
onBigQuery("DROP VIEW test." + viewName); | ||
} | ||
} | ||
|
||
private void onBigQuery(@Language("SQL") String sql) | ||
{ | ||
bigQuerySqlExecutor.execute(sql); | ||
} | ||
} |