diff --git a/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldName.java b/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldName.java index 2a7e26e..da98a76 100644 --- a/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldName.java +++ b/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldName.java @@ -8,8 +8,6 @@ package io.clusterless.tessellate.parser.ast; -import java.util.Objects; - public class FieldName implements FieldRef { String name; @@ -17,25 +15,9 @@ public FieldName(CharSequence name) { this.name = name.toString(); } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - FieldName fieldName = (FieldName) o; - return Objects.equals(name, fieldName.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - @Override public String toString() { - final StringBuilder sb = new StringBuilder("FieldName{"); - sb.append("name='").append(name).append('\''); - sb.append('}'); - return sb.toString(); + return name; } @Override diff --git a/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldOrdinal.java b/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldOrdinal.java index 13e5ada..901c40f 100644 --- a/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldOrdinal.java +++ b/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldOrdinal.java @@ -27,9 +27,6 @@ public Comparable asComparable() { @Override public String toString() { - final StringBuilder sb = new StringBuilder("FieldOrdinal{"); - sb.append("ordinal=").append(ordinal); - sb.append('}'); - return sb.toString(); + return ordinal.toString(); } } diff --git a/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldTypeName.java b/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldTypeName.java index 67934ca..766fec1 100644 --- a/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldTypeName.java +++ b/tessellate-main/src/main/java/io/clusterless/tessellate/parser/ast/FieldTypeName.java @@ -8,8 +8,6 @@ package io.clusterless.tessellate.parser.ast; -import java.util.Objects; - public class FieldTypeName { String name; @@ -21,19 +19,6 @@ public String name() { return name; } - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - FieldTypeName fieldName = (FieldTypeName) o; - return Objects.equals(name, fieldName.name); - } - - @Override - public int hashCode() { - return Objects.hash(name); - } - @Override public String toString() { return name; diff --git a/tessellate-main/src/test/java/io/clusterless/tessellate/parser/StatementParserTest.java b/tessellate-main/src/test/java/io/clusterless/tessellate/parser/StatementParserTest.java index bc03838..dfc8da5 100644 --- a/tessellate-main/src/test/java/io/clusterless/tessellate/parser/StatementParserTest.java +++ b/tessellate-main/src/test/java/io/clusterless/tessellate/parser/StatementParserTest.java @@ -8,10 +8,13 @@ package io.clusterless.tessellate.parser; -import io.clusterless.tessellate.parser.ast.Intrinsic; -import io.clusterless.tessellate.parser.ast.Operation; +import io.clusterless.tessellate.parser.ast.*; import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -50,6 +53,10 @@ void parse() { @Test void transforms() { + Field field = new Field(new FieldName("time_ymd"), Optional.of(new FieldType(new FieldTypeName("DateTime"), Optional.of(new FieldTypeParam("yyyyMMdd", Optional.empty()))))); + List results = ((UnaryOperation) StatementParser.parse("time +> time_ymd|DateTime|yyyyMMdd")).results(); + assertThat(results).hasSize(1).map(Objects::toString).contains(field.toString()); + assertNotNull(StatementParser.parse("one")); assertNotNull(StatementParser.parse("one|string")); assertNotNull(StatementParser.parse("two->@two")); diff --git a/tessellate-main/src/test/java/io/clusterless/tessellate/pipeline/PipelineOptionsMergerTest.java b/tessellate-main/src/test/java/io/clusterless/tessellate/pipeline/PipelineOptionsMergerTest.java index e6fc2a8..8227a0f 100644 --- a/tessellate-main/src/test/java/io/clusterless/tessellate/pipeline/PipelineOptionsMergerTest.java +++ b/tessellate-main/src/test/java/io/clusterless/tessellate/pipeline/PipelineOptionsMergerTest.java @@ -14,6 +14,7 @@ import io.clusterless.tessellate.options.PipelineOptions; import io.clusterless.tessellate.options.PipelineOptionsMerge; import io.clusterless.tessellate.parser.ast.Assignment; +import io.clusterless.tessellate.parser.ast.UnaryOperation; import io.clusterless.tessellate.util.JSONUtil; import org.junit.jupiter.api.Test; @@ -42,6 +43,7 @@ void usingOptions(@GivenTextResource("/config/pipeline-mvel.json") String pipeli assertEquals(output, merged.sink().output()); assertEquals("1689820455", ((Assignment) merged.transform().statements().get(5)).literal()); + assertEquals("_seven", ((UnaryOperation) merged.transform().statements().get(6)).results().get(0).fieldRef().asComparable()); } @Test diff --git a/tessellate-main/src/test/resources/config/pipeline-mvel.json b/tessellate-main/src/test/resources/config/pipeline-mvel.json index a56c243..ff0687f 100644 --- a/tessellate-main/src/test/resources/config/pipeline-mvel.json +++ b/tessellate-main/src/test/resources/config/pipeline-mvel.json @@ -24,6 +24,7 @@ "three+>@three|DateTime|yyyyMMdd", "four->", "five=>_five", - "@{1689820455}=>six|DateTime|yyyyMMdd" + "@{1689820455}=>six|DateTime|yyyyMMdd", + "seven +> _seven|DateTime|yyyyMMdd" ] }