Skip to content

[FLINK-37752][json] Make configuration 'json.decode.json-parser.enabled' take effect #26522

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

Merged
merged 1 commit into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public Set<ConfigOption<?>> optionalOptions() {
options.add(MAP_NULL_KEY_LITERAL);
options.add(ENCODE_DECIMAL_AS_PLAIN_NUMBER);
options.add(ENCODE_IGNORE_NULL_FIELDS);
options.add(DECODE_JSON_PARSER_ENABLED);
return options;
}

Expand All @@ -202,6 +203,7 @@ public Set<ConfigOption<?>> forwardOptions() {
options.add(MAP_NULL_KEY_LITERAL);
options.add(ENCODE_DECIMAL_AS_PLAIN_NUMBER);
options.add(ENCODE_IGNORE_NULL_FIELDS);
options.add(DECODE_JSON_PARSER_ENABLED);
return options;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ void testLowerCaseOptionForMapNullKeyMode() {
testSchemaDeserializationSchema(tableOptions);
}

@Test
void testDecodeJsonParseEnabled() {
testJsonParserConfiguration(true, JsonParserRowDataDeserializationSchema.class);

testJsonParserConfiguration(false, JsonRowDataDeserializationSchema.class);
}

// ------------------------------------------------------------------------
// Utilities
// ------------------------------------------------------------------------
Expand Down Expand Up @@ -229,6 +236,38 @@ private Map<String, String> getAllOptions() {
options.put("json.map-null-key.literal", "null");
options.put("json.encode.decimal-as-plain-number", "true");
options.put("json.encode.ignore-null-fields", "true");
options.put("json.decode.json-parser.enabled", "true");
return options;
}

private void testJsonParserConfiguration(boolean enabled, Class<?> expectedClass) {
Map<String, String> options =
getModifyOptions(
opt -> opt.put("json.decode.json-parser.enabled", String.valueOf(enabled)));

DeserializationSchema<RowData> actualDeser =
createTableSource(options)
.valueFormat
.createRuntimeDecoder(
ScanRuntimeProviderContext.INSTANCE,
SCHEMA.toPhysicalRowDataType());

DeserializationSchema<RowData> expectedDeser =
enabled
? new JsonParserRowDataDeserializationSchema(
PHYSICAL_TYPE,
InternalTypeInfo.of(PHYSICAL_TYPE),
false,
true,
TimestampFormat.ISO_8601)
: new JsonRowDataDeserializationSchema(
PHYSICAL_TYPE,
InternalTypeInfo.of(PHYSICAL_TYPE),
false,
true,
TimestampFormat.ISO_8601);

assertThat(actualDeser).isInstanceOf(expectedClass);
assertThat(actualDeser).isEqualTo(expectedDeser);
}
}