Github user xccui commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5491#discussion_r168439885
  
    --- Diff: 
flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonSchemaConverter.java
 ---
    @@ -0,0 +1,358 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *     http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.flink.formats.json;
    +
    +import org.apache.flink.api.common.typeinfo.TypeInformation;
    +import org.apache.flink.api.common.typeinfo.Types;
    +import org.apache.flink.types.Row;
    +import org.apache.flink.util.Preconditions;
    +
    +import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonParser;
    +import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JsonNode;
    +import 
org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
    +
    +import java.io.IOException;
    +import java.util.ArrayList;
    +import java.util.Arrays;
    +import java.util.HashSet;
    +import java.util.Iterator;
    +import java.util.List;
    +import java.util.Map;
    +import java.util.Optional;
    +import java.util.Set;
    +
    +/**
    + * Converts a JSON schema into Flink's type information. It uses {@link 
Row} for representing
    + * objects and tuple arrays.
    + *
    + * <p>Note: This converter implements just a subset of the JSON schema 
specification.
    + * Union types (as well as "allOf", "anyOf", "not") are not supported yet. 
Simple
    + * references that link to a common definition in the document are 
supported. "oneOf" and
    + * arrays of type are only supported for specifying nullability;
    + */
    +@SuppressWarnings("OptionalIsPresent")
    +public final class JsonSchemaConverter {
    +
    +   private JsonSchemaConverter() {
    +           // private
    +   }
    +
    +   // see 
https://spacetelescope.github.io/understanding-json-schema/UnderstandingJSONSchema.pdf
    +   private static final String PROPERTIES = "properties";
    +   private static final String ADDITIONAL_PROPERTIES = 
"additionalProperties";
    +   private static final String TYPE = "type";
    +   private static final String FORMAT = "format";
    +   private static final String CONTENT_ENCODING = "contentEncoding";
    +   private static final String ITEMS = "items";
    +   private static final String ADDITIONAL_ITEMS = "additionalItems";
    +   private static final String REF = "$ref";
    +   private static final String ALL_OF = "allOf";
    +   private static final String ANY_OF = "anyOf";
    +   private static final String NOT = "not";
    +   private static final String ONE_OF = "oneOf";
    +
    +   // from https://tools.ietf.org/html/draft-zyp-json-schema-03#page-14
    +   private static final String DISALLOW = "disallow";
    +   private static final String EXTENDS = "extends";
    +
    +   private static final String TYPE_NULL = "null";
    +   private static final String TYPE_BOOLEAN = "boolean";
    +   private static final String TYPE_OBJECT = "object";
    +   private static final String TYPE_ARRAY = "array";
    +   private static final String TYPE_NUMBER = "number";
    +   private static final String TYPE_INTEGER = "integer";
    +   private static final String TYPE_STRING = "string";
    +
    +   private static final String FORMAT_DATE = "date";
    +   private static final String FORMAT_TIME = "time";
    +   private static final String FORMAT_DATE_TIME = "date-time";
    +
    +   private static final String CONTENT_ENCODING_BASE64 = "base64";
    +
    +   /**
    +    * Converts a JSON schema into Flink's type information. Throws an 
exception of the schema
    --- End diff --
    
    of -> if


---

Reply via email to