Store query and version in partitions created by tests
@@ -2689,18 +2689,7 @@ public abstract class AbstractTestHiveClient
List<PartitionWithStatistics> partitions = ImmutableList.of(firstPartitionName, secondPartitionName)
.stream()
- .map(partitionName -> new PartitionWithStatistics(
- Partition.builder()
- .setDatabaseName(tableName.getSchemaName())
- .setTableName(tableName.getTableName())
- .setColumns(table.getDataColumns())
- .setValues(toPartitionValues(partitionName))
- .withStorage(storage -> storage
- .setStorageFormat(fromHiveStorageFormat(HiveStorageFormat.ORC))
- .setLocation(partitionTargetPath(tableName, partitionName)))
- .build(),
- partitionName,
- PartitionStatistics.empty()))
+ .map(partitionName -> new PartitionWithStatistics(createDummyPartition(table, partitionName), partitionName, PartitionStatistics.empty()))
.collect(toImmutableList());
metastoreClient.addPartitions(tableName.getSchemaName(), tableName.getTableName(), partitions);
metastoreClient.updatePartitionStatistics(tableName.getSchemaName(), tableName.getTableName(), firstPartitionName, currentStatistics -> EMPTY_TABLE_STATISTICS);
@@ -2782,15 +2771,7 @@ public abstract class AbstractTestHiveClient
List<String> partitionValues = ImmutableList.of("2016-01-01");
String partitionName = makePartName(ImmutableList.of("ds"), partitionValues);
- Partition partition = Partition.builder()
- .setDatabaseName(tableName.getSchemaName())
- .setTableName(tableName.getTableName())
- .setColumns(table.getDataColumns())
- .setValues(partitionValues)
- .withStorage(storage -> storage
- .setStorageFormat(fromHiveStorageFormat(ORC))
- .setLocation(partitionTargetPath(tableName, partitionName)))
- .build();
+ Partition partition = createDummyPartition(table, partitionName);
// create partition with stats for all columns
metastoreClient.addPartitions(tableName.getSchemaName(), tableName.getTableName(), ImmutableList.of(new PartitionWithStatistics(partition, partitionName, statsForAllColumns1)));
@@ -2838,6 +2819,22 @@ public abstract class AbstractTestHiveClient
}
}
+ protected Partition createDummyPartition(Table table, String partitionName)
+ {
+ return Partition.builder()
+ .setDatabaseName(table.getDatabaseName())
+ .setTableName(table.getTableName())
+ .setColumns(table.getDataColumns())
+ .setValues(toPartitionValues(partitionName))
+ .withStorage(storage -> storage
+ .setStorageFormat(fromHiveStorageFormat(HiveStorageFormat.ORC))
+ .setLocation(partitionTargetPath(new SchemaTableName(table.getDatabaseName(), table.getTableName()), partitionName)))
+ .setParameters(ImmutableMap.of(
+ PRESTO_VERSION_NAME, "testversion",
+ PRESTO_QUERY_ID_NAME, "20180101_123456_00001_x1y2z"))
+ .build();
+ }
+
protected String partitionTargetPath(SchemaTableName schemaTableName, String partitionName)
{
try (Transaction transaction = newTransaction()) {
