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

namespaces: allow '=' and ';' in names #1936

Merged
merged 1 commit into from
Apr 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/main/java/marquez/common/models/NamespaceName.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ public final class NamespaceName {
private static final int MIN_SIZE = 1;
private static final int MAX_SIZE = 1024;
private static final Pattern PATTERN =
Pattern.compile(String.format("^[a-zA-Z:/0-9_\\-\\.]{%d,%d}$", MIN_SIZE, MAX_SIZE));
Pattern.compile(String.format("^[a-zA-Z:;=/0-9_\\-\\.]{%d,%d}$", MIN_SIZE, MAX_SIZE));

@Getter private final String value;

public NamespaceName(@NonNull final String value) {
checkArgument(
PATTERN.matcher(value).matches(),
"namespace '%s' must contain only letters (a-z, A-Z), numbers (0-9), "
+ "underscores (_), dashes (-), colons (:), slashes (/) or dots (.) with a maximum "
+ "length of %s characters.",
+ "underscores (_), dashes (-), colons (:), equals (=), semicolons (;), slashes (/) "
+ "or dots (.) with a maximum length of %s characters.",
value,
MAX_SIZE);
this.value = value;
Expand Down
4 changes: 2 additions & 2 deletions api/src/test/java/marquez/OpenLineageIntegrationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public static List<String> data() {

@Test
public void testSendOpenLineageBadArgument() throws IOException {
// Namespaces can't have semi-colons, so this will get rejected
// Namespaces can't have emojis, so this will get rejected
String badNamespace =
"sqlserver://myhost:3342;user=auser;password=XXXXXXXXXX;database=TheDatabase";
"sqlserver://myhost:3342;user=auser;password=\uD83D\uDE02\uD83D\uDE02\uD83D\uDE02;database=TheDatabase";
LineageEvent event =
new LineageEvent(
"COMPLETE",
Expand Down
31 changes: 31 additions & 0 deletions api/src/test/java/marquez/common/models/NamespaceNameTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package marquez.common.models;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

@org.junit.jupiter.api.Tag("UnitTests")
public class NamespaceNameTest {

@ParameterizedTest
@ValueSource(
strings = {
"DEFAULT",
"database://localhost:1234",
"s3://bucket",
"bigquery:",
"sqlserver://synapse-test-test001.sql.azuresynapse.net;databaseName=TESTPOOL1;",
"\u003D"
})
void testValidNamespaceName(String name) {
assertThat(NamespaceName.of(name).getValue()).isEqualTo(name);
}

@ParameterizedTest
@ValueSource(strings = {"@@@", "\uD83D\uDE02", "!", ""})
void testInvalidNamespaceName(String name) {
Assertions.assertThrows(IllegalArgumentException.class, () -> NamespaceName.of(name));
}
}