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 @@ -134,7 +134,7 @@ public Map<String, String> getPartitionProjectionHiveTableProperties(ConnectorTa
metastoreTablePropertiesBuilder,
PARTITION_PROJECTION_LOCATION_TEMPLATE,
METASTORE_PROPERTY_PROJECTION_LOCATION_TEMPLATE,
value -> value.toString().toLowerCase(Locale.ENGLISH));
Object::toString);

// Handle Column Properties
tableMetadata.getColumns().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,21 @@ public void testEnumPartitionProjectionOnVarcharColumnWithWhitespace()
@Test
public void testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplateCreatedOnTrino()
{
// It's important to mix case here to detect if we properly handle rewriting
// properties between Trino and Hive (e.g for Partition Projection)
String schemaName = "Hive_Datalake_MixedCase";
String tableName = getRandomTestTableName();

// We create new schema to include mixed case location path and create such keys in Object Store
computeActual("CREATE SCHEMA hive.%1$s WITH (location='s3a://%2$s/%1$s')".formatted(schemaName, bucketName));

String storageFormat = format(
"s3a://%s/%s/%s/short_name1=${short_name1}/short_name2=${short_name2}/",
this.bucketName,
HIVE_TEST_SCHEMA,
schemaName,
tableName);
computeActual(
"CREATE TABLE " + getFullyQualifiedTestTableName(tableName) + " ( " +
"CREATE TABLE " + getFullyQualifiedTestTableName(schemaName, tableName) + " ( " +
" name varchar(25), " +
" comment varchar(152), " +
" nationkey bigint, " +
Expand All @@ -410,14 +417,14 @@ public void testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplat
")");
assertThat(
hiveMinioDataLake.getHiveHadoop()
.runOnHive("SHOW TBLPROPERTIES " + getHiveTestTableName(tableName)))
.runOnHive("SHOW TBLPROPERTIES " + getHiveTestTableName(schemaName, tableName)))
.containsPattern("[ |]+projection\\.enabled[ |]+true[ |]+")
.containsPattern("[ |]+storage\\.location\\.template[ |]+" + quote(storageFormat) + "[ |]+")
.containsPattern("[ |]+projection\\.short_name1\\.type[ |]+enum[ |]+")
.containsPattern("[ |]+projection\\.short_name1\\.values[ |]+PL1,CZ1[ |]+")
.containsPattern("[ |]+projection\\.short_name2\\.type[ |]+enum[ |]+")
.containsPattern("[ |]+projection\\.short_name2\\.values[ |]+PL2,CZ2[ |]+");
testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplate(tableName);
testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplate(schemaName, tableName);
}

@Test
Expand Down Expand Up @@ -447,12 +454,12 @@ public void testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplat
" 'projection.short_name2.type'='enum', " +
" 'projection.short_name2.values'='PL2,CZ2' " +
")");
testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplate(tableName);
testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplate(HIVE_TEST_SCHEMA, tableName);
}

private void testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplate(String tableName)
private void testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTemplate(String schemaName, String tableName)
{
String fullyQualifiedTestTableName = getFullyQualifiedTestTableName(tableName);
String fullyQualifiedTestTableName = getFullyQualifiedTestTableName(schemaName, tableName);
computeActual(createInsertStatement(
fullyQualifiedTestTableName,
ImmutableList.of(
Expand All @@ -462,7 +469,7 @@ private void testEnumPartitionProjectionOnVarcharColumnWithStorageLocationTempla
ImmutableList.of("'CZECH_2'", "'Comment'", "3", "5", "'CZ1'", "'CZ2'"))));

assertQuery(
format("SELECT * FROM %s", getFullyQualifiedTestTableName("\"" + tableName + "$partitions\"")),
format("SELECT * FROM %s", getFullyQualifiedTestTableName(schemaName, "\"" + tableName + "$partitions\"")),
"VALUES ('PL1','PL2'), ('PL1','CZ2'), ('CZ1','PL2'), ('CZ1','CZ2')");

assertQuery(
Expand Down Expand Up @@ -1720,12 +1727,22 @@ protected String getFullyQualifiedTestTableName()

protected String getFullyQualifiedTestTableName(String tableName)
{
return format("hive.%s.%s", HIVE_TEST_SCHEMA, tableName);
return getFullyQualifiedTestTableName(HIVE_TEST_SCHEMA, tableName);
}

protected String getFullyQualifiedTestTableName(String schemaName, String tableName)
{
return "hive.%s.%s".formatted(schemaName, tableName);
}

protected String getHiveTestTableName(String tableName)
{
return format("%s.%s", HIVE_TEST_SCHEMA, tableName);
return getHiveTestTableName(HIVE_TEST_SCHEMA, tableName);
}

protected String getHiveTestTableName(String schemaName, String tableName)
{
return "%s.%s".formatted(schemaName, tableName);
}

protected String getCreateTableStatement(String tableName, String... propertiesEntries)
Expand Down