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

[#423] feat(core): Support the case-sensitive feature in gravitino catalog #1133

Closed
wants to merge 6 commits into from
Closed
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 @@ -220,4 +220,12 @@ public static void check(boolean condition, String message, Object... args) {
throw new IllegalNameIdentifierException(String.format(message, args));
}
}

public NameIdentifier parent() {
if (hasNamespace()) {
return NameIdentifier.of(namespace.levels());
}

throw new UnsupportedOperationException("Cannot get the parent of a metalake identifier");
}
}
16 changes: 16 additions & 0 deletions api/src/test/java/com/datastrato/gravitino/TestNameIdentifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import com.datastrato.gravitino.exceptions.IllegalNameIdentifierException;
import com.datastrato.gravitino.exceptions.IllegalNamespaceException;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class TestNameIdentifier {
Expand Down Expand Up @@ -126,4 +127,19 @@ public void testCheckNameIdentifier() {
() -> NameIdentifier.checkTable(NameIdentifier.of("a", "b", "c")));
assertTrue(excep3.getMessage().contains("Table namespace must be non-null and have 3 levels"));
}

@Test
void testParent() {
NameIdentifier identifier = NameIdentifier.of("a", "b", "c");
assertEquals(NameIdentifier.of("a", "b"), identifier.parent());

NameIdentifier identifier1 = NameIdentifier.of("a", "b");
assertEquals(NameIdentifier.of("a"), identifier1.parent());

NameIdentifier identifier2 = NameIdentifier.of("a");
Assertions.assertThrows(UnsupportedOperationException.class, identifier2::parent);

NameIdentifier identifier3 = NameIdentifier.of("a", "b", "c", "d");
assertEquals(NameIdentifier.of("a", "b", "c"), identifier3.parent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -932,4 +932,16 @@ public PropertiesMetadata catalogPropertiesMetadata() throws UnsupportedOperatio
public PropertiesMetadata schemaPropertiesMetadata() throws UnsupportedOperationException {
return schemaPropertiesMetadata;
}

@Override
public boolean nameCaseSensitivity() {
// If we want this to be more exact, we can create a database with a name to test this
// configuration when initiation.
return false;
}

@Override
public boolean toUpperCaseIfNotSensitive() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ public <R> R doWithPropertiesMeta(ThrowableFunction<HasPropertyMetadata, R> fn)
return classLoader.withClassLoader(cl -> fn.apply(catalog.ops()));
}

public <R> R doWithDefaultConfig(ThrowableFunction<HasCatalogDefaultConfig, R> fn)
throws Exception {
return classLoader.withClassLoader(cl -> fn.apply(catalog.ops()));
}

public void close() {
try {
classLoader.withClassLoader(
Expand Down
Loading
Loading