@@ -0,0 +1,3241 @@
+/*%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.facebook.presto.hive;%0A%0Aimport com.facebook.presto.spi.type.Type;%0Aimport com.facebook.presto.spi.type.TypeManager;%0Aimport com.facebook.presto.type.TypeRegistry;%0Aimport com.google.common.collect.ImmutableMap;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.util.HashMap;%0Aimport java.util.Map;%0A%0Aimport static com.facebook.presto.spi.type.TypeSignature.parseTypeSignature;%0Aimport static java.util.Objects.requireNonNull;%0Aimport static org.testng.Assert.assertEquals;%0A%0Apublic class TestHiveTypeTranslator%0A%7B%0A    private final TypeManager typeManager;%0A    private final TypeTranslator typeTranslator;%0A%0A    private final Map%3CString, HiveType%3E typeTranslationMap;%0A%0A    public TestHiveTypeTranslator()%0A    %7B%0A        this(new HiveTypeTranslator(), ImmutableMap.of());%0A    %7D%0A%0A    protected TestHiveTypeTranslator(TypeTranslator typeTranslator, Map%3CString, HiveType%3E overwriteTranslation)%0A    %7B%0A        this.typeManager = new TypeRegistry();%0A        this.typeTranslator = requireNonNull(typeTranslator, %22typeTranslator is null%22);%0A%0A        ImmutableMap%3CString, HiveType%3E hiveTypeTranslationMap = ImmutableMap.%3CString, HiveType%3Ebuilder()%0A                .put(%22bigint%22, HiveType.HIVE_LONG)%0A                .put(%22integer%22, HiveType.HIVE_INT)%0A                .put(%22smallint%22, HiveType.HIVE_SHORT)%0A                .put(%22tinyint%22, HiveType.HIVE_BYTE)%0A                .put(%22double%22, HiveType.HIVE_DOUBLE)%0A                .put(%22varchar(3)%22, HiveType.valueOf(%22varchar(3)%22))%0A                .put(%22varchar%22, HiveType.HIVE_STRING)%0A                .put(%22date%22, HiveType.HIVE_DATE)%0A                .put(%22timestamp%22, HiveType.HIVE_TIMESTAMP)%0A                .put(%22decimal(5,3)%22, HiveType.valueOf(%22decimal(5,3)%22))%0A                .put(%22varbinary%22, HiveType.HIVE_BINARY)%0A                .put(%22array(timestamp)%22, HiveType.valueOf(%22array%3Ctimestamp%3E%22))%0A                .put(%22map(boolean,varbinary)%22, HiveType.valueOf(%22map%3Cboolean,binary%3E%22))%0A                .put(%22row(col0 integer,col1 varbinary)%22, HiveType.valueOf(%22struct%3Ccol0:int,col1:binary%3E%22))%0A                .build();%0A%0A        typeTranslationMap = new HashMap%3C%3E();%0A        typeTranslationMap.putAll(hiveTypeTranslationMap);%0A        typeTranslationMap.putAll(overwriteTranslation);%0A    %7D%0A%0A    @Test%0A    public void testTypeTranslator()%0A    %7B%0A        for (Map.Entry%3CString, HiveType%3E entry : typeTranslationMap.entrySet()) %7B%0A            assertTypeTranslation(entry.getKey(), entry.getValue());%0A        %7D%0A    %7D%0A%0A    private void assertTypeTranslation(String typeName, HiveType hiveType)%0A    %7B%0A        Type type = typeManager.getType(parseTypeSignature(typeName));%0A        assertEquals(HiveType.toHiveType(typeTranslator, type), hiveType);%0A    %7D%0A%7D%0A

Add TestHiveTypeTranslator for Hive connector