Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed sink bug when using struct type for record value #503

Merged
merged 3 commits into from
Mar 24, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed tests
  • Loading branch information
kushagraThapar committed Mar 24, 2023
commit 4c7a3be4a6418097bd7ef4d8363eae133c763e21
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ public void structWithEmptyArrayToMap() {
.field("array_of_boolean", SchemaBuilder.array(Schema.BOOLEAN_SCHEMA).build());

Struct struct = new Struct(schema)
.put("array_of_boolean", Map.of());
.put("array_of_boolean", List.of());

Map<String, Object> converted = StructToJsonMap.toJsonMap(struct);
assertEquals(List.of(), converted.get("array_of_boolean"));
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
import org.junit.runners.Parameterized;
import org.mockito.Mock;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@@ -158,15 +159,15 @@ public void jsonPathNotExistThrows() {

@Test
public void complexJsonPath() {
returnOnKeyOrValue(null,
Map.of("id", List.of(
Map.of("id", 0,
"name", "cosmos kramer",
"occupation", "unknown"),
Map.of("id", 1,
"name", "franz kafka",
"occupation", "writer")
)));
Map<String, Object> map1 = new LinkedHashMap<>();
map1.put("id", 0);
map1.put("name", "cosmos kramer");
map1.put("occupation", "unknown");
Map<String, Object> map2 = new LinkedHashMap<>();
map2.put("id", 1);
map2.put("name", "franz kafka");
map2.put("occupation", "writer");
returnOnKeyOrValue(null, Map.of("id", List.of(map1, map2)));

strategy.configure(Map.of(ProvidedInConfig.JSON_PATH_CONFIG, "$.id[0].name"));
assertEquals("cosmos kramer", strategy.generateId(record));