-
Notifications
You must be signed in to change notification settings - Fork 751
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
[GOBBLIN-2167] Allow filtering of Hive datasets by underlying HDFS folder location #4069
Merged
Will-Lo
merged 7 commits into
apache:master
from
Will-Lo:add-underlying-fs-allowlist-hive-dataset-finder
Oct 22, 2024
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9897f4f
WIP
Will-Lo f556f27
Add regex filter for table based on location
Will-Lo e1ed1a6
Cleanup
Will-Lo d4e60be
Add logs
Will-Lo e736bab
add more details to log
Will-Lo da1902d
Fix typo
Will-Lo 1906286
Address reviews
Will-Lo 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -215,6 +215,51 @@ public void testDatasetConfig() throws Exception { | |
|
||
} | ||
|
||
@Test | ||
public void testHiveTableFolderAllowlistFilter() throws Exception { | ||
List<HiveDatasetFinder.DbAndTable> dbAndTables = Lists.newArrayList(); | ||
dbAndTables.add(new HiveDatasetFinder.DbAndTable("db1", "table1")); | ||
// This table is created on /tmp/test | ||
HiveMetastoreClientPool pool = getTestPool(dbAndTables); | ||
|
||
Properties properties = new Properties(); | ||
properties.put(HiveDatasetFinder.HIVE_DATASET_PREFIX + "." + WhitelistBlacklist.WHITELIST, ""); | ||
// Try a regex with multiple groups | ||
properties.put(HiveDatasetFinder.TABLE_FOLDER_ALLOWLIST_FILTER, "(/tmp/|a).*"); | ||
|
||
HiveDatasetFinder finder = new TestHiveDatasetFinder(FileSystem.getLocal(new Configuration()), properties, pool); | ||
List<HiveDataset> datasets = Lists.newArrayList(finder.getDatasetsIterator()); | ||
|
||
Assert.assertEquals(datasets.size(), 1); | ||
|
||
properties.put(HiveDatasetFinder.HIVE_DATASET_PREFIX + "." + WhitelistBlacklist.WHITELIST, ""); | ||
// The table located at /tmp/test should be filtered | ||
properties.put(HiveDatasetFinder.TABLE_FOLDER_ALLOWLIST_FILTER, "/a/b"); | ||
|
||
finder = new TestHiveDatasetFinder(FileSystem.getLocal(new Configuration()), properties, pool); | ||
datasets = Lists.newArrayList(finder.getDatasetsIterator()); | ||
|
||
Assert.assertEquals(datasets.size(), 0); | ||
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. can also add a test for the case where the regex is empty or null |
||
|
||
// Test empty filter | ||
properties.put(HiveDatasetFinder.HIVE_DATASET_PREFIX + "." + WhitelistBlacklist.WHITELIST, ""); | ||
// The table located at /tmp/test should be filtered | ||
properties.put(HiveDatasetFinder.TABLE_FOLDER_ALLOWLIST_FILTER, ""); | ||
|
||
finder = new TestHiveDatasetFinder(FileSystem.getLocal(new Configuration()), properties, pool); | ||
datasets = Lists.newArrayList(finder.getDatasetsIterator()); | ||
|
||
Assert.assertEquals(datasets.size(), 0); | ||
|
||
// Test no regex config | ||
properties.put(HiveDatasetFinder.HIVE_DATASET_PREFIX + "." + WhitelistBlacklist.WHITELIST, ""); | ||
|
||
finder = new TestHiveDatasetFinder(FileSystem.getLocal(new Configuration()), properties, pool); | ||
datasets = Lists.newArrayList(finder.getDatasetsIterator()); | ||
|
||
Assert.assertEquals(datasets.size(), 0); | ||
} | ||
|
||
private HiveMetastoreClientPool getTestPool(List<HiveDatasetFinder.DbAndTable> dbAndTables) throws Exception { | ||
|
||
SetMultimap<String, String> entities = HashMultimap.create(); | ||
|
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.
it would be helpful to call out that the dataset table is created at path
/tmp/test
on line 221 since there is another assertion above using a different regex which doesn't filter the table