-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Iceberg query runner with MinIO and file metastore #16861
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,13 @@ | |
import com.google.common.io.Resources; | ||
import io.airlift.http.server.testing.TestingHttpServer; | ||
import io.airlift.log.Logger; | ||
import io.airlift.log.Logging; | ||
import io.trino.plugin.hive.containers.HiveHadoop; | ||
import io.trino.plugin.hive.containers.HiveMinioDataLake; | ||
import io.trino.plugin.iceberg.catalog.jdbc.TestingIcebergJdbcServer; | ||
import io.trino.plugin.tpch.TpchPlugin; | ||
import io.trino.testing.DistributedQueryRunner; | ||
import io.trino.testing.containers.Minio; | ||
import io.trino.tpch.TpchTable; | ||
import org.apache.iceberg.catalog.Catalog; | ||
import org.apache.iceberg.rest.DelegatingRestSessionCatalog; | ||
|
@@ -205,9 +207,9 @@ public static void main(String[] args) | |
} | ||
} | ||
|
||
public static final class IcebergMinIoHiveMetastoreQueryRunnerMain | ||
public static final class IcebergMinioHiveMetastoreQueryRunnerMain | ||
{ | ||
private IcebergMinIoHiveMetastoreQueryRunnerMain() {} | ||
private IcebergMinioHiveMetastoreQueryRunnerMain() {} | ||
|
||
public static void main(String[] args) | ||
throws Exception | ||
|
@@ -237,7 +239,46 @@ public static void main(String[] args) | |
.build(); | ||
|
||
Thread.sleep(10); | ||
Logger log = Logger.get(IcebergMinIoHiveMetastoreQueryRunnerMain.class); | ||
Logger log = Logger.get(IcebergMinioHiveMetastoreQueryRunnerMain.class); | ||
log.info("======== SERVER STARTED ========"); | ||
log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl()); | ||
} | ||
} | ||
|
||
public static final class IcebergMinioQueryRunnerMain | ||
{ | ||
private IcebergMinioQueryRunnerMain() {} | ||
|
||
public static void main(String[] args) | ||
throws Exception | ||
{ | ||
Logging.initialize(); | ||
|
||
String bucketName = "test-bucket"; | ||
Minio minio = Minio.builder().build(); | ||
minio.start(); | ||
minio.createBucket(bucketName); | ||
|
||
DistributedQueryRunner queryRunner = IcebergQueryRunner.builder() | ||
.setCoordinatorProperties(Map.of( | ||
"http-server.http.port", "8080")) | ||
.setIcebergProperties(Map.of( | ||
"iceberg.catalog.type", "TESTING_FILE_METASTORE", | ||
"hive.metastore.catalog.dir", "s3://%s/".formatted(bucketName), | ||
"hive.s3.aws-access-key", MINIO_ACCESS_KEY, | ||
"hive.s3.aws-secret-key", MINIO_SECRET_KEY, | ||
"hive.s3.endpoint", "http://" + minio.getMinioApiEndpoint(), | ||
"hive.s3.path-style-access", "true", | ||
"hive.s3.streaming.part-size", "5MB")) | ||
.setSchemaInitializer( | ||
SchemaInitializer.builder() | ||
.withSchemaName("tpch") | ||
.withClonedTpchTables(TpchTable.getTables()) | ||
.build()) | ||
.build(); | ||
|
||
Thread.sleep(10); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the sleep is redundant (at least ATQF won't sleep after creating a query runner, so it works without a sleep in tests). will remove it in #16714, where i was adding similar runner |
||
Logger log = Logger.get(IcebergMinioQueryRunnerMain.class); | ||
log.info("======== SERVER STARTED ========"); | ||
log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl()); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that
hive.metastore.catalog.dir
is set to be in the very same bucket as the data for the iceberg tables?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's actually required for managed tables:
trino/plugin/trino-hive/src/main/java/io/trino/plugin/hive/metastore/file/FileHiveMetastore.java
Lines 351 to 355 in c7e8a6d
Since Iceberg tables are external, we could in theory put them elsewhere, but by default, they live in the catalog location. The file hive metastore is designed to store metadata as dot files alongside the table data. For Iceberg, they end up in different directories due to using unique names for Iceberg.
I'm open to revisiting this if you think there's a need, but since this is for testing, I doubt it's worthwhile.