diff --git a/core/src/main/java/feast/core/validators/Matchers.java b/core/src/main/java/feast/core/validators/Matchers.java index 8ba89a8308..5f7ddd26ac 100644 --- a/core/src/main/java/feast/core/validators/Matchers.java +++ b/core/src/main/java/feast/core/validators/Matchers.java @@ -25,7 +25,7 @@ public class Matchers { private static Pattern BIGQUERY_TABLE_REF_REGEX = Pattern.compile("[a-zA-Z0-9-]+[:]+[a-zA-Z0-9_]+[.]+[a-zA-Z0-9_]*"); private static Pattern CLASS_PATH_REGEX = - Pattern.compile("[a-zA-Z_$][a-zA-Z0-9_$]*(\\.[a-zA-Z_$][a-zA-Z0-9_$]*)"); + Pattern.compile("[a-zA-Z_][a-zA-Z0-9_]*(\\.[a-zA-Z_][a-zA-Z0-9_]*)*$"); private static Pattern UPPER_SNAKE_CASE_REGEX = Pattern.compile("^[A-Z0-9]+(_[A-Z0-9]+)*$"); private static Pattern LOWER_SNAKE_CASE_REGEX = Pattern.compile("^[a-z0-9]+(_[a-z0-9]+)*$"); private static Pattern VALID_CHARACTERS_REGEX = Pattern.compile("^[a-zA-Z_][a-zA-Z0-9_]*$"); diff --git a/core/src/test/java/feast/core/validators/MatchersTest.java b/core/src/test/java/feast/core/validators/MatchersTest.java index eb9d987cbd..fdf4d0469d 100644 --- a/core/src/test/java/feast/core/validators/MatchersTest.java +++ b/core/src/test/java/feast/core/validators/MatchersTest.java @@ -18,6 +18,7 @@ import static feast.core.validators.Matchers.checkLowerSnakeCase; import static feast.core.validators.Matchers.checkUpperSnakeCase; +import static feast.core.validators.Matchers.checkValidClassPath; import com.google.common.base.Strings; import org.junit.Rule; @@ -70,4 +71,22 @@ public void checkLowerSnakeCaseShouldThrowIllegalArgumentExceptionWithFieldForIn String in = "Invalid_feature name"; checkLowerSnakeCase(in, "feature"); } + + @Test + public void checkValidClassPathSuccess() { + checkValidClassPath("com.example.foo", "FeatureTable"); + checkValidClassPath("com.example", "FeatureTable"); + } + + @Test + public void checkValidClassPathEmpty() { + exception.expect(IllegalArgumentException.class); + checkValidClassPath("", "FeatureTable"); + } + + @Test + public void checkValidClassPathDigits() { + exception.expect(IllegalArgumentException.class); + checkValidClassPath("123", "FeatureTable"); + } }