Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix BigQuery FTE leaving temporary tables behind
also isolates temporary table names to have a common prefix for the same query id
- Loading branch information
Showing
12 changed files
with
313 additions
and
62 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/TemporaryTables.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,49 @@ | ||
/* | ||
* 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.base; | ||
|
||
import io.trino.spi.connector.ConnectorSession; | ||
|
||
import java.util.HexFormat; | ||
import java.util.concurrent.ThreadLocalRandom; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
public class TemporaryTables | ||
{ | ||
private static final HexFormat hexFormat = HexFormat.of(); | ||
public static final String TEMPORARY_TABLE_NAME_PREFIX = "tmp_trino_"; | ||
|
||
public static String temporaryTableNamePrefix(String queryId) | ||
{ | ||
requireNonNull(queryId, "queryId is null"); | ||
return String.format("%s%s_", TEMPORARY_TABLE_NAME_PREFIX, hexFormat.toHexDigits(queryId.hashCode())); | ||
} | ||
|
||
public static String generateTemporaryTableName(String queryId) | ||
{ | ||
requireNonNull(queryId, "queryId is null"); | ||
return temporaryTableNamePrefix(queryId) + hexFormat.toHexDigits(ThreadLocalRandom.current().nextInt()); | ||
} | ||
|
||
public static String generateTemporaryTableName(ConnectorSession session) | ||
{ | ||
requireNonNull(session, "session is null"); | ||
return generateTemporaryTableName(session.getQueryId()); | ||
} | ||
|
||
private TemporaryTables() | ||
{ | ||
} | ||
} |
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
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
19 changes: 19 additions & 0 deletions
19
plugin/trino-bigquery/src/main/java/io/trino/plugin/bigquery/BigQueryMetadataFactory.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,19 @@ | ||
/* | ||
* 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; | ||
|
||
public interface BigQueryMetadataFactory | ||
{ | ||
BigQueryMetadata create(BigQueryTransactionHandle transaction); | ||
} |
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
Oops, something went wrong.