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
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_ROW_LEVEL_DELETE;
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_TOPN_PUSHDOWN;
import static io.trino.testing.TestingConnectorBehavior.SUPPORTS_TOPN_PUSHDOWN_WITH_VARCHAR;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.testing.assertions.Assert.assertEventually;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static java.lang.String.format;
import static java.util.Locale.ENGLISH;
import static java.util.concurrent.Executors.newCachedThreadPool;
Expand Down Expand Up @@ -1785,7 +1785,7 @@ public void testDynamicFilteringDomainCompactionThreshold()
{
skipTestUnless(hasBehavior(SUPPORTS_CREATE_TABLE_WITH_DATA));
skipTestUnless(hasBehavior(SUPPORTS_DYNAMIC_FILTER_PUSHDOWN));
String tableName = "orderkeys_" + randomTableSuffix();
String tableName = "orderkeys_" + randomNameSuffix();
assertUpdate("CREATE TABLE " + tableName + " (orderkey) AS VALUES 30000, 60000", 2);
@Language("SQL") String query = "SELECT * FROM orders a JOIN " + tableName + " b ON a.orderkey = b.orderkey";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Locale;

import static com.google.common.base.Throwables.getStackTraceAsString;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -74,7 +74,7 @@ private void setUpTableFromTpch(String tableName)
@Test
public void testEmptyTable()
{
String tableName = "test_stats_table_empty_" + randomTableSuffix();
String tableName = "test_stats_table_empty_" + randomNameSuffix();
computeActual(format("CREATE TABLE %s AS SELECT orderkey, custkey, orderpriority, comment FROM tpch.tiny.orders WHERE false", tableName));
try {
gatherStats(tableName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import java.util.stream.Stream;

import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static java.lang.String.format;
import static java.util.Locale.ENGLISH;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -63,7 +63,7 @@ public void testNonLowerCaseSchemaName()
throws Exception
{
// Ensure schema name starts with a letter and is prefixed with a random string to make sure LIKE 'schema%' returns a single result
String fixedRandom = "a" + randomTableSuffix();
String fixedRandom = "a" + randomNameSuffix();
String bigQuerySchema = fixedRandom + "_NonLowerCaseSchema";
String trinoSchema = bigQuerySchema.toLowerCase(ENGLISH);
try (AutoCloseable ignore1 = withSchema(bigQuerySchema);
Expand All @@ -86,7 +86,7 @@ public void testNonLowerCaseSchemaName()
public void testNonLowerCaseTableName()
throws Exception
{
String bigQuerySchema = "SomeSchema_" + randomTableSuffix();
String bigQuerySchema = "SomeSchema_" + randomNameSuffix();
String trinoSchema = bigQuerySchema.toLowerCase(ENGLISH);
try (AutoCloseable ignore1 = withSchema(bigQuerySchema);
AutoCloseable ignore2 = withTable(
Expand Down Expand Up @@ -129,7 +129,7 @@ public void testNonLowerCaseTableName()
public void testNonLowerCaseViewName()
throws Exception
{
String bigQuerySchema = "SomeSchema_" + randomTableSuffix();
String bigQuerySchema = "SomeSchema_" + randomNameSuffix();
String trinoSchema = bigQuerySchema.toLowerCase(ENGLISH);
String namePrefix = format("%s.Test_Case", bigQuerySchema);

Expand Down Expand Up @@ -164,7 +164,7 @@ public void testSchemaNameClash()
throws Exception
{
// Ensure schema names start with a letter
String random = "a" + randomTableSuffix();
String random = "a" + randomNameSuffix();
String[] nameVariants = {random + "_casesensitivename", random + "_CaseSensitiveName", random + "_CASESENSITIVENAME"};
assertThat(Stream.of(nameVariants)
.map(name -> name.toLowerCase(ENGLISH))
Expand Down Expand Up @@ -201,7 +201,7 @@ public void testTableNameClash()
throws Exception
{
// Ensure schema name starts with a letter and is lowercase to only test table name code path
String schema = ("a" + randomTableSuffix() + "_tpch").toLowerCase(ENGLISH);
String schema = ("a" + randomNameSuffix() + "_tpch").toLowerCase(ENGLISH);
String[] nameVariants = {"casesensitivename", "CaseSensitiveName", "CASESENSITIVENAME"};
assertThat(Stream.of(nameVariants)
.map(name -> name.toLowerCase(ENGLISH))
Expand Down Expand Up @@ -231,7 +231,7 @@ public void testTableNameClash()
@Test
public void testCreateSchema()
{
String schemaName = "Test_Create_Case_Sensitive_" + randomTableSuffix();
String schemaName = "Test_Create_Case_Sensitive_" + randomNameSuffix();
assertUpdate("CREATE SCHEMA " + schemaName.toLowerCase(ENGLISH));
assertQuery(format("SELECT schema_name FROM information_schema.schemata WHERE schema_name = '%s'", schemaName.toLowerCase(ENGLISH)), format("VALUES '%s'", schemaName.toLowerCase(ENGLISH)));
assertUpdate("DROP SCHEMA " + schemaName.toLowerCase(ENGLISH));
Expand All @@ -241,7 +241,7 @@ public void testCreateSchema()
public void testCreateSchemaNameClash()
throws Exception
{
String schemaName = "Test_Create_Case_Sensitive_Clash_" + randomTableSuffix();
String schemaName = "Test_Create_Case_Sensitive_Clash_" + randomNameSuffix();
try (AutoCloseable schema = withSchema(schemaName)) {
assertQueryFails("CREATE SCHEMA " + schemaName.toLowerCase(ENGLISH), ".*Schema 'bigquery\\.\\Q" + schemaName.toLowerCase(ENGLISH) + "\\E' already exists");
}
Expand All @@ -251,7 +251,7 @@ public void testCreateSchemaNameClash()
public void testDropSchema()
throws Exception
{
String schemaName = "Test_Drop_Case_Sensitive_" + randomTableSuffix();
String schemaName = "Test_Drop_Case_Sensitive_" + randomNameSuffix();
try (AutoCloseable schema = withSchema(schemaName)) {
assertUpdate("DROP SCHEMA " + schemaName.toLowerCase(ENGLISH));
}
Expand All @@ -261,7 +261,7 @@ public void testDropSchema()
public void testDropSchemaNameClash()
throws Exception
{
String schemaName = "Test_Drop_Case_Sensitive_Clash_" + randomTableSuffix();
String schemaName = "Test_Drop_Case_Sensitive_Clash_" + randomNameSuffix();
try (AutoCloseable schema = withSchema(schemaName);
AutoCloseable secondSchema = withSchema(schemaName.toLowerCase(ENGLISH))) {
assertQueryFails("DROP SCHEMA " + schemaName.toLowerCase(ENGLISH), "Found ambiguous names in BigQuery.*");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import static io.trino.plugin.bigquery.BigQueryQueryRunner.BigQuerySqlExecutor;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.testing.MaterializedResult.resultBuilder;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static io.trino.testing.assertions.Assert.assertEquals;
import static io.trino.testing.assertions.Assert.assertEventually;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -174,7 +174,7 @@ public Object[][] createTableSupportedTypes()
@Test(dataProvider = "createTableUnsupportedTypes")
public void testCreateTableUnsupportedType(String createType)
{
String tableName = format("test_create_table_unsupported_type_%s_%s", createType.replaceAll("[^a-zA-Z0-9]", ""), randomTableSuffix());
String tableName = format("test_create_table_unsupported_type_%s_%s", createType.replaceAll("[^a-zA-Z0-9]", ""), randomNameSuffix());
assertQueryFails(format("CREATE TABLE %s (col1 %s)", tableName, createType), "Unsupported column type: " + createType);
assertUpdate("DROP TABLE IF EXISTS " + tableName);
}
Expand All @@ -192,7 +192,7 @@ public Object[][] createTableUnsupportedTypes()
@Test
public void testCreateTableWithRowTypeWithoutField()
{
String tableName = "test_row_type_table_" + randomTableSuffix();
String tableName = "test_row_type_table_" + randomNameSuffix();
assertQueryFails(
"CREATE TABLE " + tableName + "(col1 row(int))",
"\\QROW type does not have field names declared: row(integer)\\E");
Expand Down Expand Up @@ -429,7 +429,7 @@ public void testColumnPositionMismatch()
@Test
public void testSelectTableWithRowAccessPolicyFilterAll()
{
String policyName = "test_policy" + randomTableSuffix();
String policyName = "test_policy" + randomNameSuffix();
try (TestTable table = new TestTable(this::onBigQuery, "test.test_row_access_policy", "AS SELECT 1 col")) {
assertQuery("SELECT * FROM " + table.getName(), "VALUES 1");

Expand All @@ -445,7 +445,7 @@ public void testSelectTableWithRowAccessPolicyFilterAll()
@Test
public void testSelectTableWithRowAccessPolicyFilterPartialRow()
{
String policyName = "test_policy" + randomTableSuffix();
String policyName = "test_policy" + randomNameSuffix();
try (TestTable table = new TestTable(this::onBigQuery, "test.test_row_access_policy", "AS (SELECT 1 col UNION ALL SELECT 2 col)")) {
assertQuery("SELECT * FROM " + table.getName(), "VALUES (1), (2)");

Expand All @@ -462,8 +462,8 @@ public void testSelectTableWithRowAccessPolicyFilterPartialRow()
public void testViewDefinitionSystemTable()
{
String schemaName = "test";
String tableName = "views_system_table_base_" + randomTableSuffix();
String viewName = "views_system_table_view_" + randomTableSuffix();
String tableName = "views_system_table_base_" + randomNameSuffix();
String viewName = "views_system_table_view_" + randomNameSuffix();

onBigQuery(format("CREATE TABLE %s.%s (a INT64, b INT64, c INT64)", schemaName, tableName));
onBigQuery(format("CREATE VIEW %s.%s AS SELECT * FROM %s.%s", schemaName, viewName, schemaName, tableName));
Expand Down Expand Up @@ -534,7 +534,7 @@ public void testDateYearOfEraPredicate()
@Test
public void testBigQueryMaterializedView()
{
String materializedView = "test_materialized_view" + randomTableSuffix();
String materializedView = "test_materialized_view" + randomNameSuffix();
try {
onBigQuery("CREATE MATERIALIZED VIEW test." + materializedView + " AS SELECT count(1) AS cnt FROM tpch.region");
assertQuery("SELECT table_type FROM information_schema.tables WHERE table_schema = 'test' AND table_name = '" + materializedView + "'", "VALUES 'BASE TABLE'");
Expand All @@ -553,7 +553,7 @@ public void testBigQueryMaterializedView()
@Test
public void testBigQuerySnapshotTable()
{
String snapshotTable = "test_snapshot" + randomTableSuffix();
String snapshotTable = "test_snapshot" + randomNameSuffix();
try {
onBigQuery("CREATE SNAPSHOT TABLE test." + snapshotTable + " CLONE tpch.region");
assertQuery("SELECT table_type FROM information_schema.tables WHERE table_schema = 'test' AND table_name = '" + snapshotTable + "'", "VALUES 'BASE TABLE'");
Expand All @@ -574,7 +574,7 @@ public void testBigQuerySnapshotTable()
public void testBigQueryExternalTable(String gcpStorageBucket)
{
// Prerequisite: upload region.csv in resources directory to gs://{testing.gcp-storage-bucket}/tpch/tiny/region.csv
String externalTable = "test_external" + randomTableSuffix();
String externalTable = "test_external" + randomNameSuffix();
try {
onBigQuery("CREATE EXTERNAL TABLE test." + externalTable + " OPTIONS (format = 'CSV', uris = ['gs://" + gcpStorageBucket + "/tpch/tiny/region.csv'])");
assertQuery("SELECT table_type FROM information_schema.tables WHERE table_schema = 'test' AND table_name = '" + externalTable + "'", "VALUES 'BASE TABLE'");
Expand All @@ -601,7 +601,7 @@ public void testQueryCache()
.setCatalogSessionProperty("bigquery", "create_disposition_type", "create_never")
.build();

String materializedView = "test_materialized_view" + randomTableSuffix();
String materializedView = "test_materialized_view" + randomNameSuffix();
try {
onBigQuery("CREATE MATERIALIZED VIEW test." + materializedView + " AS SELECT count(1) AS cnt FROM tpch.region");

Expand All @@ -622,7 +622,7 @@ public void testQueryCache()
@Test
public void testWildcardTable()
{
String suffix = randomTableSuffix();
String suffix = randomNameSuffix();
String firstTable = format("test_wildcard_%s_1", suffix);
String secondTable = format("test_wildcard_%s_2", suffix);
String wildcardTable = format("test_wildcard_%s_*", suffix);
Expand All @@ -648,7 +648,7 @@ public void testWildcardTable()
@Test
public void testWildcardTableWithDifferentColumnDefinition()
{
String suffix = randomTableSuffix();
String suffix = randomNameSuffix();
String firstTable = format("test_invalid_wildcard_%s_1", suffix);
String secondTable = format("test_invalid_wildcard_%s_2", suffix);
String wildcardTable = format("test_invalid_wildcard_%s_*", suffix);
Expand Down Expand Up @@ -722,7 +722,7 @@ public void testNativeQuerySelectFromNation()
@Test
public void testNativeQuerySelectFromTestTable()
{
String tableName = "test.test_select" + randomTableSuffix();
String tableName = "test.test_select" + randomNameSuffix();
try {
onBigQuery("CREATE TABLE " + tableName + "(col BIGINT)");
onBigQuery("INSERT INTO " + tableName + " VALUES (1), (2)");
Expand All @@ -738,7 +738,7 @@ public void testNativeQuerySelectFromTestTable()
@Test
public void testNativeQuerySelectUnsupportedType()
{
String tableName = "test_unsupported" + randomTableSuffix();
String tableName = "test_unsupported" + randomNameSuffix();
try {
onBigQuery("CREATE TABLE test." + tableName + "(one BIGINT, two BIGNUMERIC(40,2), three STRING)");
// Check that column 'two' is not supported.
Expand All @@ -754,7 +754,7 @@ public void testNativeQuerySelectUnsupportedType()
@Test
public void testNativeQueryCreateStatement()
{
String tableName = "test_create" + randomTableSuffix();
String tableName = "test_create" + randomNameSuffix();
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
assertThatThrownBy(() -> query("SELECT * FROM TABLE(bigquery.system.query(query => 'CREATE TABLE test." + tableName + "(n INTEGER)'))"))
.hasMessage("Unsupported statement type: CREATE_TABLE");
Expand All @@ -764,7 +764,7 @@ public void testNativeQueryCreateStatement()
@Test
public void testNativeQueryInsertStatementTableDoesNotExist()
{
String tableName = "test_insert" + randomTableSuffix();
String tableName = "test_insert" + randomNameSuffix();
assertFalse(getQueryRunner().tableExists(getSession(), tableName));
assertThatThrownBy(() -> query("SELECT * FROM TABLE(bigquery.system.query(query => 'INSERT INTO test." + tableName + " VALUES (1)'))"))
.hasMessageContaining("Failed to get schema for query")
Expand All @@ -774,7 +774,7 @@ public void testNativeQueryInsertStatementTableDoesNotExist()
@Test
public void testNativeQueryInsertStatementTableExists()
{
String tableName = "test_insert" + randomTableSuffix();
String tableName = "test_insert" + randomNameSuffix();
try {
onBigQuery("CREATE TABLE test." + tableName + "(col BIGINT)");
assertThatThrownBy(() -> query("SELECT * FROM TABLE(bigquery.system.query(query => 'INSERT INTO test." + tableName + " VALUES (3)'))"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.testng.annotations.Test;

import static io.trino.plugin.bigquery.BigQueryQueryRunner.BigQuerySqlExecutor;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static org.testng.Assert.assertEquals;

public class TestBigQueryMetadataCaching
Expand All @@ -42,7 +42,7 @@ protected QueryRunner createQueryRunner()
@Test
public void testMetadataCaching()
{
String schema = "test_metadata_caching_" + randomTableSuffix();
String schema = "test_metadata_caching_" + randomNameSuffix();
try {
getQueryRunner().execute("CREATE SCHEMA " + schema);
assertEquals(getQueryRunner().execute("SHOW SCHEMAS IN bigquery LIKE '" + schema + "'").getOnlyValue(), schema);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import static io.trino.spi.type.TimestampWithTimeZoneType.TIMESTAMP_TZ_MICROS;
import static io.trino.spi.type.VarbinaryType.VARBINARY;
import static io.trino.spi.type.VarcharType.VARCHAR;
import static io.trino.testing.sql.TestTable.randomTableSuffix;
import static io.trino.testing.TestingNames.randomNameSuffix;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

Expand Down Expand Up @@ -277,7 +277,7 @@ public void testNumericMappingView()
@Test
public void testInvalidNumericScaleType()
{
String tableName = "test.invalid_numeric_scale_" + randomTableSuffix();
String tableName = "test.invalid_numeric_scale_" + randomNameSuffix();
try {
assertThatThrownBy(() -> getBigQuerySqlExecutor().execute(format("CREATE TABLE %s (invalid_type NUMERIC(38, 10))", tableName)))
.hasMessageContaining("In NUMERIC(P, S), S must be between 0 and 9");
Expand Down
Loading