twalthr commented on a change in pull request #6958: [FLINK-10687] [table] Make
flink-formats Scala-free
URL: https://github.com/apache/flink/pull/6958#discussion_r228907389
##########
File path:
flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowFormatFactory.java
##########
@@ -23,51 +23,39 @@
import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.table.descriptors.DescriptorProperties;
-import org.apache.flink.table.descriptors.FormatDescriptorValidator;
import org.apache.flink.table.descriptors.JsonValidator;
-import org.apache.flink.table.descriptors.SchemaValidator;
import org.apache.flink.table.factories.DeserializationSchemaFactory;
import org.apache.flink.table.factories.SerializationSchemaFactory;
+import org.apache.flink.table.factories.TableFormatFactoryBase;
import org.apache.flink.types.Row;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Table format factory for providing configured instances of JSON-to-row
{@link SerializationSchema}
* and {@link DeserializationSchema}.
*/
-public class JsonRowFormatFactory implements SerializationSchemaFactory<Row>,
DeserializationSchemaFactory<Row> {
+public class JsonRowFormatFactory extends TableFormatFactoryBase<Row>
+ implements SerializationSchemaFactory<Row>,
DeserializationSchemaFactory<Row> {
- @Override
- public Map<String, String> requiredContext() {
- final Map<String, String> context = new HashMap<>();
- context.put(FormatDescriptorValidator.FORMAT_TYPE(),
JsonValidator.FORMAT_TYPE_VALUE);
-
context.put(FormatDescriptorValidator.FORMAT_PROPERTY_VERSION(), "1");
- return context;
+ public JsonRowFormatFactory() {
+ super(JsonValidator.FORMAT_TYPE_VALUE, 1, true);
}
@Override
- public boolean supportsSchemaDerivation() {
- return true;
- }
-
- @Override
- public List<String> supportedProperties() {
+ protected List<String> supportedFormatProperties() {
Review comment:
I introduced a base class that contains the schema derivation logic and
reduces code duplication.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services