-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Core: Add support for view-default
property in catalog
#11064
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ public class InMemoryCatalog extends BaseMetastoreViewCatalog | |
private final ConcurrentMap<TableIdentifier, String> views; | ||
private FileIO io; | ||
private String catalogName; | ||
private Map<String, String> catalogProperties; | ||
private String warehouseLocation; | ||
private CloseableGroup closeableGroup; | ||
|
||
|
@@ -85,6 +86,7 @@ public String name() { | |
@Override | ||
public void initialize(String name, Map<String, String> properties) { | ||
this.catalogName = name != null ? name : InMemoryCatalog.class.getSimpleName(); | ||
this.catalogProperties = ImmutableMap.copyOf(properties); | ||
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. Careful here, ImmutableMap.copyOf isn't null safe |
||
|
||
String warehouse = properties.getOrDefault(CatalogProperties.WAREHOUSE_LOCATION, ""); | ||
this.warehouseLocation = warehouse.replaceAll("/*$", ""); | ||
|
@@ -94,6 +96,11 @@ public void initialize(String name, Map<String, String> properties) { | |
closeableGroup.setSuppressCloseFailure(true); | ||
} | ||
|
||
@Override | ||
protected Map<String, String> properties() { | ||
return catalogProperties == null ? ImmutableMap.of() : catalogProperties; | ||
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. Depending on what you do above this may or may not be necessary 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 think this is still needed in case |
||
} | ||
|
||
@Override | ||
protected TableOperations newTableOps(TableIdentifier tableIdentifier) { | ||
return new InMemoryTableOperations(io, tableIdentifier); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -637,6 +637,30 @@ public void testCompleteCreateTable() { | |
.isEqualTo(UUID.fromString(((BaseTable) table).operations().current().uuid())); | ||
} | ||
|
||
@Test | ||
public void testDefaultTableProperties() { | ||
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 would just create a separate PR to fix this for tables, because the scope of this PR is really about adding support for view default properties |
||
C catalog = catalog(); | ||
|
||
TableIdentifier ident = TableIdentifier.of("ns", "table"); | ||
|
||
if (requiresNamespaceCreate()) { | ||
catalog.createNamespace(ident.namespace()); | ||
} | ||
|
||
assertThat(catalog.tableExists(ident)).as("Table should not exist").isFalse(); | ||
|
||
Table table = | ||
catalog() | ||
.buildTable(ident, SCHEMA) | ||
.withProperty("default-key2", "catalog-overridden-key2") | ||
.create(); | ||
assertThat(table.properties()) | ||
.containsEntry("default-key1", "catalog-default-key1") | ||
.containsEntry("default-key2", "catalog-overridden-key2"); | ||
|
||
assertThat(catalog.dropTable(ident)).as("Should successfully drop table").isTrue(); | ||
} | ||
|
||
@Test | ||
public void testLoadTable() { | ||
C catalog = catalog(); | ||
|
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.
Thanks @ebyhr for working on this. I also raised a similar PR which I think is not required anymore. Do you think we should also add
"view-override."
?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 probably makes sense since we have the table-default as well, but i have no problem this being in a followup