[
https://issues.apache.org/jira/browse/CALCITE-1103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15218083#comment-15218083
]
Josh Elser commented on CALCITE-1103:
-------------------------------------
Nevermind, I did reproduce an issue with protobuf:
{code}
@Test public void testBigDecimalPrecision() throws Exception {
final String tableName = "decimalPrecision";
// DECIMAL(25,5), 20 before, 5 after
BigDecimal decimal = new BigDecimal("12345123451234512345.09876");
try (Connection conn = getLocalConnection();
Statement stmt = conn.createStatement()) {
assertFalse(stmt.execute("DROP TABLE IF EXISTS " + tableName));
assertFalse(stmt.execute("CREATE TABLE " + tableName + " (col1
DECIMAL(25,5))"));
// Insert a single decimal
try (PreparedStatement pstmt = conn.prepareStatement("INSERT INTO " +
tableName
+ " values (?)")) {
pstmt.setBigDecimal(1, decimal);
assertEquals(1, pstmt.executeUpdate());
}
ResultSet results = stmt.executeQuery("SELECT * FROM " + tableName);
assertNotNull(results);
assertTrue(results.next());
BigDecimal actualDecimal = results.getBigDecimal(1);
assertEquals(decimal, actualDecimal);
}
}
{code}
> Decimal data serialized as Double in Protocol Buffer API
> --------------------------------------------------------
>
> Key: CALCITE-1103
> URL: https://issues.apache.org/jira/browse/CALCITE-1103
> Project: Calcite
> Issue Type: Bug
> Components: avatica
> Affects Versions: 1.5.0
> Environment: HDP 2.3.4 with Phoenix 4.4 and Calcite 1.5
> Reporter: Kevin Liew
> Assignee: Josh Elser
> Priority: Minor
> Labels: decimal, double, protobuf
>
> Decimal data is serialized as TypedValue.double_value and loses precision.
> Decoded Wireshark capture
> {code:sql}select * from decimal_table{code}
> {noformat}
> [employee@centos7-ws test]$ protoc --decode_raw < test.pb
> 1: "org.apache.calcite.avatica.proto.Responses$ExecuteResponse"
> 2 {
> 1 {
> 1: "cf74c4e9-29bc-410a-b557-bf7a4965cbaf"
> 2: 479389
> 3: 1
> 4 {
> 1 {
> 4: 1
> 8: 255
> 9: "KEYCOLUMN"
> 10: "KEYCOLUMN"
> 12: 255
> 14: "DECIMAL_TABLE_38_6"
> 16: 1
> 19: "java.lang.String"
> 20 {
> 1: 12
> 2: "VARCHAR"
> 3: 21
> }
> }
> 1 {
> 1: 1
> 4: 1
> 6: 1
> 7: 1
> 8: 38
> 9: "COLUMN1"
> 10: "COLUMN1"
> 12: 38
> 13: 6
> 14: "DECIMAL_TABLE_38_6"
> 16: 1
> 19: "java.math.BigDecimal"
> 20 {
> 1: 3
> 2: "DECIMAL"
> 3: 23
> }
> }
> 2: "select * from decimal_table_38_6"
> 4 {
> 1: 4
> }
> }
> 5 {
> 2: 1
> 3 {
> 1 {
> 1 {
> 1: 21
> 3: "ConversionTestKey"
> }
> }
> 1 {
> 1 {
> 1: 22
> 6: 0x3ffe666666666666
> }
> }
> }
> 3 {
> 1 {
> 1 {
> 1: 21
> 3: "FractionalNumeric6"
> }
> }
> 1 {
> 1 {
> 1: 22
> 6: 0x40ba0a524af0bf1a
> }
> }
> }
> 3 {
> 1 {
> 1 {
> 1: 21
> 3: "FractionalNumeric8"
> }
> }
> 1 {
> 1 {
> 1: 22
> 6: 0xbff1f9acffa7eb6c
> }
> }
> }
> 3 {
> 1 {
> 1 {
> 1: 21
> 3: "Null"
> }
> }
> 1 {
> 1 {
> 1: 24
> }
> }
> }
> 3 {
> 1 {
> 1 {
> 1: 21
> 3: "OnePlusFraction"
> }
> }
> 1 {
> 1 {
> 1: 22
> 6: 0x3ff000010c6f7a0b
> }
> }
> }
> }
> 6: 18446744073709551615
> 7 {
> 1: "centos7-ws:8765"
> }
> }
> 3 {
> 1: "centos7-ws:8765"
> }
> }
> {noformat}
> The column1 data is tagged with 6 which corresponds to double_value in the
> proto file.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)