@@ -0,0 +1,2189 @@
+/*%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.DecimalType;%0Aimport org.testng.annotations.Test;%0A%0Aimport java.math.BigDecimal;%0A%0Aimport static java.nio.charset.StandardCharsets.US_ASCII;%0Aimport static org.testng.Assert.assertEquals;%0A%0Apublic class TestHiveDecimalParser%0A%7B%0A    @Test%0A    public void testParseDecimal()%0A    %7B%0A        checkParseDecimal(%223%22, 2, 1, new BigDecimal(%223.0%22));%0A        checkParseDecimal(%223.1%22, 2, 1, new BigDecimal(%223.1%22));%0A%0A        // rounding%0A        checkParseDecimal(%223.11%22, 2, 1, new BigDecimal(%223.1%22));%0A        checkParseDecimal(%223.16%22, 2, 1, new BigDecimal(%223.2%22));%0A%0A        // rouding of half (odd and even)%0A        checkParseDecimal(%223.15%22, 2, 1, new BigDecimal(%223.2%22));%0A        checkParseDecimal(%223.25%22, 2, 1, new BigDecimal(%223.3%22));%0A%0A        // negative%0A        checkParseDecimal(%22-3%22, 2, 1, new BigDecimal(%22-3.0%22));%0A        checkParseDecimal(%22-3.1%22, 2, 1, new BigDecimal(%22-3.1%22));%0A%0A        // negative rounding%0A        checkParseDecimal(%22-3.11%22, 2, 1, new BigDecimal(%22-3.1%22));%0A        checkParseDecimal(%22-3.16%22, 2, 1, new BigDecimal(%22-3.2%22));%0A%0A        // negative rounding of half (odd and even)%0A        checkParseDecimal(%22-3.15%22, 2, 1, new BigDecimal(%22-3.2%22));%0A        checkParseDecimal(%22-3.25%22, 2, 1, new BigDecimal(%22-3.3%22));%0A    %7D%0A%0A    private void checkParseDecimal(String input, int precision, int scale, BigDecimal expected)%0A    %7B%0A        byte%5B%5D bytes = input.getBytes(US_ASCII);%0A        BigDecimal parsed = HiveDecimalParser.parseHiveDecimal(bytes, 0, bytes.length, DecimalType.createDecimalType(precision, scale));%0A        assertEquals(parsed, expected);%0A    %7D%0A%7D%0A

Add test for decimal parsing