Skip to content
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

[#1760] Fix(core): Fix bug when introducing fileset api in CatalogOperationDispatcher #1762

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ public Table loadTable(NameIdentifier ident) throws NoSuchTableException {
.withHiddenPropertiesSet(
getHiddenPropertyNames(
catalogIdentifier,
HasPropertyMetadata::filesetPropertiesMetadata,
HasPropertyMetadata::tablePropertiesMetadata,
table.properties()));
}

Expand Down Expand Up @@ -667,7 +667,9 @@ public Fileset loadFileset(NameIdentifier ident) throws NoSuchFilesetException {
return EntityCombinedFileset.of(fileset)
.withHiddenPropertiesSet(
getHiddenPropertyNames(
catalogIdent, HasPropertyMetadata::tablePropertiesMetadata, fileset.properties()));
catalogIdent,
HasPropertyMetadata::filesetPropertiesMetadata,
fileset.properties()));
}

@Override
Expand Down Expand Up @@ -705,7 +707,7 @@ public Fileset createFileset(
.withHiddenPropertiesSet(
getHiddenPropertyNames(
catalogIdent,
HasPropertyMetadata::tablePropertiesMetadata,
HasPropertyMetadata::filesetPropertiesMetadata,
createdFileset.properties()));
}

Expand All @@ -725,7 +727,7 @@ public Fileset alterFileset(NameIdentifier ident, FilesetChange... changes)
.withHiddenPropertiesSet(
getHiddenPropertyNames(
catalogIdent,
HasPropertyMetadata::tablePropertiesMetadata,
HasPropertyMetadata::filesetPropertiesMetadata,
alteredFileset.properties()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public TestCatalogOperations(Map<String, String> config) {
filesets = Maps.newHashMap();
tablePropertiesMetadata = new TestBasePropertiesMetadata();
schemaPropertiesMetadata = new TestBasePropertiesMetadata();
filesetPropertiesMetadata = new TestBasePropertiesMetadata();
filesetPropertiesMetadata = new TestFilesetPropertiesMetadata();
this.config = config;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2024 Datastrato Pvt Ltd.
* This software is licensed under the Apache License version 2.
*/
package com.datastrato.gravitino;

import com.datastrato.gravitino.catalog.PropertyEntry;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import java.util.List;
import java.util.Map;

public class TestFilesetPropertiesMetadata extends TestBasePropertiesMetadata {

public static final String TEST_FILESET_HIDDEN_KEY = "fileset_key";

private static final Map<String, PropertyEntry<?>> TEST_FILESET_PROPERTY;

static {
List<PropertyEntry<?>> tablePropertyMetadata =
ImmutableList.of(
PropertyEntry.stringPropertyEntry(
TEST_FILESET_HIDDEN_KEY,
"test fileset required k1 property",
false,
false,
"test",
true,
false));

TEST_FILESET_PROPERTY = Maps.uniqueIndex(tablePropertyMetadata, PropertyEntry::getName);
}

@Override
protected Map<String, PropertyEntry<?>> specificPropertyEntries() {
return ImmutableMap.<String, PropertyEntry<?>>builder()
.putAll(super.specificPropertyEntries())
.putAll(TEST_FILESET_PROPERTY)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import static com.datastrato.gravitino.Entity.EntityType.TABLE;
import static com.datastrato.gravitino.StringIdentifier.ID_KEY;
import static com.datastrato.gravitino.TestBasePropertiesMetadata.COMMENT_KEY;
import static com.datastrato.gravitino.TestFilesetPropertiesMetadata.TEST_FILESET_HIDDEN_KEY;
import static com.datastrato.gravitino.catalog.BasePropertiesMetadata.GRAVITINO_MANAGED_ENTITY;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
Expand Down Expand Up @@ -678,6 +679,7 @@ private void testProperties(Map<String, String> expectedProps, Map<String, Strin
});
Assertions.assertFalse(testProps.containsKey(StringIdentifier.ID_KEY));
Assertions.assertFalse(testProps.containsKey(GRAVITINO_MANAGED_ENTITY));
Assertions.assertFalse(testProps.containsKey(TEST_FILESET_HIDDEN_KEY));
}

private void testPropertyException(Executable operation, String... errorMessage) {
Expand Down
Loading