-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable reading Parquet's bloomfilter statistics for Iceberg connector
- Loading branch information
1 parent
c4f0e7e
commit b1d730e
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
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
71 changes: 71 additions & 0 deletions
71
...ino-iceberg/src/test/java/io/trino/plugin/iceberg/TestIcebergParquetWithBloomFilters.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,71 @@ | ||
/* | ||
* 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.iceberg; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import io.trino.plugin.hive.TestingHivePlugin; | ||
import io.trino.spi.connector.CatalogSchemaTableName; | ||
import io.trino.spi.connector.SchemaTableName; | ||
import io.trino.testing.BaseTestParquetWithBloomFilters; | ||
import io.trino.testing.DistributedQueryRunner; | ||
import io.trino.testing.QueryRunner; | ||
|
||
import java.nio.file.Path; | ||
import java.util.List; | ||
|
||
import static io.trino.plugin.hive.parquet.TestHiveParquetWithBloomFilters.writeParquetFileWithBloomFilter; | ||
import static io.trino.testing.TestingNames.randomNameSuffix; | ||
import static java.lang.String.format; | ||
|
||
public class TestIcebergParquetWithBloomFilters | ||
extends BaseTestParquetWithBloomFilters | ||
{ | ||
@Override | ||
protected QueryRunner createQueryRunner() | ||
throws Exception | ||
{ | ||
DistributedQueryRunner queryRunner = IcebergQueryRunner.builder().build(); | ||
dataDirectory = queryRunner.getCoordinator().getBaseDataDir().resolve("iceberg_data"); | ||
|
||
// create hive catalog | ||
queryRunner.installPlugin(new TestingHivePlugin()); | ||
queryRunner.createCatalog("hive", "hive", ImmutableMap.<String, String>builder() | ||
.put("hive.metastore", "file") | ||
.put("hive.metastore.catalog.dir", dataDirectory.toString()) | ||
.put("hive.security", "allow-all") | ||
.buildOrThrow()); | ||
|
||
return queryRunner; | ||
} | ||
|
||
@Override | ||
protected CatalogSchemaTableName createParquetTableWithBloomFilter(String columnName, List<Integer> testValues) | ||
{ | ||
// create the managed table | ||
String tableName = "parquet_with_bloom_filters_" + randomNameSuffix(); | ||
CatalogSchemaTableName hiveCatalogSchemaTableName = new CatalogSchemaTableName("hive", new SchemaTableName("tpch", tableName)); | ||
CatalogSchemaTableName icebergCatalogSchemaTableName = new CatalogSchemaTableName("iceberg", new SchemaTableName("tpch", tableName)); | ||
assertUpdate(format("CREATE TABLE %s (%s INT) WITH (format = 'PARQUET')", hiveCatalogSchemaTableName, columnName)); | ||
|
||
// directly write data to the managed table | ||
Path tableLocation = Path.of("%s/tpch/%s".formatted(dataDirectory, tableName)); | ||
Path fileLocation = tableLocation.resolve("bloomFilterFile.parquet"); | ||
writeParquetFileWithBloomFilter(fileLocation.toFile(), columnName, testValues); | ||
|
||
// migrate the hive table to the iceberg table | ||
assertUpdate("CALL iceberg.system.migrate('tpch', '" + tableName + "', 'false')"); | ||
|
||
return icebergCatalogSchemaTableName; | ||
} | ||
} |