Skip to content

Commit

Permalink
Fixing flakey tests for UnnestOperator.
Browse files Browse the repository at this point in the history
Signed-off-by: forestmvey <forestv@bitquilltech.com>
  • Loading branch information
forestmvey committed Mar 31, 2023
1 parent 4982979 commit 404ccc3
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
Expand Down Expand Up @@ -307,7 +306,7 @@ private void getNested(
&& (StringUtils.substringAfterLast(field, ".").equals(nestedField)
|| !field.contains("."))
) {
ret.add(new HashMap<>(Map.of(field, currentObj)));
ret.add(new LinkedHashMap<>(Map.of(field, currentObj)));
} else if (currentObj != null) {
getNested(field, nestedField.substring(nestedField.indexOf(".") + 1),
row, ret, currentObj, supportArrays);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,24 @@ public void nested_one_nested_field() {
assertThat(
execute(new UnnestOperator(inputPlan, fields, groupedFieldsByPath)),
contains(
tupleValue(new LinkedHashMap<>(Map.of("message.info", "a", "comment.data", "1"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "b", "comment.data", "1"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "c", "comment.data", "1")))
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "a");
put("comment.data", "1");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "b");
put("comment.data", "1");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "c");
put("comment.data", "1");
}}
)
)
);
}
Expand All @@ -124,19 +139,63 @@ public void nested_two_nested_field() {
"field", new ReferenceExpression("comment.data", STRING),
"path", new ReferenceExpression("comment", STRING))
);

assertThat(
execute(new UnnestOperator(inputPlan, fields)),
contains(
tupleValue(new LinkedHashMap<>(Map.of("message.info", "a", "comment.data", "1"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "a", "comment.data", "2"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "a", "comment.data", "3"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "b", "comment.data", "1"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "b", "comment.data", "2"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "b", "comment.data", "3"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "c", "comment.data", "1"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "c", "comment.data", "2"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "c", "comment.data", "3")))
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "a");
put("comment.data", "1");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "a");
put("comment.data", "2");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "a");
put("comment.data", "3");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "b");
put("comment.data", "1");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "b");
put("comment.data", "2");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "b");
put("comment.data", "3");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "c");
put("comment.data", "1");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "c");
put("comment.data", "2");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "c");
put("comment.data", "3");
}}
)
)
);
}
Expand All @@ -159,9 +218,24 @@ public void nested_two_nested_fields_with_same_path() {
assertThat(
execute(new UnnestOperator(inputPlan, fields)),
contains(
tupleValue(new LinkedHashMap<>(Map.of("message.info", "a", "message.id", "1"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "b", "message.id", "2"))),
tupleValue(new LinkedHashMap<>(Map.of("message.info", "c", "message.id", "3")))
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "a");
put("message.id", "1");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "b");
put("message.id", "2");
}}
),
tupleValue(
new LinkedHashMap<>() {{
put("message.info", "c");
put("message.id", "3");
}}
)
)
);
}
Expand Down

0 comments on commit 404ccc3

Please sign in to comment.