apache / doris

Apache Doris is an easy-to-use, high performance and unified analytics database.
https://doris.apache.org
Apache License 2.0
12.3k stars 3.21k forks source link

doris can't get Decimals precision use java.sql.PreparedStatement com.mysql.jdbc.JDBC42 but mysql can get it #4037

Open mnloveyx opened 4 years ago

mnloveyx commented 4 years ago

PreparedStatement preparedStatement = null; try { preparedStatement = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY ); preparedStatement.setMaxRows( 1 ); ResultSetMetaData rsmd = preparedStatement.getMetaData(); } catch ( Exception e ) { throw new Exception( e ); } finally { if ( preparedStatement != null ) { try { preparedStatement.close(); } catch ( SQLException e ) { } } } rsmd.getFields

doris Decimals precision can't get it use java.sql.PreparedStatement com.mysql.jdbc.JDBC42 see

image

mysql Decimals precision

image

doris create table CREATE TABLE IF NOT EXISTS test1 ( id BIGINT NOT NULL COMMENT "", need_amt DECIMAL(16,2) replace_if_not_null NULL COMMENT "" ) ENGINE=OLAP AGGREGATE KEY(id) COMMENT "OLAP" DISTRIBUTED BY HASH(id) BUCKETS 6 PROPERTIES ( "replication_num" = "3", "in_memory" = "false", "storage_format" = "DEFAULT" );

mysql create table

CREATE TABLE test1 ( id bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id', need_amt decimal(16,2) DEFAULT NULL COMMENT '', PRIMARY KEY (id) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='test'

yangzhg commented 4 years ago

this because of method writeField in fe/src/main/java/org/apache/doris/mysql/MysqlSerializer.java not write the length and Decimals, could you fix this for us?