-
Notifications
You must be signed in to change notification settings - Fork 7
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 feature to ignore Iceberg tables #185
Merged
Merged
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
8a00255
Updated to BK-core
6baeee4
Updated to path-cleanup
7090dc4
Update PagingCleanupServiceTest.java
0f99aa6
cleanup
javsanbel2 9bbd52d
Merge branch 'feature/prevent-actions-on-iceberg-tables' of github.co…
javsanbel2 1e339c9
cleanup 2
javsanbel2 62c68d5
main business logic
javsanbel2 b6c718f
adding exception
javsanbel2 c5ad343
Add DB & table name to exception message
fd454a8
Update IcebergValidator.java
e41ac6c
Create IcebergValidatorTest.java
a2939d5
Update HiveMetadataCleanerTest.java
223e086
Updating and adding S3PathCleaner tests
1f6e360
Adding IcebergValidator to constructors
1905b0a
Updating Junit imports
efca2c9
Update SchedulerApiaryTest.java
d16bc0a
Update CommonBeans
9bf7248
clean-up add comment
4c45de2
Remove extra deletion
61c2f88
adding beans
javsanbel2 4e0b82b
fix tests
e548873
fixing it tests for metadata cleanup
javsanbel2 8b1ca85
fix path cleanup
javsanbel2 631502b
fix main problem with tests
javsanbel2 c1a7c96
Fix BeekeeperDryRunPathCleanupIntegrationTest
90c2871
revert changes to fix BeekeeperExpiredMetadataSchedulerApiaryIntegrat…
45fcc26
Added missing properties to fix BeekeeperUnreferencedPathSchedulerApi…
06914d1
Add integration test for metadatacleanup
a09e9f1
Update metadataHandler to catch beekeeperException
8c1ce38
cleanup
33a22c1
Update path-cleanup housekeeping status
a4b896a
cleanup
1be81b8
cleanup
66ad261
cleanup
0948aea
Update beekeeper to runtime exception
ed8745f
bump versions for testing
1047c57
Add Hadoop dependencies
eb13799
Update pom.xml
812565e
Revert changes to beekeeper-path
26b404c
revert more path-cleanup
101ab88
Revert path-cleanup
c646650
cleanup
e71a5ae
Added logging for table params
eea8403
add logging
95e6c64
remove logs to check filters
804be2f
cleaning up
javsanbel2 ae26519
fix validator tests
javsanbel2 c2e0b3f
clean up it tests
javsanbel2 07174b2
change expired metadata handler
javsanbel2 58c6e65
fix leninet
javsanbel2 a32e9d0
Add IcebergTableListenerEventFilter
9a93bd7
add event
javsanbel2 db1352a
Add integration test for scheduler
f300e60
Revert versions used for testing & changelog
bacd477
Revert testing version
04bb806
Update beekeeper-scheduler-apiary/src/main/java/com/expediagroup/beek…
HamzaJugon f94ba5d
Updating asserts and remove unused logging
1206eb8
Merge branch 'feature/prevent-actions-on-iceberg-tables' of https://g…
5517c7f
Implement IsIcebergTablePredicate
e66982e
revert changes to schedulerApiary
5e67a64
Update SchedulerApiary.java
a65f066
Updating logging so we only see stack trace on debug level
fd6bd88
Update logging in ExpiredMetadataHandler
026e769
Updating for minor comments
070b34d
Update logging
1418f1b
Update CHANGELOG.md
HamzaJugon b80e71d
Update CHANGELOG.md
HamzaJugon 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
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
63 changes: 63 additions & 0 deletions
63
...cleanup/src/main/java/com/expediagroup/beekeeper/cleanup/validation/IcebergValidator.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,63 @@ | ||
/** | ||
* Copyright (C) 2019-2024 Expedia, Inc. | ||
* | ||
* 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 com.expediagroup.beekeeper.cleanup.validation; | ||
|
||
import static java.lang.String.format; | ||
|
||
import java.util.Map; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import com.expediagroup.beekeeper.cleanup.metadata.CleanerClient; | ||
import com.expediagroup.beekeeper.cleanup.metadata.CleanerClientFactory; | ||
import com.expediagroup.beekeeper.core.error.BeekeeperIcebergException; | ||
import com.expediagroup.beekeeper.core.predicate.IsIcebergTablePredicate; | ||
|
||
public class IcebergValidator { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(IcebergValidator.class); | ||
|
||
private final CleanerClientFactory cleanerClientFactory; | ||
private final IsIcebergTablePredicate isIcebergTablePredicate; | ||
|
||
public IcebergValidator(CleanerClientFactory cleanerClientFactory) { | ||
this.cleanerClientFactory = cleanerClientFactory; | ||
this.isIcebergTablePredicate = new IsIcebergTablePredicate(); | ||
} | ||
|
||
/** | ||
* Beekeeper currently does not support the Iceberg format. Iceberg tables in the Hive Metastore do not store partition information, | ||
* causing Beekeeper to attempt to clean up the entire table due to the missing information. This method checks if | ||
* the table is an Iceberg table and throws a BeekeeperIcebergException to stop the process. | ||
* | ||
* @param databaseName | ||
* @param tableName | ||
*/ | ||
public void throwExceptionIfIceberg(String databaseName, String tableName) { | ||
try (CleanerClient client = cleanerClientFactory.newInstance()) { | ||
Map<String, String> tableParameters = client.getTableProperties(databaseName, tableName); | ||
|
||
if (isIcebergTablePredicate.test(tableParameters)) { | ||
throw new BeekeeperIcebergException( | ||
format("Iceberg table %s.%s is not currently supported in Beekeeper.", databaseName, tableName)); | ||
} | ||
} catch (Exception e) { | ||
throw new BeekeeperIcebergException( | ||
format("Unexpected exception when identifying if table %s.%s is Iceberg.", databaseName, tableName), e); | ||
} | ||
} | ||
} |
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
92 changes: 92 additions & 0 deletions
92
...nup/src/test/java/com/expediagroup/beekeeper/cleanup/validation/IcebergValidatorTest.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,92 @@ | ||
/** | ||
* Copyright (C) 2019-2024 Expedia, Inc. | ||
* | ||
* 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 com.expediagroup.beekeeper.cleanup.validation; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy; | ||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.expediagroup.beekeeper.cleanup.metadata.CleanerClient; | ||
import com.expediagroup.beekeeper.cleanup.metadata.CleanerClientFactory; | ||
import com.expediagroup.beekeeper.core.error.BeekeeperIcebergException; | ||
|
||
public class IcebergValidatorTest { | ||
|
||
private CleanerClientFactory cleanerClientFactory; | ||
private CleanerClient cleanerClient; | ||
private IcebergValidator icebergValidator; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
cleanerClientFactory = mock(CleanerClientFactory.class); | ||
cleanerClient = mock(CleanerClient.class); | ||
when(cleanerClientFactory.newInstance()).thenReturn(cleanerClient); | ||
icebergValidator = new IcebergValidator(cleanerClientFactory); | ||
} | ||
|
||
@Test(expected = BeekeeperIcebergException.class) | ||
public void shouldThrowExceptionWhenTableTypeIsIceberg() throws Exception { | ||
Map<String, String> properties = new HashMap<>(); | ||
properties.put("table_type", "ICEBERG"); | ||
|
||
when(cleanerClient.getTableProperties("db", "table")).thenReturn(properties); | ||
|
||
icebergValidator.throwExceptionIfIceberg("db", "table"); | ||
verify(cleanerClientFactory).newInstance(); | ||
verify(cleanerClient).close(); | ||
} | ||
|
||
@Test(expected = BeekeeperIcebergException.class) | ||
public void shouldThrowExceptionWhenMetadataIsIceberg() throws Exception { | ||
Map<String, String> properties = new HashMap<>(); | ||
properties.put("metadata_location", "s3://db/table/metadata/0000.json"); | ||
|
||
when(cleanerClient.getTableProperties("db", "table")).thenReturn(properties); | ||
|
||
icebergValidator.throwExceptionIfIceberg("db", "table"); | ||
} | ||
|
||
@Test | ||
public void shouldNotThrowExceptionForNonIcebergTable() throws Exception { | ||
Map<String, String> properties = new HashMap<>(); | ||
properties.put("table_type", "HIVE_TABLE"); | ||
|
||
when(cleanerClient.getTableProperties("db", "table")).thenReturn(properties); | ||
|
||
icebergValidator.throwExceptionIfIceberg("db", "table"); | ||
verify(cleanerClientFactory).newInstance(); | ||
verify(cleanerClient).close(); | ||
} | ||
|
||
@Test | ||
public void shouldThrowExceptionWhenOutputFormatIsNull() throws Exception { | ||
Map<String, String> properties = new HashMap<>(); | ||
properties.put("table_type", null); | ||
properties.put("metadata_location", null); | ||
|
||
when(cleanerClient.getTableProperties("db", "table")).thenReturn(properties); | ||
|
||
assertThatThrownBy(() -> icebergValidator.throwExceptionIfIceberg("db", "table")).isInstanceOf( | ||
BeekeeperIcebergException.class); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...r-core/src/main/java/com/expediagroup/beekeeper/core/error/BeekeeperIcebergException.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,33 @@ | ||
/** | ||
* Copyright (C) 2019-2024 Expedia, Inc. | ||
* | ||
* 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 com.expediagroup.beekeeper.core.error; | ||
|
||
public class BeekeeperIcebergException extends BeekeeperException { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
public BeekeeperIcebergException(String message, Exception e) { | ||
super(message, e); | ||
} | ||
|
||
public BeekeeperIcebergException(String message, Throwable e) { | ||
super(message, e); | ||
} | ||
|
||
public BeekeeperIcebergException(String message) { | ||
super(message); | ||
} | ||
} |
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.
nit: Maybe using
IllegalStateException
would have been clearer.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.
We are purposely using a custom exception to handle the exception in the main class later on.