Github user cestella commented on a diff in the pull request:
https://github.com/apache/metron/pull/742#discussion_r137913443
--- Diff:
metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/StringFunctions.java
---
@@ -321,6 +321,46 @@ public Object apply(List<Object> args) {
}
}
+ @Stellar( name="SUBSTRING"
+ , description = "Returns a substring of a string"
+ , params = {
+ "input - The string to take the substring of",
+ "start - The starting position (0-based and inclusive)",
+ "end? - The ending position (0-based and exclusive)"
+ }
+ , returns = "The substring of the input"
+ )
+ public static class Substring extends BaseStellarFunction {
+
+ @Override
+ public Object apply(List<Object> strings) {
+
+ if(strings == null || strings.size() < 2 ) {
+ throw new IllegalArgumentException("[SUBSTRING] required 2
arguments: the input and the start position (inclusive)");
+ }
+ String var = strings.get(0) == null?null: (String) strings.get(0);
+ Integer start = strings.get(1) == null?null:(Integer)strings.get(1);
--- End diff --
Agreed
---