You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by di...@apache.org on 2024/09/25 02:55:01 UTC

(flink) branch master updated (42d918dec16 -> 483a94a15ae)

This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


    from 42d918dec16 [FLINK-36308][cep] Remove deprecated APIs from CEP module (#25381)
     new de40ebe5379 [FLINK-36311][format/avro] Remove deprecated APIs in Flink Avro format
     new 98a0a567edf [FLINK-36311][format/json] Remove deprecated APIs in Flink Json format
     new 483a94a15ae [FLINK-36311][format/csv] Remove deprecated APIs in Flink Csv format

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../avro/typeutils/AvroSchemaConverter.java        |   6 +-
 .../formats/avro/typeutils/AvroSerializer.java     |  18 -
 .../avro/AvroRowDeSerializationSchemaTest.java     | 374 -----------------
 .../flink/formats/csv/RowCsvInputFormat.java       | 188 ++++++++-
 .../formats/csv/CsvRowDataSerDeSchemaTest.java     |   4 +-
 .../csv/CsvRowDeSerializationSchemaTest.java       | 403 -------------------
 .../json/JsonNodeDeserializationSchema.java        |  37 --
 .../json/JsonNodeDeserializationSchemaTest.java    |  50 ---
 .../json/JsonRowDeserializationSchemaTest.java     | 443 ---------------------
 .../json/JsonRowSerializationSchemaTest.java       | 250 ------------
 flink-python/pom.xml                               |  24 +-
 .../formats/avro/AvroRowDeserializationSchema.java |  10 +-
 .../formats/avro/AvroRowSerializationSchema.java   |   7 +-
 .../formats/csv/CsvRowDeserializationSchema.java   |  10 +-
 .../formats/csv/CsvRowSerializationSchema.java     |   8 +-
 .../formats/json/JsonRowDeserializationSchema.java |  25 +-
 .../formats/json/JsonRowSerializationSchema.java   |  14 +-
 17 files changed, 221 insertions(+), 1650 deletions(-)
 delete mode 100644 flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDeSerializationSchemaTest.java
 delete mode 100644 flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDeSerializationSchemaTest.java
 delete mode 100644 flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonNodeDeserializationSchema.java
 delete mode 100644 flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonNodeDeserializationSchemaTest.java
 delete mode 100644 flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDeserializationSchemaTest.java
 delete mode 100644 flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowSerializationSchemaTest.java
 rename {flink-formats/flink-avro => flink-python}/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java (97%)
 rename {flink-formats/flink-avro => flink-python}/src/main/java/org/apache/flink/formats/avro/AvroRowSerializationSchema.java (98%)
 rename {flink-formats/flink-csv => flink-python}/src/main/java/org/apache/flink/formats/csv/CsvRowDeserializationSchema.java (97%)
 rename {flink-formats/flink-csv => flink-python}/src/main/java/org/apache/flink/formats/csv/CsvRowSerializationSchema.java (98%)
 rename {flink-formats/flink-json => flink-python}/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java (96%)
 rename {flink-formats/flink-json => flink-python}/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java (96%)


(flink) 03/03: [FLINK-36311][format/csv] Remove deprecated APIs in Flink Csv format

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 483a94a15aed6661a333255139280affb935d52c
Author: Dian Fu <di...@apache.org>
AuthorDate: Wed Sep 18 16:12:05 2024 +0800

    [FLINK-36311][format/csv] Remove deprecated APIs in Flink Csv format
---
 .../flink/formats/csv/RowCsvInputFormat.java       | 188 +++++++++-
 .../formats/csv/CsvRowDataSerDeSchemaTest.java     |   4 +-
 .../csv/CsvRowDeSerializationSchemaTest.java       | 403 ---------------------
 .../formats/avro/AvroRowDeserializationSchema.java |   1 -
 .../formats/csv/CsvRowDeserializationSchema.java   |  10 +-
 .../formats/csv/CsvRowSerializationSchema.java     |   8 +-
 6 files changed, 191 insertions(+), 423 deletions(-)

diff --git a/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowCsvInputFormat.java b/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowCsvInputFormat.java
index 53634c5cc83..51ff3a44b08 100644
--- a/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowCsvInputFormat.java
+++ b/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/RowCsvInputFormat.java
@@ -18,11 +18,14 @@
 
 package org.apache.flink.formats.csv;
 
+import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
+import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
 import org.apache.flink.api.common.typeinfo.TypeInformation;
+import org.apache.flink.api.common.typeinfo.Types;
+import org.apache.flink.api.java.typeutils.ObjectArrayTypeInfo;
 import org.apache.flink.api.java.typeutils.RowTypeInfo;
 import org.apache.flink.core.fs.FileInputSplit;
 import org.apache.flink.core.fs.Path;
-import org.apache.flink.formats.csv.CsvRowDeserializationSchema.RuntimeConverter;
 import org.apache.flink.types.Row;
 import org.apache.flink.util.jackson.JacksonMapperFactory;
 
@@ -32,11 +35,19 @@ import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.dataformat.csv.Csv
 
 import java.io.IOException;
 import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.time.LocalDateTime;
+import java.time.ZoneOffset;
 import java.util.Arrays;
 import java.util.NoSuchElementException;
 
-import static org.apache.flink.formats.csv.CsvRowDeserializationSchema.createFieldRuntimeConverters;
-import static org.apache.flink.formats.csv.CsvRowDeserializationSchema.validateArity;
+import static org.apache.flink.formats.common.TimeFormats.SQL_TIMESTAMP_FORMAT;
+import static org.apache.flink.formats.common.TimeFormats.SQL_TIMESTAMP_WITH_LOCAL_TIMEZONE_FORMAT;
 import static org.apache.flink.util.Preconditions.checkArgument;
 import static org.apache.flink.util.Preconditions.checkNotNull;
 
@@ -140,6 +151,177 @@ public class RowCsvInputFormat extends AbstractCsvInputFormat<Row> {
         return returnRecord;
     }
 
+    // --------------------------------------------------------------------------------------------
+
+    interface RuntimeConverter extends Serializable {
+        Object convert(JsonNode node);
+    }
+
+    private static RuntimeConverter createRowRuntimeConverter(
+            RowTypeInfo rowTypeInfo, boolean ignoreParseErrors, boolean isTopLevel) {
+        final TypeInformation<?>[] fieldTypes = rowTypeInfo.getFieldTypes();
+        final String[] fieldNames = rowTypeInfo.getFieldNames();
+
+        final RuntimeConverter[] fieldConverters =
+                createFieldRuntimeConverters(ignoreParseErrors, fieldTypes);
+
+        return assembleRowRuntimeConverter(
+                ignoreParseErrors, isTopLevel, fieldNames, fieldConverters);
+    }
+
+    static RuntimeConverter[] createFieldRuntimeConverters(
+            boolean ignoreParseErrors, TypeInformation<?>[] fieldTypes) {
+        final RuntimeConverter[] fieldConverters = new RuntimeConverter[fieldTypes.length];
+        for (int i = 0; i < fieldTypes.length; i++) {
+            fieldConverters[i] = createNullableRuntimeConverter(fieldTypes[i], ignoreParseErrors);
+        }
+        return fieldConverters;
+    }
+
+    private static RuntimeConverter assembleRowRuntimeConverter(
+            boolean ignoreParseErrors,
+            boolean isTopLevel,
+            String[] fieldNames,
+            RuntimeConverter[] fieldConverters) {
+        final int rowArity = fieldNames.length;
+
+        return (node) -> {
+            final int nodeSize = node.size();
+
+            if (nodeSize != 0) {
+                validateArity(rowArity, nodeSize, ignoreParseErrors);
+            } else {
+                return null;
+            }
+
+            final Row row = new Row(rowArity);
+            for (int i = 0; i < Math.min(rowArity, nodeSize); i++) {
+                // Jackson only supports mapping by name in the first level
+                if (isTopLevel) {
+                    row.setField(i, fieldConverters[i].convert(node.get(fieldNames[i])));
+                } else {
+                    row.setField(i, fieldConverters[i].convert(node.get(i)));
+                }
+            }
+            return row;
+        };
+    }
+
+    private static RuntimeConverter createNullableRuntimeConverter(
+            TypeInformation<?> info, boolean ignoreParseErrors) {
+        final RuntimeConverter valueConverter = createRuntimeConverter(info, ignoreParseErrors);
+        return (node) -> {
+            if (node.isNull()) {
+                return null;
+            }
+            try {
+                return valueConverter.convert(node);
+            } catch (Throwable t) {
+                if (!ignoreParseErrors) {
+                    throw t;
+                }
+                return null;
+            }
+        };
+    }
+
+    private static RuntimeConverter createRuntimeConverter(
+            TypeInformation<?> info, boolean ignoreParseErrors) {
+        if (info.equals(Types.VOID)) {
+            return (node) -> null;
+        } else if (info.equals(Types.STRING)) {
+            return JsonNode::asText;
+        } else if (info.equals(Types.BOOLEAN)) {
+            return (node) -> Boolean.valueOf(node.asText().trim());
+        } else if (info.equals(Types.BYTE)) {
+            return (node) -> Byte.valueOf(node.asText().trim());
+        } else if (info.equals(Types.SHORT)) {
+            return (node) -> Short.valueOf(node.asText().trim());
+        } else if (info.equals(Types.INT)) {
+            return (node) -> Integer.valueOf(node.asText().trim());
+        } else if (info.equals(Types.LONG)) {
+            return (node) -> Long.valueOf(node.asText().trim());
+        } else if (info.equals(Types.FLOAT)) {
+            return (node) -> Float.valueOf(node.asText().trim());
+        } else if (info.equals(Types.DOUBLE)) {
+            return (node) -> Double.valueOf(node.asText().trim());
+        } else if (info.equals(Types.BIG_DEC)) {
+            return (node) -> new BigDecimal(node.asText().trim());
+        } else if (info.equals(Types.BIG_INT)) {
+            return (node) -> new BigInteger(node.asText().trim());
+        } else if (info.equals(Types.SQL_DATE)) {
+            return (node) -> Date.valueOf(node.asText());
+        } else if (info.equals(Types.SQL_TIME)) {
+            return (node) -> Time.valueOf(node.asText());
+        } else if (info.equals(Types.SQL_TIMESTAMP)) {
+            return (node) -> Timestamp.valueOf(node.asText());
+        } else if (info.equals(Types.LOCAL_DATE)) {
+            return (node) -> Date.valueOf(node.asText()).toLocalDate();
+        } else if (info.equals(Types.LOCAL_TIME)) {
+            return (node) -> Time.valueOf(node.asText()).toLocalTime();
+        } else if (info.equals(Types.LOCAL_DATE_TIME)) {
+            return (node) -> LocalDateTime.parse(node.asText().trim(), SQL_TIMESTAMP_FORMAT);
+        } else if (info.equals(Types.INSTANT)) {
+            return (node) ->
+                    LocalDateTime.parse(node.asText(), SQL_TIMESTAMP_WITH_LOCAL_TIMEZONE_FORMAT)
+                            .toInstant(ZoneOffset.UTC);
+        } else if (info instanceof RowTypeInfo) {
+            final RowTypeInfo rowTypeInfo = (RowTypeInfo) info;
+            return createRowRuntimeConverter(rowTypeInfo, ignoreParseErrors, false);
+        } else if (info instanceof BasicArrayTypeInfo) {
+            return createObjectArrayRuntimeConverter(
+                    ((BasicArrayTypeInfo<?, ?>) info).getComponentInfo(), ignoreParseErrors);
+        } else if (info instanceof ObjectArrayTypeInfo) {
+            return createObjectArrayRuntimeConverter(
+                    ((ObjectArrayTypeInfo<?, ?>) info).getComponentInfo(), ignoreParseErrors);
+        } else if (info instanceof PrimitiveArrayTypeInfo
+                && ((PrimitiveArrayTypeInfo) info).getComponentType() == Types.BYTE) {
+            return createByteArrayRuntimeConverter(ignoreParseErrors);
+        } else {
+            throw new RuntimeException("Unsupported type information '" + info + "'.");
+        }
+    }
+
+    private static RuntimeConverter createObjectArrayRuntimeConverter(
+            TypeInformation<?> elementType, boolean ignoreParseErrors) {
+        final Class<?> elementClass = elementType.getTypeClass();
+        final RuntimeConverter elementConverter =
+                createNullableRuntimeConverter(elementType, ignoreParseErrors);
+
+        return (node) -> {
+            final int nodeSize = node.size();
+            final Object[] array = (Object[]) Array.newInstance(elementClass, nodeSize);
+            for (int i = 0; i < nodeSize; i++) {
+                array[i] = elementConverter.convert(node.get(i));
+            }
+            return array;
+        };
+    }
+
+    private static RuntimeConverter createByteArrayRuntimeConverter(boolean ignoreParseErrors) {
+        return (node) -> {
+            try {
+                return node.binaryValue();
+            } catch (IOException e) {
+                if (!ignoreParseErrors) {
+                    throw new RuntimeException("Unable to deserialize byte array.", e);
+                }
+                return null;
+            }
+        };
+    }
+
+    static void validateArity(int expected, int actual, boolean ignoreParseErrors) {
+        if (expected != actual && !ignoreParseErrors) {
+            throw new RuntimeException(
+                    "Row length mismatch. "
+                            + expected
+                            + " fields expected but was "
+                            + actual
+                            + ".");
+        }
+    }
+
     /** Create a builder. */
     public static Builder builder(TypeInformation<Row> typeInfo, Path... filePaths) {
         return new Builder(typeInfo, filePaths);
diff --git a/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java b/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
index 402168a3d8d..87f109721e4 100644
--- a/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
+++ b/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDataSerDeSchemaTest.java
@@ -474,7 +474,7 @@ class CsvRowDataSerDeSchemaTest {
         CsvRowDataSerializationSchema schema =
                 InstantiationUtil.deserializeObject(
                         InstantiationUtil.serializeObject(serSchemaBuilder.build()),
-                        CsvRowDeSerializationSchemaTest.class.getClassLoader());
+                        CsvRowDataSerDeSchemaTest.class.getClassLoader());
         open(schema);
         return schema.serialize(row);
     }
@@ -487,7 +487,7 @@ class CsvRowDataSerDeSchemaTest {
         CsvRowDataDeserializationSchema schema =
                 InstantiationUtil.deserializeObject(
                         InstantiationUtil.serializeObject(deserSchemaBuilder.build()),
-                        CsvRowDeSerializationSchemaTest.class.getClassLoader());
+                        CsvRowDataSerDeSchemaTest.class.getClassLoader());
         open(schema);
         return schema.deserialize(csv != null ? csv.getBytes() : null);
     }
diff --git a/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDeSerializationSchemaTest.java b/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDeSerializationSchemaTest.java
deleted file mode 100644
index b26732b371e..00000000000
--- a/flink-formats/flink-csv/src/test/java/org/apache/flink/formats/csv/CsvRowDeSerializationSchemaTest.java
+++ /dev/null
@@ -1,403 +0,0 @@
-/*
- * 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.csv;
-
-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.InstantiationUtil;
-
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.util.function.Consumer;
-
-import static org.apache.flink.connector.testutils.formats.SchemaTestUtils.open;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Tests for {@link CsvRowSerializationSchema} and {@link CsvRowDeserializationSchema}. */
-class CsvRowDeSerializationSchemaTest {
-
-    @Test
-    @SuppressWarnings("unchecked")
-    public void testSerializeDeserialize() throws Exception {
-
-        testNullableField(Types.LONG, "null", null);
-        testNullableField(Types.STRING, "null", null);
-        testNullableField(Types.VOID, "null", null);
-        testNullableField(Types.STRING, "\"This is a test.\"", "This is a test.");
-        testNullableField(Types.STRING, "\"This is a test\n\r.\"", "This is a test\n\r.");
-        testNullableField(Types.BOOLEAN, "true", true);
-        testNullableField(Types.BOOLEAN, "null", null);
-        testNullableField(Types.BYTE, "124", (byte) 124);
-        testNullableField(Types.SHORT, "10000", (short) 10000);
-        testNullableField(Types.INT, "1234567", 1234567);
-        testNullableField(Types.LONG, "12345678910", 12345678910L);
-        testNullableField(Types.FLOAT, "0.33333334", 0.33333334f);
-        testNullableField(Types.DOUBLE, "0.33333333332", 0.33333333332d);
-        testNullableField(
-                Types.BIG_DEC,
-                "\"1234.0000000000000000000000001\"",
-                new BigDecimal("1234.0000000000000000000000001"));
-        testNullableField(
-                Types.BIG_INT,
-                "\"123400000000000000000000000000\"",
-                new BigInteger("123400000000000000000000000000"));
-        testNullableField(Types.SQL_DATE, "2018-10-12", Date.valueOf("2018-10-12"));
-        testNullableField(Types.SQL_TIME, "12:12:12", Time.valueOf("12:12:12"));
-        testNullableField(
-                Types.SQL_TIMESTAMP,
-                "\"2018-10-12 12:12:12.0\"",
-                Timestamp.valueOf("2018-10-12 12:12:12"));
-        testNullableField(Types.LOCAL_DATE, "2018-10-12", Date.valueOf("2018-10-12").toLocalDate());
-        testNullableField(Types.LOCAL_TIME, "12:12:12", Time.valueOf("12:12:12").toLocalTime());
-        testNullableField(
-                Types.LOCAL_DATE_TIME,
-                "\"2018-10-12 12:12:12\"",
-                LocalDateTime.parse("2018-10-12T12:12:12"));
-        testNullableField(
-                Types.INSTANT,
-                "\"1970-01-01 00:00:01.123456789Z\"",
-                Instant.ofEpochMilli(1123).plusNanos(456789));
-        testNullableField(Types.INSTANT, "\"1970-01-01 00:00:12Z\"", Instant.ofEpochSecond(12));
-        testNullableField(
-                Types.ROW(Types.STRING, Types.INT, Types.BOOLEAN),
-                "Hello;42;false",
-                Row.of("Hello", 42, false));
-        testNullableField(Types.OBJECT_ARRAY(Types.STRING), "a;b;c", new String[] {"a", "b", "c"});
-        testNullableField(Types.OBJECT_ARRAY(Types.BYTE), "12;4;null", new Byte[] {12, 4, null});
-        testNullableField(
-                (TypeInformation<byte[]>) Types.PRIMITIVE_ARRAY(Types.BYTE),
-                "awML",
-                new byte[] {107, 3, 11});
-    }
-
-    @Test
-    void testSerializeDeserializeCustomizedProperties() throws Exception {
-
-        final Consumer<CsvRowSerializationSchema.Builder> serConfig =
-                (serSchemaBuilder) ->
-                        serSchemaBuilder
-                                .setEscapeCharacter('*')
-                                .setQuoteCharacter('\'')
-                                .setArrayElementDelimiter(":")
-                                .setFieldDelimiter(';');
-
-        final Consumer<CsvRowDeserializationSchema.Builder> deserConfig =
-                (deserSchemaBuilder) ->
-                        deserSchemaBuilder
-                                .setEscapeCharacter('*')
-                                .setQuoteCharacter('\'')
-                                .setArrayElementDelimiter(":")
-                                .setFieldDelimiter(';');
-
-        testField(Types.STRING, "123*'4**", "123'4*", deserConfig, ";");
-        testField(Types.STRING, "'123''4**'", "123'4*", serConfig, deserConfig, ";");
-        testField(Types.STRING, "'a;b*'c'", "a;b'c", deserConfig, ";");
-        testField(Types.STRING, "'a;b''c'", "a;b'c", serConfig, deserConfig, ";");
-        testField(Types.INT, "       12          ", 12, deserConfig, ";");
-        testField(Types.INT, "12", 12, serConfig, deserConfig, ";");
-        testField(
-                Types.LOCAL_DATE_TIME,
-                "    2018-10-12 12:12:12     ",
-                LocalDateTime.parse("2018-10-12T12:12:12"),
-                deserConfig,
-                ";");
-        testField(
-                Types.ROW(Types.STRING, Types.STRING),
-                "1:hello",
-                Row.of("1", "hello"),
-                deserConfig,
-                ";");
-        testField(
-                Types.ROW(Types.STRING, Types.STRING),
-                "'1:hello'",
-                Row.of("1", "hello"),
-                serConfig,
-                deserConfig,
-                ";");
-        testField(
-                Types.ROW(Types.STRING, Types.STRING),
-                "'1:hello world'",
-                Row.of("1", "hello world"),
-                serConfig,
-                deserConfig,
-                ";");
-        testField(
-                Types.STRING,
-                "null",
-                "null",
-                serConfig,
-                deserConfig,
-                ";"); // string because null literal has not been set
-    }
-
-    @Test
-    void testDeserializeParseError() {
-        assertThatThrownBy(() -> testDeserialization(false, false, "Test,null,Test"))
-                .isInstanceOf(IOException.class);
-    }
-
-    @Test
-    void testDeserializeUnsupportedNull() throws Exception {
-        // unsupported null for integer
-        assertThat(testDeserialization(true, false, "Test,null,Test"))
-                .isEqualTo(Row.of("Test", null, "Test"));
-    }
-
-    @Test
-    void testDeserializeIncompleteRow() throws Exception {
-        // last two columns are missing
-        assertThat(testDeserialization(true, false, "Test")).isEqualTo(Row.of("Test", null, null));
-    }
-
-    @Test
-    void testDeserializeMoreColumnsThanExpected() throws Exception {
-        // one additional string column
-        assertThat(testDeserialization(true, false, "Test,12,Test,Test")).isNull();
-    }
-
-    @Test
-    void testDeserializeIgnoreComment() throws Exception {
-        // # is part of the string
-        assertThat(testDeserialization(false, false, "#Test,12,Test"))
-                .isEqualTo(Row.of("#Test", 12, "Test"));
-    }
-
-    @Test
-    void testDeserializeAllowComment() throws Exception {
-        // entire row is ignored
-        assertThat(testDeserialization(true, true, "#Test,12,Test")).isNull();
-    }
-
-    @Test
-    void testSerializationProperties() throws Exception {
-        final TypeInformation<Row> rowInfo = Types.ROW(Types.STRING, Types.INT, Types.STRING);
-        final CsvRowSerializationSchema.Builder serSchemaBuilder =
-                new CsvRowSerializationSchema.Builder(rowInfo).setLineDelimiter("\r");
-
-        assertThat(serialize(serSchemaBuilder, Row.of("Test", 12, "Hello")))
-                .isEqualTo("Test,12,Hello\r".getBytes());
-
-        serSchemaBuilder.setQuoteCharacter('#');
-
-        assertThat(serialize(serSchemaBuilder, Row.of("Test", 12, "2019-12-26 12:12:12")))
-                .isEqualTo("Test,12,#2019-12-26 12:12:12#\r".getBytes());
-
-        serSchemaBuilder.disableQuoteCharacter();
-
-        assertThat(serialize(serSchemaBuilder, Row.of("Test", 12, "2019-12-26 12:12:12")))
-                .isEqualTo("Test,12,2019-12-26 12:12:12\r".getBytes());
-    }
-
-    @Test
-    void testEmptyLineDelimiter() throws Exception {
-        final TypeInformation<Row> rowInfo = Types.ROW(Types.STRING, Types.INT, Types.STRING);
-        final CsvRowSerializationSchema.Builder serSchemaBuilder =
-                new CsvRowSerializationSchema.Builder(rowInfo).setLineDelimiter("");
-
-        assertThat(serialize(serSchemaBuilder, Row.of("Test", 12, "Hello")))
-                .isEqualTo("Test,12,Hello".getBytes());
-    }
-
-    @Test
-    void testInvalidNesting() {
-        assertThatThrownBy(
-                        () ->
-                                testNullableField(
-                                        Types.ROW(Types.ROW(Types.STRING)),
-                                        "FAIL",
-                                        Row.of(Row.of("FAIL"))))
-                .isInstanceOf(IllegalArgumentException.class);
-    }
-
-    @Test
-    void testInvalidType() {
-        assertThatThrownBy(
-                        () ->
-                                testNullableField(
-                                        Types.GENERIC(java.util.Date.class),
-                                        "FAIL",
-                                        new java.util.Date()))
-                .isInstanceOf(IllegalArgumentException.class);
-    }
-
-    @Test
-    void testSerializeDeserializeNestedTypes() throws Exception {
-        final TypeInformation<Row> subDataType0 =
-                Types.ROW(
-                        Types.STRING,
-                        Types.INT,
-                        Types.STRING,
-                        Types.LOCAL_DATE_TIME,
-                        Types.INSTANT);
-        final TypeInformation<Row> subDataType1 =
-                Types.ROW(
-                        Types.STRING,
-                        Types.INT,
-                        Types.STRING,
-                        Types.LOCAL_DATE_TIME,
-                        Types.INSTANT);
-        final TypeInformation<Row> rowInfo = Types.ROW(subDataType0, subDataType1);
-
-        // serialization
-        CsvRowSerializationSchema.Builder serSchemaBuilder =
-                new CsvRowSerializationSchema.Builder(rowInfo);
-        // deserialization
-        CsvRowDeserializationSchema.Builder deserSchemaBuilder =
-                new CsvRowDeserializationSchema.Builder(rowInfo);
-
-        Row normalRow =
-                Row.of(
-                        Row.of(
-                                "hello",
-                                1,
-                                "This is 1st top column",
-                                LocalDateTime.parse("1970-01-01T01:02:03"),
-                                Instant.ofEpochMilli(1000)),
-                        Row.of(
-                                "world",
-                                2,
-                                "This is 2nd top column",
-                                LocalDateTime.parse("1970-01-01T01:02:04"),
-                                Instant.ofEpochMilli(2000)));
-        testSerDeConsistency(normalRow, serSchemaBuilder, deserSchemaBuilder);
-
-        Row nullRow =
-                Row.of(
-                        null,
-                        Row.of(
-                                "world",
-                                2,
-                                "This is 2nd top column after null",
-                                LocalDateTime.parse("1970-01-01T01:02:05"),
-                                Instant.ofEpochMilli(3000)));
-        testSerDeConsistency(nullRow, serSchemaBuilder, deserSchemaBuilder);
-    }
-
-    private <T> void testNullableField(TypeInformation<T> fieldInfo, String string, T value)
-            throws Exception {
-        testField(
-                fieldInfo,
-                string,
-                value,
-                (deserSchema) -> deserSchema.setNullLiteral("null"),
-                (serSchema) -> serSchema.setNullLiteral("null"),
-                ",");
-    }
-
-    private <T> void testField(
-            TypeInformation<T> fieldInfo,
-            String csvValue,
-            T value,
-            Consumer<CsvRowSerializationSchema.Builder> serializationConfig,
-            Consumer<CsvRowDeserializationSchema.Builder> deserializationConfig,
-            String fieldDelimiter)
-            throws Exception {
-        final TypeInformation<Row> rowInfo = Types.ROW(Types.STRING, fieldInfo, Types.STRING);
-        final String expectedCsv = "BEGIN" + fieldDelimiter + csvValue + fieldDelimiter + "END\n";
-        final Row expectedRow = Row.of("BEGIN", value, "END");
-
-        // serialization
-        final CsvRowSerializationSchema.Builder serSchemaBuilder =
-                new CsvRowSerializationSchema.Builder(rowInfo);
-        serializationConfig.accept(serSchemaBuilder);
-        final byte[] serializedRow = serialize(serSchemaBuilder, expectedRow);
-        assertThat(new String(serializedRow)).isEqualTo(expectedCsv);
-
-        // deserialization
-        final CsvRowDeserializationSchema.Builder deserSchemaBuilder =
-                new CsvRowDeserializationSchema.Builder(rowInfo);
-        deserializationConfig.accept(deserSchemaBuilder);
-        final Row deserializedRow = deserialize(deserSchemaBuilder, expectedCsv);
-        assertThat(deserializedRow).isEqualTo(expectedRow);
-    }
-
-    private <T> void testField(
-            TypeInformation<T> fieldInfo,
-            String csvValue,
-            T value,
-            Consumer<CsvRowDeserializationSchema.Builder> deserializationConfig,
-            String fieldDelimiter)
-            throws Exception {
-        final TypeInformation<Row> rowInfo = Types.ROW(Types.STRING, fieldInfo, Types.STRING);
-        final String csv = "BEGIN" + fieldDelimiter + csvValue + fieldDelimiter + "END\n";
-        final Row expectedRow = Row.of("BEGIN", value, "END");
-
-        // deserialization
-        final CsvRowDeserializationSchema.Builder deserSchemaBuilder =
-                new CsvRowDeserializationSchema.Builder(rowInfo);
-        deserializationConfig.accept(deserSchemaBuilder);
-        final Row deserializedRow = deserialize(deserSchemaBuilder, csv);
-        assertThat(deserializedRow).isEqualTo(expectedRow);
-    }
-
-    private Row testDeserialization(
-            boolean allowParsingErrors, boolean allowComments, String string) throws Exception {
-        final TypeInformation<Row> rowInfo = Types.ROW(Types.STRING, Types.INT, Types.STRING);
-        final CsvRowDeserializationSchema.Builder deserSchemaBuilder =
-                new CsvRowDeserializationSchema.Builder(rowInfo)
-                        .setIgnoreParseErrors(allowParsingErrors)
-                        .setAllowComments(allowComments);
-        return deserialize(deserSchemaBuilder, string);
-    }
-
-    private void testSerDeConsistency(
-            Row originalRow,
-            CsvRowSerializationSchema.Builder serSchemaBuilder,
-            CsvRowDeserializationSchema.Builder deserSchemaBuilder)
-            throws Exception {
-        Row deserializedRow =
-                deserialize(
-                        deserSchemaBuilder, new String(serialize(serSchemaBuilder, originalRow)));
-        assertThat(originalRow).isEqualTo(deserializedRow);
-    }
-
-    private static byte[] serialize(CsvRowSerializationSchema.Builder serSchemaBuilder, Row row)
-            throws Exception {
-        // we serialize and deserialize the schema to test runtime behavior
-        // when the schema is shipped to the cluster
-        final CsvRowSerializationSchema schema =
-                InstantiationUtil.deserializeObject(
-                        InstantiationUtil.serializeObject(serSchemaBuilder.build()),
-                        CsvRowDeSerializationSchemaTest.class.getClassLoader());
-        open(schema);
-        return schema.serialize(row);
-    }
-
-    private static Row deserialize(
-            CsvRowDeserializationSchema.Builder deserSchemaBuilder, String csv) throws Exception {
-        // we serialize and deserialize the schema to test runtime behavior
-        // when the schema is shipped to the cluster
-        final CsvRowDeserializationSchema schema =
-                InstantiationUtil.deserializeObject(
-                        InstantiationUtil.serializeObject(deserSchemaBuilder.build()),
-                        CsvRowDeSerializationSchemaTest.class.getClassLoader());
-        open(schema);
-        return schema.deserialize(csv.getBytes());
-    }
-}
diff --git a/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java b/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
index 852ee54f850..923783f6cef 100644
--- a/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
+++ b/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
@@ -20,7 +20,6 @@ package org.apache.flink.formats.avro;
 import org.apache.flink.annotation.Internal;
 import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.api.common.serialization.AbstractDeserializationSchema;
-import org.apache.flink.api.common.serialization.DeserializationSchema;
 import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
 import org.apache.flink.api.common.typeinfo.TypeInformation;
 import org.apache.flink.api.common.typeinfo.Types;
diff --git a/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowDeserializationSchema.java b/flink-python/src/main/java/org/apache/flink/formats/csv/CsvRowDeserializationSchema.java
similarity index 97%
rename from flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowDeserializationSchema.java
rename to flink-python/src/main/java/org/apache/flink/formats/csv/CsvRowDeserializationSchema.java
index b2a91a9fb34..1f1831303f4 100644
--- a/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowDeserializationSchema.java
+++ b/flink-python/src/main/java/org/apache/flink/formats/csv/CsvRowDeserializationSchema.java
@@ -18,7 +18,7 @@
 
 package org.apache.flink.formats.csv;
 
-import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.annotation.Internal;
 import org.apache.flink.api.common.serialization.DeserializationSchema;
 import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
 import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
@@ -57,13 +57,8 @@ import static org.apache.flink.formats.common.TimeFormats.SQL_TIMESTAMP_WITH_LOC
  * Row}.
  *
  * <p>Failure during deserialization are forwarded as wrapped {@link IOException}s.
- *
- * @deprecated The format was developed for the Table API users and will not be maintained for
- *     DataStream API users anymore. Either use Table API or switch to Data Stream, defining your
- *     own {@link DeserializationSchema}.
  */
-@PublicEvolving
-@Deprecated
+@Internal
 public final class CsvRowDeserializationSchema implements DeserializationSchema<Row> {
 
     private static final long serialVersionUID = 2135553495874539201L;
@@ -98,7 +93,6 @@ public final class CsvRowDeserializationSchema implements DeserializationSchema<
     }
 
     /** A builder for creating a {@link CsvRowDeserializationSchema}. */
-    @PublicEvolving
     public static class Builder {
 
         private final RowTypeInfo typeInfo;
diff --git a/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowSerializationSchema.java b/flink-python/src/main/java/org/apache/flink/formats/csv/CsvRowSerializationSchema.java
similarity index 98%
rename from flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowSerializationSchema.java
rename to flink-python/src/main/java/org/apache/flink/formats/csv/CsvRowSerializationSchema.java
index 53f4edf16e3..358d4ec56fa 100644
--- a/flink-formats/flink-csv/src/main/java/org/apache/flink/formats/csv/CsvRowSerializationSchema.java
+++ b/flink-python/src/main/java/org/apache/flink/formats/csv/CsvRowSerializationSchema.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.formats.csv;
 
+import org.apache.flink.annotation.Internal;
 import org.apache.flink.annotation.PublicEvolving;
 import org.apache.flink.api.common.serialization.SerializationSchema;
 import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
@@ -57,13 +58,8 @@ import static org.apache.flink.formats.common.TimeFormats.SQL_TIMESTAMP_WITH_LOC
  *
  * <p>Result <code>byte[]</code> messages can be deserialized using {@link
  * CsvRowDeserializationSchema}.
- *
- * @deprecated The format was developed for the Table API users and will not be maintained for
- *     DataStream API users anymore. Either use Table API or switch to Data Stream, defining your
- *     own {@link SerializationSchema}.
  */
-@PublicEvolving
-@Deprecated
+@Internal
 public final class CsvRowSerializationSchema implements SerializationSchema<Row> {
 
     private static final long serialVersionUID = 2098447220136965L;


(flink) 01/03: [FLINK-36311][format/avro] Remove deprecated APIs in Flink Avro format

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit de40ebe53797a4abe023a437e63d9ba5aa095d40
Author: Dian Fu <di...@apache.org>
AuthorDate: Wed Sep 18 14:16:20 2024 +0800

    [FLINK-36311][format/avro] Remove deprecated APIs in Flink Avro format
---
 .../avro/typeutils/AvroSchemaConverter.java        |   6 +-
 .../formats/avro/typeutils/AvroSerializer.java     |  18 -
 .../avro/AvroRowDeSerializationSchemaTest.java     | 374 ---------------------
 flink-python/pom.xml                               |  10 +
 .../formats/avro/AvroRowDeserializationSchema.java |   9 +-
 .../formats/avro/AvroRowSerializationSchema.java   |   7 +-
 6 files changed, 17 insertions(+), 407 deletions(-)

diff --git a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java
index 178056e145a..651bda15053 100644
--- a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java
+++ b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSchemaConverter.java
@@ -21,8 +21,8 @@ package org.apache.flink.formats.avro.typeutils;
 import org.apache.flink.api.common.typeinfo.TypeInformation;
 import org.apache.flink.api.common.typeinfo.Types;
 import org.apache.flink.api.java.typeutils.RowTypeInfo;
-import org.apache.flink.formats.avro.AvroRowDeserializationSchema;
-import org.apache.flink.formats.avro.AvroRowSerializationSchema;
+import org.apache.flink.formats.avro.AvroRowDataDeserializationSchema;
+import org.apache.flink.formats.avro.AvroRowDataSerializationSchema;
 import org.apache.flink.table.api.DataTypes;
 import org.apache.flink.table.types.AtomicDataType;
 import org.apache.flink.table.types.DataType;
@@ -56,7 +56,7 @@ import java.util.List;
  * SQL API.
  *
  * <p>Note: Changes in this class need to be kept in sync with the corresponding runtime classes
- * {@link AvroRowDeserializationSchema} and {@link AvroRowSerializationSchema}.
+ * {@link AvroRowDataDeserializationSchema} and {@link AvroRowDataSerializationSchema}.
  */
 public class AvroSchemaConverter {
 
diff --git a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSerializer.java b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSerializer.java
index 99e9de566c6..69e9073d9b1 100644
--- a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSerializer.java
+++ b/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/typeutils/AvroSerializer.java
@@ -137,13 +137,6 @@ public class AvroSerializer<T> extends TypeSerializer<T> {
         this.previousSchema = checkNotNull(previousSchema);
     }
 
-    /** @deprecated Use {@link AvroSerializer#AvroSerializer(Class)} instead. */
-    @Deprecated
-    @SuppressWarnings("unused")
-    public AvroSerializer(Class<T> type, Class<? extends T> typeToInstantiate) {
-        this(type);
-    }
-
     // ------------------------------------------------------------------------
 
     @Nonnull
@@ -367,17 +360,6 @@ public class AvroSerializer<T> extends TypeSerializer<T> {
     //  Serializer Snapshots
     // ------------------------------------------------------------------------
 
-    /**
-     * A config snapshot for the Avro Serializer that stores the Avro Schema to check compatibility.
-     * This class is now deprecated and only kept for backward comparability.
-     */
-    @Deprecated
-    public static final class AvroSchemaSerializerConfigSnapshot<T>
-            extends AvroSerializerSnapshot<T> {
-
-        public AvroSchemaSerializerConfigSnapshot() {}
-    }
-
     // -------- backwards compatibility with 1.5, 1.6 -----------
 
     private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
diff --git a/flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDeSerializationSchemaTest.java b/flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDeSerializationSchemaTest.java
deleted file mode 100644
index 1349ca2e03e..00000000000
--- a/flink-formats/flink-avro/src/test/java/org/apache/flink/formats/avro/AvroRowDeSerializationSchemaTest.java
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * 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.avro;
-
-import org.apache.flink.api.java.tuple.Tuple3;
-import org.apache.flink.api.java.tuple.Tuple4;
-import org.apache.flink.formats.avro.utils.AvroTestUtils;
-import org.apache.flink.types.Row;
-import org.apache.flink.util.InstantiationUtil;
-
-import org.apache.avro.Schema;
-import org.apache.avro.generic.GenericRecord;
-import org.apache.avro.specific.SpecificRecord;
-import org.junit.Test;
-import org.junit.jupiter.params.ParameterizedTest;
-import org.junit.jupiter.params.provider.ValueSource;
-
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Test for the Avro serialization and deserialization schema. */
-class AvroRowDeSerializationSchemaTest {
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testSpecificSerializeDeserializeFromSchema(boolean legacyTimestampMapping)
-            throws IOException {
-        final Tuple3<Class<? extends SpecificRecord>, SpecificRecord, Row> testData =
-                AvroTestUtils.getSpecificTestData();
-        final String schemaString = testData.f1.getSchema().toString();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(schemaString);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(schemaString);
-
-        if (legacyTimestampMapping) {
-            final byte[] bytes = serializationSchema.serialize(testData.f2);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f2);
-        } else {
-            final byte[] bytes = serializationSchema.serialize(testData.f2, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f2);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testGenericSerializeDeserialize(boolean legacyTimestampMapping) throws IOException {
-        final Tuple3<GenericRecord, Row, Schema> testData = AvroTestUtils.getGenericTestData();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(testData.f2.toString());
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(testData.f2.toString());
-
-        if (legacyTimestampMapping) {
-            final byte[] bytes = serializationSchema.serialize(testData.f1);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f1);
-        } else {
-            final byte[] bytes = serializationSchema.serialize(testData.f1, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f1);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testSpecificSerializeFromClassSeveralTimes(boolean legacyTimestampMapping)
-            throws IOException {
-        final Tuple3<Class<? extends SpecificRecord>, SpecificRecord, Row> testData =
-                AvroTestUtils.getSpecificTestData();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(testData.f0);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(testData.f0);
-
-        if (legacyTimestampMapping) {
-            serializationSchema.serialize(testData.f2);
-            serializationSchema.serialize(testData.f2);
-            final byte[] bytes = serializationSchema.serialize(testData.f2);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f2);
-        } else {
-            serializationSchema.serialize(testData.f2, false);
-            serializationSchema.serialize(testData.f2, false);
-            final byte[] bytes = serializationSchema.serialize(testData.f2, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f2);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testSpecificSerializeFromSchemaSeveralTimes(boolean legacyTimestampMapping)
-            throws IOException {
-        final Tuple3<Class<? extends SpecificRecord>, SpecificRecord, Row> testData =
-                AvroTestUtils.getSpecificTestData();
-        final String schemaString = testData.f1.getSchema().toString();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(schemaString);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(schemaString);
-
-        if (legacyTimestampMapping) {
-            serializationSchema.serialize(testData.f2);
-            serializationSchema.serialize(testData.f2);
-            final byte[] bytes = serializationSchema.serialize(testData.f2);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f2);
-        } else {
-            serializationSchema.serialize(testData.f2, false);
-            serializationSchema.serialize(testData.f2, false);
-            final byte[] bytes = serializationSchema.serialize(testData.f2, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f2);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testGenericSerializeSeveralTimes(boolean legacyTimestampMapping) throws IOException {
-        final Tuple3<GenericRecord, Row, Schema> testData = AvroTestUtils.getGenericTestData();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(testData.f2.toString());
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(testData.f2.toString());
-
-        if (legacyTimestampMapping) {
-            serializationSchema.serialize(testData.f1);
-            serializationSchema.serialize(testData.f1);
-            final byte[] bytes = serializationSchema.serialize(testData.f1);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f1);
-        } else {
-            serializationSchema.serialize(testData.f1, false);
-            serializationSchema.serialize(testData.f1, false);
-            final byte[] bytes = serializationSchema.serialize(testData.f1, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f1);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testSpecificDeserializeFromClassSeveralTimes(boolean legacyTimestampMapping)
-            throws IOException {
-        final Tuple3<Class<? extends SpecificRecord>, SpecificRecord, Row> testData =
-                AvroTestUtils.getSpecificTestData();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(testData.f0);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(testData.f0);
-
-        if (legacyTimestampMapping) {
-            final byte[] bytes = serializationSchema.serialize(testData.f2);
-            deserializationSchema.deserialize(bytes);
-            deserializationSchema.deserialize(bytes);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f2);
-        } else {
-            final byte[] bytes = serializationSchema.serialize(testData.f2, false);
-            deserializationSchema.deserialize(bytes, false);
-            deserializationSchema.deserialize(bytes, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f2);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testSpecificDeserializeFromSchemaSeveralTimes(boolean legacyTimestampMapping)
-            throws IOException {
-        final Tuple3<Class<? extends SpecificRecord>, SpecificRecord, Row> testData =
-                AvroTestUtils.getSpecificTestData();
-        final String schemaString = testData.f1.getSchema().toString();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(schemaString);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(schemaString);
-
-        if (legacyTimestampMapping) {
-            final byte[] bytes = serializationSchema.serialize(testData.f2);
-            deserializationSchema.deserialize(bytes);
-            deserializationSchema.deserialize(bytes);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f2);
-        } else {
-            final byte[] bytes = serializationSchema.serialize(testData.f2, false);
-            deserializationSchema.deserialize(bytes, false);
-            deserializationSchema.deserialize(bytes, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f2);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testGenericDeserializeSeveralTimes(boolean legacyTimestampMapping) throws IOException {
-        final Tuple3<GenericRecord, Row, Schema> testData = AvroTestUtils.getGenericTestData();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(testData.f2.toString());
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(testData.f2.toString());
-
-        if (legacyTimestampMapping) {
-            final byte[] bytes = serializationSchema.serialize(testData.f1);
-            deserializationSchema.deserialize(bytes);
-            deserializationSchema.deserialize(bytes);
-            final Row actual = deserializationSchema.deserialize(bytes);
-            assertThat(actual).isEqualTo(testData.f1);
-        } else {
-            final byte[] bytes = serializationSchema.serialize(testData.f1, false);
-            deserializationSchema.deserialize(bytes, false);
-            deserializationSchema.deserialize(bytes, false);
-            final Row actual = deserializationSchema.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(testData.f1);
-        }
-    }
-
-    @ParameterizedTest
-    @ValueSource(booleans = {true, false})
-    void testSerializability(boolean legacyTimestampMapping) throws Exception {
-        final Tuple3<Class<? extends SpecificRecord>, SpecificRecord, Row> testData =
-                AvroTestUtils.getSpecificTestData();
-        final String schemaString = testData.f1.getSchema().toString();
-
-        // from class
-        final AvroRowSerializationSchema classSer = new AvroRowSerializationSchema(testData.f0);
-        final AvroRowDeserializationSchema classDeser =
-                new AvroRowDeserializationSchema(testData.f0);
-        testSerializability(classSer, classDeser, testData.f2, legacyTimestampMapping);
-
-        // from schema string
-        final AvroRowSerializationSchema schemaSer = new AvroRowSerializationSchema(schemaString);
-        final AvroRowDeserializationSchema schemaDeser =
-                new AvroRowDeserializationSchema(schemaString);
-        testSerializability(schemaSer, schemaDeser, testData.f2, legacyTimestampMapping);
-    }
-
-    void testTimestampSerializeDeserializeLegacyMapping() throws Exception {
-        final Tuple4<Class<? extends SpecificRecord>, SpecificRecord, GenericRecord, Row> testData =
-                AvroTestUtils.getTimestampTestData();
-
-        final String schemaString = testData.f1.getSchema().toString();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(schemaString);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(schemaString);
-
-        assertThatThrownBy(
-                        () -> {
-                            serializationSchema.serialize(testData.f3);
-                        })
-                .isInstanceOf(RuntimeException.class)
-                .hasMessage("Unsupported local timestamp type.");
-
-        final byte[] bytes = serializationSchema.serialize(testData.f3, false);
-
-        assertThatThrownBy(
-                        () -> {
-                            deserializationSchema.deserialize(bytes);
-                        })
-                .isInstanceOf(RuntimeException.class)
-                .hasMessage("Unsupported local timestamp type.");
-    }
-
-    @Test
-    void testTimestampSpecificSerializeDeserializeNewMapping() throws Exception {
-        final Tuple4<Class<? extends SpecificRecord>, SpecificRecord, GenericRecord, Row> testData =
-                AvroTestUtils.getTimestampTestData();
-
-        final String schemaString = testData.f1.getSchema().toString();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(schemaString);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(schemaString);
-
-        final byte[] bytes = serializationSchema.serialize(testData.f3, false);
-        final Row actual = deserializationSchema.deserialize(bytes, false);
-        assertThat(actual).isEqualTo(testData.f3);
-    }
-
-    @Test
-    void testTimestampGenericGenericSerializeDeserializeNewMapping() throws Exception {
-        final Tuple4<Class<? extends SpecificRecord>, SpecificRecord, GenericRecord, Row> testData =
-                AvroTestUtils.getTimestampTestData();
-
-        final String schemaString = testData.f2.getSchema().toString();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(schemaString);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(schemaString);
-
-        final byte[] bytes = serializationSchema.serialize(testData.f3);
-        final Row actual = deserializationSchema.deserialize(bytes);
-        assertThat(actual).isEqualTo(testData.f3);
-    }
-
-    @Test
-    void testTimestampClassSerializeDeserializeNewMapping() throws Exception {
-        final Tuple4<Class<? extends SpecificRecord>, SpecificRecord, GenericRecord, Row> testData =
-                AvroTestUtils.getTimestampTestData();
-
-        final AvroRowSerializationSchema serializationSchema =
-                new AvroRowSerializationSchema(testData.f0);
-        final AvroRowDeserializationSchema deserializationSchema =
-                new AvroRowDeserializationSchema(testData.f0);
-
-        final byte[] bytes = serializationSchema.serialize(testData.f3);
-        final Row actual = deserializationSchema.deserialize(bytes);
-        assertThat(actual).isEqualTo(testData.f3);
-    }
-
-    private void testSerializability(
-            AvroRowSerializationSchema ser,
-            AvroRowDeserializationSchema deser,
-            Row data,
-            boolean legacyTimestampMapping)
-            throws Exception {
-        final byte[] serBytes = InstantiationUtil.serializeObject(ser);
-        final byte[] deserBytes = InstantiationUtil.serializeObject(deser);
-
-        final AvroRowSerializationSchema serCopy =
-                InstantiationUtil.deserializeObject(
-                        serBytes, Thread.currentThread().getContextClassLoader());
-        final AvroRowDeserializationSchema deserCopy =
-                InstantiationUtil.deserializeObject(
-                        deserBytes, Thread.currentThread().getContextClassLoader());
-
-        if (legacyTimestampMapping) {
-            final byte[] bytes = serCopy.serialize(data);
-            deserCopy.deserialize(bytes);
-            deserCopy.deserialize(bytes);
-            final Row actual = deserCopy.deserialize(bytes);
-            assertThat(actual).isEqualTo(data);
-        } else {
-            final byte[] bytes = serCopy.serialize(data, false);
-            deserCopy.deserialize(bytes, false);
-            deserCopy.deserialize(bytes, false);
-            final Row actual = deserCopy.deserialize(bytes, false);
-            assertThat(actual).isEqualTo(data);
-        }
-    }
-}
diff --git a/flink-python/pom.xml b/flink-python/pom.xml
index 7afc822145e..697a6d53cc3 100644
--- a/flink-python/pom.xml
+++ b/flink-python/pom.xml
@@ -97,6 +97,12 @@ under the License.
 			<version>${project.version}</version>
 			<scope>provided</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.flink</groupId>
+			<artifactId>flink-avro</artifactId>
+			<version>${project.version}</version>
+			<scope>provided</scope>
+		</dependency>
 
 		<!-- Beam dependencies -->
 
@@ -721,6 +727,10 @@ under the License.
 									<pattern>com.google.protobuf</pattern>
 									<shadedPattern>org.apache.flink.api.python.shaded.com.google.protobuf</shadedPattern>
 								</relocation>
+								<relocation>
+									<pattern>org.apache.avro</pattern>
+									<shadedPattern>org.apache.flink.avro.shaded.org.apache.avro</shadedPattern>
+								</relocation>
 							</relocations>
 						</configuration>
 					</execution>
diff --git a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java b/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
similarity index 98%
rename from flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
rename to flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
index 74429b102f2..852ee54f850 100644
--- a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
+++ b/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowDeserializationSchema.java
@@ -17,7 +17,7 @@
 
 package org.apache.flink.formats.avro;
 
-import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.annotation.Internal;
 import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.api.common.serialization.AbstractDeserializationSchema;
 import org.apache.flink.api.common.serialization.DeserializationSchema;
@@ -80,13 +80,8 @@ import java.util.TimeZone;
  *
  * <p>Note: Changes in this class need to be kept in sync with the corresponding runtime class
  * {@link AvroRowSerializationSchema} and schema converter {@link AvroSchemaConverter}.
- *
- * @deprecated The format was developed for the Table API users and will not be maintained for
- *     DataStream API users anymore. Either use Table API or switch to Data Stream, defining your
- *     own {@link DeserializationSchema}.
  */
-@PublicEvolving
-@Deprecated
+@Internal
 public class AvroRowDeserializationSchema extends AbstractDeserializationSchema<Row> {
     /** Used for time conversions into SQL types. */
     private static final TimeZone LOCAL_TZ = TimeZone.getDefault();
diff --git a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowSerializationSchema.java b/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowSerializationSchema.java
similarity index 98%
rename from flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowSerializationSchema.java
rename to flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowSerializationSchema.java
index 1e80306538c..90503e81915 100644
--- a/flink-formats/flink-avro/src/main/java/org/apache/flink/formats/avro/AvroRowSerializationSchema.java
+++ b/flink-python/src/main/java/org/apache/flink/formats/avro/AvroRowSerializationSchema.java
@@ -18,6 +18,7 @@
 
 package org.apache.flink.formats.avro;
 
+import org.apache.flink.annotation.Internal;
 import org.apache.flink.annotation.VisibleForTesting;
 import org.apache.flink.api.common.serialization.SerializationSchema;
 import org.apache.flink.formats.avro.typeutils.AvroSchemaConverter;
@@ -66,12 +67,8 @@ import java.util.TimeZone;
  *
  * <p>Note: Changes in this class need to be kept in sync with the corresponding runtime class
  * {@link AvroRowDeserializationSchema} and schema converter {@link AvroSchemaConverter}.
- *
- * @deprecated The format was developed for the Table API users and will not be maintained for
- *     DataStream API users anymore. Either use Table API or switch to Data Stream, defining your
- *     own {@link SerializationSchema}.
  */
-@Deprecated
+@Internal
 public class AvroRowSerializationSchema implements SerializationSchema<Row> {
 
     /** Used for time conversions from SQL types. */


(flink) 02/03: [FLINK-36311][format/json] Remove deprecated APIs in Flink Json format

Posted by di...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dianfu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 98a0a567edf6bf660d9629c0e5e12e81b443a820
Author: Dian Fu <di...@apache.org>
AuthorDate: Wed Sep 18 15:00:14 2024 +0800

    [FLINK-36311][format/json] Remove deprecated APIs in Flink Json format
---
 .../json/JsonNodeDeserializationSchema.java        |  37 --
 .../json/JsonNodeDeserializationSchemaTest.java    |  50 ---
 .../json/JsonRowDeserializationSchemaTest.java     | 443 ---------------------
 .../json/JsonRowSerializationSchemaTest.java       | 250 ------------
 flink-python/pom.xml                               |  14 +-
 .../formats/json/JsonRowDeserializationSchema.java |  25 +-
 .../formats/json/JsonRowSerializationSchema.java   |  14 +-
 7 files changed, 13 insertions(+), 820 deletions(-)

diff --git a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonNodeDeserializationSchema.java b/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonNodeDeserializationSchema.java
deleted file mode 100644
index 928a6f1e59d..00000000000
--- a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonNodeDeserializationSchema.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * DeserializationSchema that deserializes a JSON String into an ObjectNode.
- *
- * <p>Fields can be accessed by calling objectNode.get(&lt;name>).as(&lt;type>)
- *
- * @deprecated Use {@code new JsonDeserializationSchema(ObjectNode.class)} instead
- */
-@Deprecated
-public class JsonNodeDeserializationSchema extends JsonDeserializationSchema<ObjectNode> {
-
-    private static final long serialVersionUID = 2L;
-
-    public JsonNodeDeserializationSchema() {
-        super(ObjectNode.class);
-    }
-}
diff --git a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonNodeDeserializationSchemaTest.java b/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonNodeDeserializationSchemaTest.java
deleted file mode 100644
index e6b2a3e05cb..00000000000
--- a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonNodeDeserializationSchemaTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * 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.connector.testutils.formats.DummyInitializationContext;
-import org.apache.flink.util.jackson.JacksonMapperFactory;
-
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode;
-
-import org.junit.jupiter.api.Test;
-
-import java.io.IOException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-/** Tests for the {@link JsonNodeDeserializationSchema}. */
-@SuppressWarnings("deprecation")
-class JsonNodeDeserializationSchemaTest {
-
-    @Test
-    void testDeserialize() throws IOException {
-        ObjectMapper mapper = JacksonMapperFactory.createObjectMapper();
-        ObjectNode initialValue = mapper.createObjectNode();
-        initialValue.put("key", 4).put("value", "world");
-        byte[] serializedValue = mapper.writeValueAsBytes(initialValue);
-
-        JsonNodeDeserializationSchema schema = new JsonNodeDeserializationSchema();
-        schema.open(new DummyInitializationContext());
-        ObjectNode deserializedValue = schema.deserialize(serializedValue);
-
-        assertThat(deserializedValue.get("key").asInt()).isEqualTo(4);
-        assertThat(deserializedValue.get("value").asText()).isEqualTo("world");
-    }
-}
diff --git a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDeserializationSchemaTest.java b/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDeserializationSchemaTest.java
deleted file mode 100644
index 4712768f291..00000000000
--- a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowDeserializationSchemaTest.java
+++ /dev/null
@@ -1,443 +0,0 @@
-/*
- * 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.jackson.JacksonMapperFactory;
-
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
-import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.node.ObjectNode;
-
-import org.junit.jupiter.api.Test;
-
-import javax.annotation.Nullable;
-
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ThreadLocalRandom;
-
-import static org.apache.flink.formats.utils.DeserializationSchemaMatcher.whenDeserializedWith;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Tests for the {@link JsonRowDeserializationSchema}. */
-public class JsonRowDeserializationSchemaTest {
-
-    private static final ObjectMapper OBJECT_MAPPER = JacksonMapperFactory.createObjectMapper();
-
-    /** Tests simple deserialization using type information. */
-    @Test
-    public void testTypeInfoDeserialization() throws Exception {
-        long id = 1238123899121L;
-        String name = "asdlkjasjkdla998y1122";
-        byte[] bytes = new byte[1024];
-        ThreadLocalRandom.current().nextBytes(bytes);
-        Timestamp timestamp = Timestamp.valueOf("1990-10-14 12:12:43");
-        Date date = Date.valueOf("1990-10-14");
-        Time time = Time.valueOf("12:12:43");
-
-        Map<String, Long> map = new HashMap<>();
-        map.put("flink", 123L);
-
-        Map<String, Map<String, Integer>> nestedMap = new HashMap<>();
-        Map<String, Integer> innerMap = new HashMap<>();
-        innerMap.put("key", 234);
-        nestedMap.put("inner_map", innerMap);
-
-        // Root
-        ObjectNode root = OBJECT_MAPPER.createObjectNode();
-        root.put("id", id);
-        root.put("name", name);
-        root.put("bytes", bytes);
-        root.put("date1", "1990-10-14");
-        root.put("date2", "1990-10-14");
-        root.put("time1", "12:12:43Z");
-        root.put("time2", "12:12:43Z");
-        root.put("timestamp1", "1990-10-14T12:12:43Z");
-        root.put("timestamp2", "1990-10-14T12:12:43Z");
-        root.putObject("map").put("flink", 123);
-        root.putObject("map2map").putObject("inner_map").put("key", 234);
-
-        byte[] serializedJson = OBJECT_MAPPER.writeValueAsBytes(root);
-
-        JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(
-                                Types.ROW_NAMED(
-                                        new String[] {
-                                            "id",
-                                            "name",
-                                            "bytes",
-                                            "date1",
-                                            "date2",
-                                            "time1",
-                                            "time2",
-                                            "timestamp1",
-                                            "timestamp2",
-                                            "map",
-                                            "map2map"
-                                        },
-                                        Types.LONG,
-                                        Types.STRING,
-                                        Types.PRIMITIVE_ARRAY(Types.BYTE),
-                                        Types.SQL_DATE,
-                                        Types.LOCAL_DATE,
-                                        Types.SQL_TIME,
-                                        Types.LOCAL_TIME,
-                                        Types.SQL_TIMESTAMP,
-                                        Types.LOCAL_DATE_TIME,
-                                        Types.MAP(Types.STRING, Types.LONG),
-                                        Types.MAP(
-                                                Types.STRING, Types.MAP(Types.STRING, Types.INT))))
-                        .build();
-
-        Row row = new Row(11);
-        row.setField(0, id);
-        row.setField(1, name);
-        row.setField(2, bytes);
-        row.setField(3, date);
-        row.setField(4, date.toLocalDate());
-        row.setField(5, time);
-        row.setField(6, time.toLocalTime());
-        row.setField(7, timestamp);
-        row.setField(8, timestamp.toLocalDateTime());
-        row.setField(9, map);
-        row.setField(10, nestedMap);
-
-        assertThat(
-                        whenDeserializedWith(deserializationSchema)
-                                .equalsTo(row)
-                                .matches(serializedJson))
-                .isTrue();
-    }
-
-    @Test
-    public void testSchemaDeserialization() throws Exception {
-        final BigDecimal id = BigDecimal.valueOf(1238123899121L);
-        final String name = "asdlkjasjkdla998y1122";
-        final byte[] bytes = new byte[1024];
-        ThreadLocalRandom.current().nextBytes(bytes);
-        final BigDecimal[] numbers =
-                new BigDecimal[] {
-                    BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3)
-                };
-        final String[] strings = new String[] {"one", "two", "three"};
-
-        // Root
-        ObjectNode root = OBJECT_MAPPER.createObjectNode();
-        root.put("id", id.longValue());
-        root.putNull("idOrNull");
-        root.put("name", name);
-        root.put("date", "1990-10-14");
-        root.put("time", "12:12:43Z");
-        root.put("timestamp", "1990-10-14T12:12:43Z");
-        root.put("bytes", bytes);
-        root.putArray("numbers").add(1).add(2).add(3);
-        root.putArray("strings").add("one").add("two").add("three");
-        root.putObject("nested").put("booleanField", true).put("decimalField", 12);
-
-        final byte[] serializedJson = OBJECT_MAPPER.writeValueAsBytes(root);
-
-        JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(
-                                "{"
-                                        + "    type: 'object',"
-                                        + "    properties: {"
-                                        + "         id: { type: 'integer' },"
-                                        + "         idOrNull: { type: ['integer', 'null'] },"
-                                        + "         name: { type: 'string' },"
-                                        + "         date: { type: 'string', format: 'date' },"
-                                        + "         time: { type: 'string', format: 'time' },"
-                                        + "         timestamp: { type: 'string', format: 'date-time' },"
-                                        + "         bytes: { type: 'string', contentEncoding: 'base64' },"
-                                        + "         numbers: { type: 'array', items: { type: 'integer' } },"
-                                        + "         strings: { type: 'array', items: { type: 'string' } },"
-                                        + "         nested: { "
-                                        + "             type: 'object',"
-                                        + "             properties: { "
-                                        + "                 booleanField: { type: 'boolean' },"
-                                        + "                 decimalField: { type: 'number' }"
-                                        + "             }"
-                                        + "         }"
-                                        + "    }"
-                                        + "}")
-                        .build();
-
-        final Row expected = new Row(10);
-        expected.setField(0, id);
-        expected.setField(1, null);
-        expected.setField(2, name);
-        expected.setField(3, Date.valueOf("1990-10-14"));
-        expected.setField(4, Time.valueOf("12:12:43"));
-        expected.setField(5, Timestamp.valueOf("1990-10-14 12:12:43"));
-        expected.setField(6, bytes);
-        expected.setField(7, numbers);
-        expected.setField(8, strings);
-        final Row nestedRow = new Row(2);
-        nestedRow.setField(0, true);
-        nestedRow.setField(1, BigDecimal.valueOf(12));
-        expected.setField(9, nestedRow);
-
-        assertThat(
-                        whenDeserializedWith(deserializationSchema)
-                                .equalsTo(expected)
-                                .matches(serializedJson))
-                .isTrue();
-    }
-
-    /** Tests deserialization with non-existing field name. */
-    @Test
-    public void testMissingNode() throws Exception {
-        // Root
-        ObjectNode root = OBJECT_MAPPER.createObjectNode();
-        root.put("id", 123123123);
-        byte[] serializedJson = OBJECT_MAPPER.writeValueAsBytes(root);
-
-        TypeInformation<Row> rowTypeInformation =
-                Types.ROW_NAMED(new String[] {"name"}, Types.STRING);
-
-        JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(rowTypeInformation).build();
-
-        Row row = new Row(1);
-        assertThat(
-                        whenDeserializedWith(deserializationSchema)
-                                .equalsTo(row)
-                                .matches(serializedJson))
-                .isTrue();
-
-        deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(rowTypeInformation)
-                        .failOnMissingField()
-                        .build();
-        final JsonRowDeserializationSchema errorDs = deserializationSchema;
-        assertThatThrownBy(() -> errorDs.deserialize(serializedJson))
-                .isInstanceOf(Exception.class)
-                .hasMessageContaining("Failed to deserialize JSON");
-
-        // ignore-parse-errors ignores missing field exception too
-        deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(rowTypeInformation)
-                        .ignoreParseErrors()
-                        .build();
-        assertThat(
-                        whenDeserializedWith(deserializationSchema)
-                                .equalsTo(row)
-                                .matches(serializedJson))
-                .isTrue();
-
-        assertThatThrownBy(
-                        () ->
-                                new JsonRowDeserializationSchema.Builder(rowTypeInformation)
-                                        .failOnMissingField()
-                                        .ignoreParseErrors()
-                                        .build())
-                .isInstanceOf(IllegalArgumentException.class)
-                .hasMessageContaining(
-                        "JSON format doesn't support failOnMissingField and ignoreParseErrors are both true");
-    }
-
-    /** Tests that number of field names and types has to match. */
-    @Test
-    public void testNumberOfFieldNamesAndTypesMismatch() {
-        assertThatThrownBy(
-                        () ->
-                                new JsonRowDeserializationSchema.Builder(
-                                                Types.ROW_NAMED(
-                                                        new String[] {"one", "two", "three"},
-                                                        Types.LONG))
-                                        .build())
-                .isInstanceOf(IllegalArgumentException.class)
-                .hasMessageContaining("Number of field types and names is different.");
-    }
-
-    @Test
-    public void testJsonParse() {
-        for (TestSpec spec : testData) {
-            testIgnoreParseErrors(spec);
-            if (spec.errorMessage != null) {
-                testParseErrors(spec);
-            }
-        }
-    }
-
-    private void testIgnoreParseErrors(TestSpec spec) {
-        // the parsing field should be null and no exception is thrown
-        JsonRowDeserializationSchema ignoreErrorsSchema =
-                new JsonRowDeserializationSchema.Builder(spec.rowTypeInformation)
-                        .ignoreParseErrors()
-                        .build();
-        Row expected;
-        if (spec.expected != null) {
-            expected = spec.expected;
-        } else {
-            expected = new Row(1);
-        }
-
-        assertThat(
-                        whenDeserializedWith(ignoreErrorsSchema)
-                                .equalsTo(expected)
-                                .matches(spec.json.getBytes()))
-                .isTrue();
-    }
-
-    private void testParseErrors(TestSpec spec) {
-        // expect exception if parse error is not ignored
-        JsonRowDeserializationSchema failingSchema =
-                new JsonRowDeserializationSchema.Builder(spec.rowTypeInformation).build();
-
-        assertThatThrownBy(() -> failingSchema.deserialize(spec.json.getBytes()))
-                .isInstanceOf(Exception.class)
-                .hasMessageContaining(spec.errorMessage);
-    }
-
-    private static List<TestSpec> testData =
-            Arrays.asList(
-                    TestSpec.json("{\"id\": \"trueA\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.BOOLEAN))
-                            .expect(Row.of(false)),
-                    TestSpec.json("{\"id\": true}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.BOOLEAN))
-                            .expect(Row.of(true)),
-                    TestSpec.json("{\"id\":\"abc\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.INT))
-                            .expectErrorMessage("Failed to deserialize JSON '{\"id\":\"abc\"}'"),
-                    TestSpec.json("{\"id\":112.013}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.LONG))
-                            .expect(Row.of(112L)),
-                    TestSpec.json("{\"id\":true}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.STRING))
-                            .expect(Row.of("true")),
-                    TestSpec.json("{\"id\":123.234}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.STRING))
-                            .expect(Row.of("123.234")),
-                    TestSpec.json("{\"id\":1234567}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.STRING))
-                            .expect(Row.of("1234567")),
-                    TestSpec.json("{\"id\":\"string field\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.STRING))
-                            .expect(Row.of("string field")),
-                    TestSpec.json("{\"id\":[\"array data1\",\"array data2\",123,234.345]}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.STRING))
-                            .expect(Row.of("[\"array data1\",\"array data2\",123,234.345]")),
-                    TestSpec.json("{\"id\":{\"k1\":123,\"k2\":234.234,\"k3\":\"string data\"}}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.STRING))
-                            .expect(Row.of("{\"k1\":123,\"k2\":234.234,\"k3\":\"string data\"}")),
-                    TestSpec.json("{\"id\":\"long\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.LONG))
-                            .expectErrorMessage("Failed to deserialize JSON '{\"id\":\"long\"}'"),
-                    TestSpec.json("{\"id\":\"112.013.123\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.FLOAT))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"id\":\"112.013.123\"}'"),
-                    TestSpec.json("{\"id\":\"112.013.123\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.DOUBLE))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"id\":\"112.013.123\"}'"),
-                    TestSpec.json("{\"id\":\"18:00:243\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.SQL_TIME))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"id\":\"18:00:243\"}'"),
-                    TestSpec.json("{\"id\":\"20191112\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.SQL_DATE))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"id\":\"20191112\"}'"),
-                    TestSpec.json("{\"id\":\"2019-11-12 18:00:12\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.SQL_TIMESTAMP))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"id\":\"2019-11-12 18:00:12\"}'"),
-                    TestSpec.json("{\"id\":\"abc\"}")
-                            .typeInfo(Types.ROW_NAMED(new String[] {"id"}, Types.BIG_DEC))
-                            .expectErrorMessage("Failed to deserialize JSON '{\"id\":\"abc\"}'"),
-                    TestSpec.json("{\"row\":{\"id\":\"abc\"}}")
-                            .typeInfo(
-                                    Types.ROW_NAMED(
-                                            new String[] {"row"},
-                                            Types.ROW_NAMED(new String[] {"id"}, Types.INT)))
-                            .expect(Row.of(new Row(1)))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"row\":{\"id\":\"abc\"}}'"),
-                    TestSpec.json("{\"array\":[123, \"abc\"]}")
-                            .typeInfo(
-                                    Types.ROW_NAMED(
-                                            new String[] {"array"}, Types.OBJECT_ARRAY(Types.INT)))
-                            .expect(Row.of((Object) new Integer[] {123, null}))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"array\":[123, \"abc\"]}'"),
-                    TestSpec.json("{\"map\":{\"key1\":\"123\", \"key2\":\"abc\"}}")
-                            .typeInfo(
-                                    Types.ROW_NAMED(
-                                            new String[] {"map"},
-                                            Types.MAP(Types.STRING, Types.INT)))
-                            .expect(Row.of(createHashMap("key1", 123, "key2", null)))
-                            .expectErrorMessage(
-                                    "Failed to deserialize JSON '{\"map\":{\"key1\":\"123\", \"key2\":\"abc\"}}'"),
-                    TestSpec.json("{\"id\":1,\"factor\":799.929496989092949698}")
-                            .typeInfo(
-                                    Types.ROW_NAMED(
-                                            new String[] {"id", "factor"},
-                                            Types.INT,
-                                            Types.BIG_DEC))
-                            .expect(Row.of(1, new BigDecimal("799.929496989092949698"))));
-
-    private static Map<String, Integer> createHashMap(
-            String k1, Integer v1, String k2, Integer v2) {
-        Map<String, Integer> map = new HashMap<>();
-        map.put(k1, v1);
-        map.put(k2, v2);
-        return map;
-    }
-
-    private static class TestSpec {
-        private final String json;
-        private @Nullable TypeInformation<Row> rowTypeInformation;
-        private @Nullable Row expected;
-        private @Nullable String errorMessage;
-
-        private TestSpec(String json) {
-            this.json = json;
-        }
-
-        public static TestSpec json(String json) {
-            return new TestSpec(json);
-        }
-
-        TestSpec expect(Row row) {
-            this.expected = row;
-            return this;
-        }
-
-        TestSpec typeInfo(TypeInformation<Row> rowTypeInformation) {
-            this.rowTypeInformation = rowTypeInformation;
-            return this;
-        }
-
-        TestSpec expectErrorMessage(String errorMessage) {
-            this.errorMessage = errorMessage;
-            return this;
-        }
-    }
-}
diff --git a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowSerializationSchemaTest.java b/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowSerializationSchemaTest.java
deleted file mode 100644
index 5140a8556a4..00000000000
--- a/flink-formats/flink-json/src/test/java/org/apache/flink/formats/json/JsonRowSerializationSchemaTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * 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.junit.jupiter.api.Test;
-
-import java.io.IOException;
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.concurrent.ThreadLocalRandom;
-
-import static org.apache.flink.connector.testutils.formats.SchemaTestUtils.open;
-import static org.apache.flink.formats.utils.SerializationSchemaMatcher.whenSerializedWith;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.assertThatThrownBy;
-
-/** Tests for the {@link JsonRowSerializationSchema}. */
-public class JsonRowSerializationSchemaTest {
-
-    @Test
-    public void testRowSerialization() {
-        final TypeInformation<Row> rowSchema =
-                Types.ROW_NAMED(
-                        new String[] {"f1", "f2", "f3", "f4", "f5"},
-                        Types.INT,
-                        Types.BOOLEAN,
-                        Types.STRING,
-                        Types.SQL_TIMESTAMP,
-                        Types.LOCAL_DATE_TIME);
-
-        final Row row = new Row(5);
-        row.setField(0, 1);
-        row.setField(1, true);
-        row.setField(2, "str");
-        row.setField(3, Timestamp.valueOf("1990-10-14 12:12:43"));
-        row.setField(4, Timestamp.valueOf("1990-10-14 12:12:43").toLocalDateTime());
-
-        final JsonRowSerializationSchema serializationSchema =
-                new JsonRowSerializationSchema.Builder(rowSchema).build();
-        final JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(rowSchema).build();
-
-        assertThat(
-                        whenSerializedWith(serializationSchema)
-                                .andDeserializedWith(deserializationSchema)
-                                .equalsTo(row)
-                                .matches(row))
-                .isTrue();
-    }
-
-    @Test
-    public void testSerializationOfTwoRows() throws IOException {
-        final TypeInformation<Row> rowSchema =
-                Types.ROW_NAMED(
-                        new String[] {"f1", "f2", "f3"}, Types.INT, Types.BOOLEAN, Types.STRING);
-
-        final Row row1 = new Row(3);
-        row1.setField(0, 1);
-        row1.setField(1, true);
-        row1.setField(2, "str");
-
-        final JsonRowSerializationSchema serializationSchema =
-                new JsonRowSerializationSchema.Builder(rowSchema).build();
-        open(serializationSchema);
-        final JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(rowSchema).build();
-        open(deserializationSchema);
-
-        byte[] bytes = serializationSchema.serialize(row1);
-        assertThat(deserializationSchema.deserialize(bytes)).isEqualTo(row1);
-
-        final Row row2 = new Row(3);
-        row2.setField(0, 10);
-        row2.setField(1, false);
-        row2.setField(2, "newStr");
-
-        bytes = serializationSchema.serialize(row2);
-        assertThat(deserializationSchema.deserialize(bytes)).isEqualTo(row2);
-    }
-
-    @Test
-    public void testMultiRowsWithNullValues() throws IOException {
-        String[] jsons =
-                new String[] {
-                    "{\"svt\":\"2020-02-24T12:58:09.209+0800\"}",
-                    "{\"svt\":\"2020-02-24T12:58:09.209+0800\", \"ops\":{\"id\":\"281708d0-4092-4c21-9233-931950b6eccf\"}, "
-                            + "\"ids\":[1, 2, 3]}",
-                    "{\"svt\":\"2020-02-24T12:58:09.209+0800\"}",
-                };
-
-        String[] expected =
-                new String[] {
-                    "{\"svt\":\"2020-02-24T12:58:09.209+0800\",\"ops\":null,\"ids\":null}",
-                    "{\"svt\":\"2020-02-24T12:58:09.209+0800\",\"ops\":{\"id\":\"281708d0-4092-4c21-9233-931950b6eccf\"},"
-                            + "\"ids\":[1,2,3]}",
-                    "{\"svt\":\"2020-02-24T12:58:09.209+0800\",\"ops\":null,\"ids\":null}",
-                };
-
-        TypeInformation<Row> schema =
-                Types.ROW_NAMED(
-                        new String[] {"svt", "ops", "ids"},
-                        Types.STRING,
-                        Types.ROW_NAMED(new String[] {"id"}, Types.STRING),
-                        Types.PRIMITIVE_ARRAY(Types.INT));
-        JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(schema).build();
-        open(deserializationSchema);
-        JsonRowSerializationSchema serializationSchema =
-                JsonRowSerializationSchema.builder().withTypeInfo(schema).build();
-        open(serializationSchema);
-
-        for (int i = 0; i < jsons.length; i++) {
-            String json = jsons[i];
-            Row row = deserializationSchema.deserialize(json.getBytes());
-            String result = new String(serializationSchema.serialize(row));
-            assertThat(result).isEqualTo(expected[i]);
-        }
-    }
-
-    @Test
-    public void testNestedSchema() {
-        final TypeInformation<Row> rowSchema =
-                Types.ROW_NAMED(
-                        new String[] {"f1", "f2", "f3"},
-                        Types.INT,
-                        Types.BOOLEAN,
-                        Types.ROW(Types.INT, Types.DOUBLE));
-
-        final Row row = new Row(3);
-        row.setField(0, 42);
-        row.setField(1, false);
-        final Row nested = new Row(2);
-        nested.setField(0, 22);
-        nested.setField(1, 2.3);
-        row.setField(2, nested);
-
-        final JsonRowSerializationSchema serializationSchema =
-                new JsonRowSerializationSchema.Builder(rowSchema).build();
-        final JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(rowSchema).build();
-
-        assertThat(
-                        whenSerializedWith(serializationSchema)
-                                .andDeserializedWith(deserializationSchema)
-                                .equalsTo(row)
-                                .matches(row))
-                .isTrue();
-    }
-
-    @Test
-    public void testSerializeRowWithInvalidNumberOfFields() {
-        final TypeInformation<Row> rowSchema =
-                Types.ROW_NAMED(
-                        new String[] {"f1", "f2", "f3"}, Types.INT, Types.BOOLEAN, Types.STRING);
-
-        final Row row = new Row(1);
-        row.setField(0, 1);
-
-        final JsonRowSerializationSchema serializationSchema =
-                new JsonRowSerializationSchema.Builder(rowSchema).build();
-        open(serializationSchema);
-        assertThatThrownBy(() -> serializationSchema.serialize(row))
-                .isInstanceOf(RuntimeException.class);
-    }
-
-    @Test
-    public void testSchema() {
-        final TypeInformation<Row> rowSchema =
-                JsonRowSchemaConverter.convert(
-                        "{"
-                                + "    type: 'object',"
-                                + "    properties: {"
-                                + "         id: { type: 'integer' },"
-                                + "         idNumber: { type: 'number' },"
-                                + "         idOrNull: { type: ['integer', 'null'] },"
-                                + "         name: { type: 'string' },"
-                                + "         date: { type: 'string', format: 'date' },"
-                                + "         time: { type: 'string', format: 'time' },"
-                                + "         timestamp: { type: 'string', format: 'date-time' },"
-                                + "         bytes: { type: 'string', contentEncoding: 'base64' },"
-                                + "         numbers: { type: 'array', items: { type: 'integer' } },"
-                                + "         strings: { type: 'array', items: { type: 'string' } },"
-                                + "         nested: { "
-                                + "             type: 'object',"
-                                + "             properties: { "
-                                + "                 booleanField: { type: 'boolean' },"
-                                + "                 decimalField: { type: 'number' }"
-                                + "             }"
-                                + "         }"
-                                + "    }"
-                                + "}");
-
-        final Row row = new Row(11);
-        row.setField(0, BigDecimal.valueOf(-333));
-        row.setField(1, BigDecimal.valueOf(12.2222));
-        row.setField(2, null);
-        row.setField(3, "");
-        row.setField(4, Date.valueOf("1990-10-14"));
-        row.setField(5, Time.valueOf("12:12:43"));
-        row.setField(6, Timestamp.valueOf("1990-10-14 12:12:43"));
-
-        final byte[] bytes = new byte[1024];
-        ThreadLocalRandom.current().nextBytes(bytes);
-        row.setField(7, bytes);
-        final BigDecimal[] numbers =
-                new BigDecimal[] {
-                    BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3)
-                };
-        row.setField(8, numbers);
-        final String[] strings = new String[] {"one", "two", "three"};
-        row.setField(9, strings);
-        final Row nestedRow = new Row(2);
-        nestedRow.setField(0, true);
-        nestedRow.setField(1, BigDecimal.valueOf(12));
-        row.setField(10, nestedRow);
-
-        final JsonRowSerializationSchema serializationSchema =
-                new JsonRowSerializationSchema.Builder(rowSchema).build();
-        final JsonRowDeserializationSchema deserializationSchema =
-                new JsonRowDeserializationSchema.Builder(rowSchema).build();
-
-        assertThat(
-                        whenSerializedWith(serializationSchema)
-                                .andDeserializedWith(deserializationSchema)
-                                .equalsTo(row)
-                                .matches(row))
-                .isTrue();
-    }
-}
diff --git a/flink-python/pom.xml b/flink-python/pom.xml
index 697a6d53cc3..1f96abd752d 100644
--- a/flink-python/pom.xml
+++ b/flink-python/pom.xml
@@ -103,6 +103,12 @@ under the License.
 			<version>${project.version}</version>
 			<scope>provided</scope>
 		</dependency>
+		<dependency>
+			<groupId>org.apache.flink</groupId>
+			<artifactId>flink-json</artifactId>
+			<version>${project.version}</version>
+			<scope>provided</scope>
+		</dependency>
 
 		<!-- Beam dependencies -->
 
@@ -284,14 +290,6 @@ under the License.
 			<scope>test</scope>
 		</dependency>
 
-		<dependency>
-			<!-- Indirectly accessed in pyflink_gateway_server -->
-			<groupId>org.apache.flink</groupId>
-			<artifactId>flink-json</artifactId>
-			<version>${project.version}</version>
-			<scope>test</scope>
-		</dependency>
-
 		<dependency>
 			<!-- Indirectly accessed in pyflink_gateway_server -->
 			<groupId>org.apache.flink</groupId>
diff --git a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java b/flink-python/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java
similarity index 96%
rename from flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java
rename to flink-python/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java
index dd4a9bb9f99..ec00116ebd3 100644
--- a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java
+++ b/flink-python/src/main/java/org/apache/flink/formats/json/JsonRowDeserializationSchema.java
@@ -18,7 +18,7 @@
 
 package org.apache.flink.formats.json;
 
-import org.apache.flink.annotation.PublicEvolving;
+import org.apache.flink.annotation.Internal;
 import org.apache.flink.api.common.serialization.DeserializationSchema;
 import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
 import org.apache.flink.api.common.typeinfo.PrimitiveArrayTypeInfo;
@@ -78,13 +78,8 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
  * <p>Deserializes a <code>byte[]</code> message as a JSON object and reads the specified fields.
  *
  * <p>Failures during deserialization are forwarded as wrapped IOExceptions.
- *
- * @deprecated The format was developed for the Table API users and will not be maintained for
- *     DataStream API users anymore. Either use Table API or switch to Data Stream, defining your
- *     own {@link DeserializationSchema}.
  */
-@PublicEvolving
-@Deprecated
+@Internal
 public class JsonRowDeserializationSchema implements DeserializationSchema<Row> {
 
     private static final long serialVersionUID = -228294330688809195L;
@@ -92,14 +87,14 @@ public class JsonRowDeserializationSchema implements DeserializationSchema<Row>
     /** Type information describing the result type. */
     private final RowTypeInfo typeInfo;
 
-    private boolean failOnMissingField;
+    private final boolean failOnMissingField;
 
     private final boolean hasDecimalType;
 
     /** Object mapper for parsing the JSON. */
     private transient ObjectMapper objectMapper;
 
-    private DeserializationRuntimeConverter runtimeConverter;
+    private final DeserializationRuntimeConverter runtimeConverter;
 
     /** Flag indicating whether to ignore invalid fields/rows (default: throw an exception). */
     private final boolean ignoreParseErrors;
@@ -128,26 +123,14 @@ public class JsonRowDeserializationSchema implements DeserializationSchema<Row>
         }
     }
 
-    /** @deprecated Use the provided {@link Builder} instead. */
-    @Deprecated
     public JsonRowDeserializationSchema(TypeInformation<Row> typeInfo) {
         this(typeInfo, false, false);
     }
 
-    /** @deprecated Use the provided {@link Builder} instead. */
-    @Deprecated
     public JsonRowDeserializationSchema(String jsonSchema) {
         this(JsonRowSchemaConverter.convert(checkNotNull(jsonSchema)), false, false);
     }
 
-    /** @deprecated Use the provided {@link Builder} instead. */
-    @Deprecated
-    public void setFailOnMissingField(boolean failOnMissingField) {
-        // TODO make this class immutable once we drop this method
-        this.failOnMissingField = failOnMissingField;
-        this.runtimeConverter = createConverter(this.typeInfo);
-    }
-
     @Override
     public Row deserialize(byte[] message) throws IOException {
         try {
diff --git a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java b/flink-python/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java
similarity index 96%
rename from flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java
rename to flink-python/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java
index f185d211bf9..90374ee5edc 100644
--- a/flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java
+++ b/flink-python/src/main/java/org/apache/flink/formats/json/JsonRowSerializationSchema.java
@@ -17,6 +17,7 @@
 
 package org.apache.flink.formats.json;
 
+import org.apache.flink.annotation.Internal;
 import org.apache.flink.annotation.PublicEvolving;
 import org.apache.flink.api.common.serialization.SerializationSchema;
 import org.apache.flink.api.common.typeinfo.BasicArrayTypeInfo;
@@ -65,13 +66,8 @@ import static org.apache.flink.util.Preconditions.checkNotNull;
  *
  * <p>Result <code>byte[]</code> messages can be deserialized using {@link
  * JsonRowDeserializationSchema}.
- *
- * @deprecated The format was developed for the Table API users and will not be maintained for
- *     DataStream API users anymore. Either use Table API or switch to Data Stream, defining your
- *     own {@link SerializationSchema}.
  */
-@PublicEvolving
-@Deprecated
+@Internal
 public class JsonRowSerializationSchema implements SerializationSchema<Row> {
 
     private static final long serialVersionUID = -2885556750743978636L;
@@ -115,9 +111,7 @@ public class JsonRowSerializationSchema implements SerializationSchema<Row> {
          *
          * @param typeInfo Type information describing the result type. The field names of {@link
          *     Row} are used to parse the JSON properties.
-         * @deprecated Use {@link JsonRowSerializationSchema#builder()} instead.
          */
-        @Deprecated
         public Builder(TypeInformation<Row> typeInfo) {
             checkArgument(typeInfo instanceof RowTypeInfo, "Only RowTypeInfo is supported");
             this.typeInfo = (RowTypeInfo) typeInfo;
@@ -128,9 +122,7 @@ public class JsonRowSerializationSchema implements SerializationSchema<Row> {
          *
          * @param jsonSchema JSON schema describing the result type
          * @see <a href="http://json-schema.org/">http://json-schema.org/</a>
-         * @deprecated Use {@link JsonRowSerializationSchema#builder()} instead.
          */
-        @Deprecated
         public Builder(String jsonSchema) {
             this(JsonRowSchemaConverter.convert(checkNotNull(jsonSchema)));
         }
@@ -158,7 +150,7 @@ public class JsonRowSerializationSchema implements SerializationSchema<Row> {
         }
     }
 
-    /** Creates a builder for {@link JsonRowSerializationSchema.Builder}. */
+    /** Creates a builder for {@link Builder}. */
     public static Builder builder() {
         return new Builder();
     }