-
Notifications
You must be signed in to change notification settings - Fork 76
Keep min OFD TTL for replica table as 3 days if provided TTL is less than 3 days #414
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
Merged
+135
−1
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 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
98 changes: 98 additions & 0 deletions
98
...park/src/test/java/com/linkedin/openhouse/jobs/spark/OrphanFilesDeletionSparkAppTest.java
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 |
|---|---|---|
| @@ -0,0 +1,98 @@ | ||
| package com.linkedin.openhouse.jobs.spark; | ||
|
|
||
| import com.linkedin.openhouse.common.metrics.DefaultOtelConfig; | ||
| import com.linkedin.openhouse.common.metrics.OtelEmitter; | ||
| import com.linkedin.openhouse.jobs.util.AppsOtelEmitter; | ||
| import com.linkedin.openhouse.tablestest.OpenHouseSparkITest; | ||
| import java.util.Arrays; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| public class OrphanFilesDeletionSparkAppTest extends OpenHouseSparkITest { | ||
| private final OtelEmitter otelEmitter = | ||
| new AppsOtelEmitter(Arrays.asList(DefaultOtelConfig.getOpenTelemetry())); | ||
|
|
||
| @Test | ||
| public void testTtlSecondsPrimaryTableOneDayTtl() throws Exception { | ||
| final String tableName = "db.test_ofd1"; | ||
|
|
||
| try (Operations ops = Operations.withCatalog(getSparkSession(), otelEmitter)) { | ||
| // create table | ||
| prepareTable(ops, tableName); | ||
| // create and test ofd spark job | ||
| OrphanFilesDeletionSparkApp app = | ||
| new OrphanFilesDeletionSparkApp( | ||
| "test-ofd-job1", null, tableName, 86400, otelEmitter, ".backup", 1, false, 100); | ||
| Assertions.assertEquals(86400, app.getTtlSeconds()); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testTtlSecondsPrimaryTableThreeDayTtl() throws Exception { | ||
| final String tableName = "db.test_ofd2"; | ||
|
|
||
| try (Operations ops = Operations.withCatalog(getSparkSession(), otelEmitter)) { | ||
| // create table | ||
| prepareTable(ops, tableName); | ||
| // create and test ofd spark job | ||
| OrphanFilesDeletionSparkApp app = | ||
| new OrphanFilesDeletionSparkApp( | ||
| "test-ofd-job2", null, tableName, 259200, otelEmitter, ".backup", 1, false, 100); | ||
| Assertions.assertEquals(259200, app.getTtlSeconds()); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testTtlSecondsReplicaTableOneDayTtl() throws Exception { | ||
| final String tableName = "db.test_ofd3"; | ||
|
|
||
| try (Operations ops = Operations.withCatalog(getSparkSession(), otelEmitter)) { | ||
| // create table | ||
| prepareReplicaTable(ops, tableName); | ||
| // create and test ofd spark job | ||
| OrphanFilesDeletionSparkApp app = | ||
| new OrphanFilesDeletionSparkApp( | ||
| "test-ofd-job3", null, tableName, 86400, otelEmitter, ".backup", 1, false, 100); | ||
| app.runInner(ops); | ||
| Assertions.assertEquals(259200, app.getTtlSeconds()); | ||
| } | ||
| } | ||
|
|
||
| @Test | ||
| public void testTtlSecondsReplicaTableThreeDayTtl() throws Exception { | ||
| final String tableName = "db.test_ofd4"; | ||
|
|
||
| try (Operations ops = Operations.withCatalog(getSparkSession(), otelEmitter)) { | ||
| // create table | ||
| prepareReplicaTable(ops, tableName); | ||
| // create and test ofd spark job | ||
| OrphanFilesDeletionSparkApp app = | ||
| new OrphanFilesDeletionSparkApp( | ||
| "test-ofd-job4", null, tableName, 259200, otelEmitter, ".backup", 1, false, 100); | ||
| app.runInner(ops); | ||
| Assertions.assertEquals(259200, app.getTtlSeconds()); | ||
| } | ||
| } | ||
|
|
||
| private static void prepareTable(Operations ops, String tableName) { | ||
| ops.spark().sql(String.format("DROP TABLE IF EXISTS %s", tableName)).show(); | ||
| ops.spark() | ||
| .sql( | ||
| String.format( | ||
| "CREATE TABLE %s (data string, ts timestamp) partitioned by (days(ts))", tableName)) | ||
| .show(); | ||
| ops.spark().sql(String.format("SHOW TBLPROPERTIES %s", tableName)).show(false); | ||
| } | ||
|
|
||
| private static void prepareReplicaTable(Operations ops, String tableName) { | ||
| ops.spark().sql(String.format("DROP TABLE IF EXISTS %s", tableName)).show(); | ||
| ops.spark() | ||
| .sql( | ||
| String.format( | ||
| "CREATE TABLE %s (data string, ts timestamp) partitioned by (days(ts)) " | ||
| + "TBLPROPERTIES ('openhouse.tableType' = 'REPLICA_TABLE')", | ||
| tableName)) | ||
| .show(); | ||
| ops.spark().sql(String.format("SHOW TBLPROPERTIES %s", tableName)).show(false); | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.