Skip to content

Commit 1d0fe7b

Browse files
committed
Copy values in fix-list-values to support wildcard & index paths
See https://gitlab.com/oersi/oersi-etl/-/issues/238
1 parent 5927b7c commit 1d0fe7b

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

metafix/src/main/java/org/metafacture/metafix/MetafixListValues.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@
3636
public class MetafixListValues extends MetafixStreamAnalyzer {
3737

3838
public MetafixListValues(final String path) {
39-
super("retain(\"" + path + "\")", Compare.OBJECT, "${o}\t ${s}", "${o}");
39+
super(fix(path), Compare.OBJECT, "${o}\t ${s}", "${o}");
40+
}
41+
42+
private static String fix(final String path) {
43+
return
44+
"copy_field(\"" + path + "\",\"value.$append\")\n" +
45+
"retain(\"value\")";
4046
}
4147

4248
}

metafix/src/test/java/org/metafacture/metafix/MetafixListValuesTest.java

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,48 @@ public MetafixListValuesTest() {
4343
}
4444

4545
@Test
46-
public void testShouldListPathsA() {
46+
public void testShouldListPathsSimple() {
4747
lister = new MetafixListValues("a");
4848
verify("2\t aA");
4949
}
5050

5151
@Test
52-
public void testShouldListPathsB() {
52+
public void testShouldListPathsWildcard() {
53+
lister = new MetafixListValues("a.*");
54+
verify("2\t aA");
55+
}
56+
57+
@Test
58+
public void testShouldListPathsIndex() {
59+
lister = new MetafixListValues("a.1");
60+
verify("1\t aA");
61+
}
62+
63+
@Test
64+
public void testShouldListPathsTwoValues() {
5365
lister = new MetafixListValues("b");
66+
verify(
67+
"2\t bB",
68+
"1\t bA");
69+
}
70+
71+
@Test
72+
public void testShouldListPathsTwoValuesWildcard() {
73+
lister = new MetafixListValues("b.*");
5474
verify(
5575
"2\t bB",
5676
"1\t bA");
5777
}
5878

5979
@Test
60-
public void testShouldListPathsC() {
80+
public void testShouldListPathsTwoValuesIndex() {
81+
lister = new MetafixListValues("b.1");
82+
verify(
83+
"1\t bB");
84+
}
85+
86+
@Test
87+
public void testShouldListPathsSortCount() {
6188
lister = new MetafixListValues("c");
6289
verify(
6390
"3\t cC",

0 commit comments

Comments
 (0)