-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Support time travel in Hudi connector #15084
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
Closed
Closed
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 hidden or 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 |
|---|---|---|
|
|
@@ -220,6 +220,46 @@ The output of the query has the following columns: | |
| - ``varchar`` | ||
| - Current state of the instant | ||
|
|
||
| Rolling back to a previous version | ||
| ----------------------------------- | ||
|
|
||
| Hudi allows us to store multiple versions of data in the table overtime while | ||
| providing ``snapshot isolation``. The number of versions are configurable and depends | ||
| on how much tradeoff one prefers for space used by those older versions. Hence, as | ||
| one can imagine, Hudi has the capabilities to allow to accessing the state of a table | ||
| at a certain point/instant in time. This could be done by allowing read mechanisms | ||
| from a Hudi table that go back and read the version of the data that was written a | ||
| particular point/instant in time. | ||
|
|
||
| For example, you could find the version IDs for the ``customer_orders`` table | ||
| by running the following query:: | ||
|
|
||
| SELECT timestamp | ||
| FROM example.testdb."customer_orders$timeline" | ||
| ORDER BY timestamp DESC | ||
|
|
||
| Time travel queries | ||
| ^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| The connector offers the ability to query historical data. | ||
| This allows you to query the table as it was when a previous snapshot | ||
| of the table was taken, even if the data has since been modified or deleted. | ||
|
|
||
| The historical data of the table can be retrieved by specifying the | ||
| snapshot identifier corresponding to the version of the table that | ||
| needs to be retrieved:: | ||
|
|
||
| SELECT * | ||
| FROM example.testdb.customer_orders FOR VERSION AS OF 8954597067493422955 | ||
|
|
||
| A different approach of retrieving historical data is to specify | ||
| a point in time in the past, such as a day or week ago. The latest snapshot | ||
| of the table taken before or at the specified timestamp in the query is | ||
| internally used for providing the previous state of the table:: | ||
|
|
||
| SELECT * | ||
| FROM example.testdb.customer_orders FOR TIMESTAMP AS OF TIMESTAMP '2022-03-23 09:59:29.803 Europe/Vienna' | ||
|
Member
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. Does this PR contain a test case for |
||
|
|
||
| File formats | ||
| ------------ | ||
|
|
||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |
| import static io.trino.tests.product.launcher.docker.ContainerUtil.forSelectedPorts; | ||
| import static io.trino.tests.product.launcher.env.EnvironmentContainers.HADOOP; | ||
| import static io.trino.tests.product.launcher.env.EnvironmentContainers.TESTS; | ||
| import static io.trino.tests.product.launcher.env.common.Hadoop.CONTAINER_HADOOP_INIT_D; | ||
| import static io.trino.tests.product.launcher.env.common.Minio.MINIO_CONTAINER_NAME; | ||
| import static io.trino.tests.product.launcher.env.common.Standard.CONTAINER_TRINO_ETC; | ||
| import static java.util.Objects.requireNonNull; | ||
|
|
@@ -81,12 +82,20 @@ public EnvSinglenodeHudi( | |
| @Override | ||
| public void extendEnvironment(Environment.Builder builder) | ||
| { | ||
| String dockerImageName = "ghcr.io/trinodb/testing/hdp3.1-hive:" + hadoopImagesVersion; | ||
| // Using hdp3.1 so we are using Hive metastore with version close to versions of hive-*.jars Spark uses | ||
| builder.configureContainer(HADOOP, container -> container.setDockerImageName("ghcr.io/trinodb/testing/hdp3.1-hive:" + hadoopImagesVersion)); | ||
| builder.configureContainer(HADOOP, container -> { | ||
| container.setDockerImageName(dockerImageName); | ||
| container.withCopyFileToContainer( | ||
| forHostPath(configDir.getPath("apply-hive-config-for-hudi.sh")), | ||
| CONTAINER_HADOOP_INIT_D + "/apply-hive-config-for-hudi.sh"); | ||
| }); | ||
|
|
||
| builder.addConnector( | ||
| "hive", | ||
| forHostPath(configDir.getPath("hive.properties")), | ||
| CONTAINER_TRINO_ETC + "/catalog/hive.properties"); | ||
|
|
||
|
Member
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. nit: Revert unrelated change. |
||
| builder.addConnector( | ||
| "hudi", | ||
| forHostPath(configDir.getPath("hudi.properties")), | ||
|
|
||
Oops, something went wrong.
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.
@mosabua Could you please review this docs?