diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 115bffd45c32..e72d555f197a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -643,15 +643,11 @@ jobs: env: BIGQUERY_CREDENTIALS_KEY: ${{ secrets.BIGQUERY_CREDENTIALS_KEY }} GCP_STORAGE_BUCKET: ${{ vars.GCP_STORAGE_BUCKET }} - BIGQUERY_TESTING_PROJECT_ID: ${{ vars.BIGQUERY_TESTING_PROJECT_ID }} - BIGQUERY_TESTING_PARENT_PROJECT_ID: ${{ vars.BIGQUERY_TESTING_PARENT_PROJECT_ID }} if: matrix.modules == 'plugin/trino-bigquery' && !contains(matrix.profile, 'cloud-tests-2') && (env.CI_SKIP_SECRETS_PRESENCE_CHECKS != '' || env.BIGQUERY_CREDENTIALS_KEY != '') run: | $MAVEN test ${MAVEN_TEST} -pl :trino-bigquery -Pcloud-tests-1 \ -Dbigquery.credentials-key="${BIGQUERY_CREDENTIALS_KEY}" \ - -Dtesting.gcp-storage-bucket="${GCP_STORAGE_BUCKET}" \ - -Dtesting.bigquery-project-id="${BIGQUERY_TESTING_PROJECT_ID}" \ - -Dtesting.bigquery-parent-project-id="${BIGQUERY_TESTING_PARENT_PROJECT_ID}" + -Dtesting.gcp-storage-bucket="${GCP_STORAGE_BUCKET}" - name: Cloud BigQuery Smoke Tests id: tests-bq-smoke env: diff --git a/plugin/trino-bigquery/pom.xml b/plugin/trino-bigquery/pom.xml index 818ac117a7e5..3273806736df 100644 --- a/plugin/trino-bigquery/pom.xml +++ b/plugin/trino-bigquery/pom.xml @@ -538,7 +538,6 @@ **/TestBigQueryCaseInsensitiveMappingWithCache.java **/TestBigQuery*FailureRecoveryTest.java **/TestBigQueryWithProxyTest.java - **/TestBigQueryParentProjectId.java @@ -559,7 +558,6 @@ **/TestBigQueryAvroConnectorTest.java - **/TestBigQueryParentProjectId.java diff --git a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryClient.java b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryClient.java index bca723d6567d..5847e2d3f6de 100644 --- a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryClient.java +++ b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryClient.java @@ -287,7 +287,7 @@ public TableInfo getCachedTable(Duration viewExpiration, TableInfo remoteTableId */ public String getParentProjectId() { - return Optional.ofNullable(bigQuery.getOptions().getQuotaProjectId()).orElse(bigQuery.getOptions().getProjectId()); + return bigQuery.getOptions().getProjectId(); } /** diff --git a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/CredentialsOptionsConfigurer.java b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/CredentialsOptionsConfigurer.java index d15dc1b14517..3ecce6bae351 100644 --- a/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/CredentialsOptionsConfigurer.java +++ b/plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/CredentialsOptionsConfigurer.java @@ -31,13 +31,11 @@ public class CredentialsOptionsConfigurer implements BigQueryOptionsConfigurer { private final BigQueryCredentialsSupplier credentialsSupplier; - private final Optional configProjectId; private final Optional configParentProjectId; @Inject public CredentialsOptionsConfigurer(BigQueryConfig bigQueryConfig, BigQueryCredentialsSupplier credentialsSupplier) { - this.configProjectId = bigQueryConfig.getProjectId(); this.configParentProjectId = bigQueryConfig.getParentProjectId(); this.credentialsSupplier = requireNonNull(credentialsSupplier, "credentialsSupplier is null"); } @@ -46,11 +44,9 @@ public CredentialsOptionsConfigurer(BigQueryConfig bigQueryConfig, BigQueryCrede public BigQueryOptions.Builder configure(BigQueryOptions.Builder builder, ConnectorSession session) { Optional credentials = credentialsSupplier.getCredentials(session); - String projectId = resolveProjectId(configProjectId, credentials); + String parentProjectId = resolveProjectId(configParentProjectId, credentials); credentials.ifPresent(builder::setCredentials); - builder.setProjectId(projectId); - // Quota project id is different name for parent project id, both indicates project used for quota and billing purposes. - configParentProjectId.ifPresent(builder::setQuotaProjectId); + builder.setProjectId(parentProjectId); return builder; } diff --git a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryParentProjectId.java b/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryParentProjectId.java deleted file mode 100644 index 45abd6ba92ea..000000000000 --- a/plugin/trino-bigquery/src/test/java/io/trino/plugin/bigquery/TestBigQueryParentProjectId.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.testing.AbstractTestQueryFramework; -import io.trino.testing.QueryRunner; -import org.junit.jupiter.api.Test; - -import static io.trino.testing.TestingProperties.requiredNonEmptySystemProperty; -import static io.trino.tpch.TpchTable.NATION; -import static java.lang.String.format; -import static org.assertj.core.api.Assertions.assertThat; - -class TestBigQueryParentProjectId - extends AbstractTestQueryFramework -{ - private final String testingProjectId; - private final String testingParentProjectId; - - TestBigQueryParentProjectId() - { - testingProjectId = requiredNonEmptySystemProperty("testing.bigquery-project-id"); - testingParentProjectId = requiredNonEmptySystemProperty("testing.bigquery-parent-project-id"); - } - - @Override - protected QueryRunner createQueryRunner() - throws Exception - { - return BigQueryQueryRunner.builder() - .setConnectorProperties(ImmutableMap.builder() - .put("bigquery.project-id", testingProjectId) - .put("bigquery.parent-project-id", testingParentProjectId) - .buildOrThrow()) - .setInitialTables(ImmutableList.of(NATION)) - .build(); - } - - @Test - void testQueriesWithParentProjectId() - { - assertThat(computeScalar("SELECT name FROM bigquery.tpch.nation WHERE nationkey = 0")).isEqualTo("ALGERIA"); - assertThat(computeScalar("SELECT * FROM TABLE(bigquery.system.query(query => 'SELECT name FROM tpch.nation WHERE nationkey = 0'))")).isEqualTo("ALGERIA"); - assertThat(computeScalar(format("SELECT * FROM TABLE(bigquery.system.query(query => 'SELECT name FROM %s.tpch.nation WHERE nationkey = 0'))", testingProjectId))) - .isEqualTo("ALGERIA"); - } -}