Skip to content
Merged
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 plugin/trino-bigquery/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@
<exclude>**/TestBigQueryMetadataCaching.java</exclude>
<exclude>**/TestBigQueryAvroTypeMapping.java</exclude>
<exclude>**/TestBigQueryArrowTypeMapping.java</exclude>
<exclude>**/TestBigQueryArrowSerialization.java</exclude>
<exclude>**/TestBigQueryMetadata.java</exclude>
<exclude>**/TestBigQueryInstanceCleaner.java</exclude>
<exclude>**/TestBigQueryCaseInsensitiveMapping.java</exclude>
Expand Down Expand Up @@ -590,6 +591,7 @@
<includes>
<include>**/TestBigQueryWithDifferentProjectIdConnectorSmokeTest.java</include>
<include>**/TestBigQueryWithProxyTest.java</include>
<include>**/TestBigQueryArrowSerialization.java</include>
<include>**/TestBigQueryArrowTypeMapping.java</include>
<include>**/TestBigQueryAvroTypeMapping.java</include>
<include>**/TestBigQueryMetadataCaching.java</include>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public BigQueryArrowToPageConverter(BigQueryTypeManager typeManager, BufferAlloc
.map(field -> field.createVector(allocator))
.collect(toImmutableList());
root = new VectorSchemaRoot(vectors);
verify(vectors.size() == columns.size(), "Vectors, columns size differ");
loader = new VectorLoader(root, INSTANCE);
}

Expand Down
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);
}
}