anthoRx / parquet-sql

Apache License 2.0
3 stars 1 forks source link

Double cannot be cast to BigDecimal #31

Closed nsvir closed 2 months ago

nsvir commented 3 years ago

A Double may be of 2 sql types java.sql.Types:

image

If NUMERIC occurs, the code successful cast BigDecimal into itself. if DOUBLE occurs, the code fails to cast Double to BigDecimal.

How to reproduce: Use a h2 database:

    DriverManagerDataSource dataSource = new DriverManagerDataSource();
    dataSource.setDriverClassName("org.h2.Driver");
    dataSource.setUrl("jdbc:h2:mem:db;DB_CLOSE_DELAY=-1;MODE=Oracle");
    dataSource.setUsername("sa");
    dataSource.setPassword("sa");

    return dataSource;

Execute this SQL

CREATE TABLE POST
(
    float           FLOAT
);

INSERT INTO POST(float) values (0.5);

Ask parquetWriter to serialize POST table