dawidwys commented on a change in pull request #14619: URL: https://github.com/apache/flink/pull/14619#discussion_r558227865
########## File path: flink-table/flink-table-common/src/test/java/org/apache/flink/table/types/TypeInfoDataTypeConverterTest.java ########## @@ -0,0 +1,262 @@ +/* + * 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.table.types; + +import org.apache.flink.api.common.ExecutionConfig; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.common.typeinfo.Types; +import org.apache.flink.api.common.typeutils.TypeSerializer; +import org.apache.flink.api.java.tuple.Tuple2; +import org.apache.flink.api.java.tuple.Tuple3; +import org.apache.flink.table.api.DataTypes; +import org.apache.flink.table.types.utils.DataTypeFactoryMock; +import org.apache.flink.table.types.utils.TypeInfoDataTypeConverter; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameter; +import org.junit.runners.Parameterized.Parameters; + +import java.time.DayOfWeek; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; + +import static org.apache.flink.table.types.utils.DataTypeFactoryMock.dummyRaw; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + +/** Tests for {@link TypeInfoDataTypeConverter}. */ +@RunWith(Parameterized.class) +public class TypeInfoDataTypeConverterTest { + + @Parameters(name = "{index}: {0}") + public static List<TestSpec> testData() { + return Arrays.asList( + TestSpec.forType(Types.INT).expectDataType(DataTypes.INT().notNull()), + TestSpec.forType(Types.BIG_DEC) + .expectDataType(DataTypes.DECIMAL(38, 18).nullable()), + TestSpec.forType( + Types.ROW_NAMED( + new String[] {"a", "b", "c"}, + Types.DOUBLE, + Types.INT, + Types.STRING)) + .expectDataType( + DataTypes.ROW( + DataTypes.FIELD("a", DataTypes.DOUBLE()), + DataTypes.FIELD("b", DataTypes.INT()), + DataTypes.FIELD("c", DataTypes.STRING())) + .notNull()), + TestSpec.forType( + Types.TUPLE( + Types.INT, + Types.TUPLE(Types.STRING, Types.BOOLEAN), + Types.LONG)) + .expectDataType( + DataTypes.STRUCTURED( + Tuple3.class, + DataTypes.FIELD("f0", DataTypes.INT().notNull()), + DataTypes.FIELD( + "f1", + DataTypes.STRUCTURED( + Tuple2.class, + DataTypes.FIELD( + "f0", + DataTypes.STRING() + .nullable()), + DataTypes.FIELD( + "f1", + DataTypes.BOOLEAN() + .notNull())) + .notNull()), + DataTypes.FIELD("f2", DataTypes.BIGINT().notNull())) + .notNull()), + TestSpec.forType(Types.POJO(PojoWithFieldOrder.class)) Review comment: I think something is wrong with POJO types mapping. Shouldn't the primitive fields be mapped to `NOT NULL` types? Also from our offline chat it seems bridging classes are also not mapped correctly. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org