[
https://issues.apache.org/jira/browse/CALCITE-4841?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Louis Kuang updated CALCITE-4841:
---------------------------------
Description:
Currently, the csv adapter does not support the numeric column type (see
supported types in
[CsvFieldType|https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/file/src/main/java/org/apache/calcite/adapter/file/CsvFieldType.java#L35].
Any type that is not supported will be interpreted by the
[CsvEnumerator|https://github.com/apache/calcite/blob/master/file/src/main/java/org/apache/calcite/adapter/file/CsvEnumerator.java]
as string.
When dealing with decimal numbers, the currently most appropriate type is
`double`. However, this is not accurate enough for financial data. This feature
request proposes adding a `numeric` column type that will be implemented by the
Java `BigDecimal` type (and by conversion in
[JavaToSqlTypeConversionRules|https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/core/src/main/java/org/apache/calcite/sql/type/JavaToSqlTypeConversionRules.java#L74]
be represented as a `Decimal` SQL type). This allow financial data to be
represented and computed more accurately (`BigDecimal` has higher precision
than `double`).
Please see sample implementation in PR.
Context: I am trying to leverage Calcite to add some SQL support to
[ledger|https://www.ledger-cli.org/] reporting.
was:
Currently, the csv adapter does not support the numeric column type (see
supported types in
[CsvFieldType|https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/file/src/main/java/org/apache/calcite/adapter/file/CsvFieldType.java#L35].
Any type that is not supported will be interpreted by the
[CsvEnumerator|https://github.com/apache/calcite/blob/master/file/src/main/java/org/apache/calcite/adapter/file/CsvEnumerator.java]
as string.
When dealing with decimal numbers, the currently most appropriate type is
`double`. However, this is not accurate enough for financial data. This feature
request proposes adding a `numeric` column type that will be implemented by the
Java `BigDecimal` type (and by conversion in
[JavaToSqlTypeConversionRules|https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/core/src/main/java/org/apache/calcite/sql/type/JavaToSqlTypeConversionRules.java#L74]
be represented as a `Decimal` SQL type). This allow financial data to be
represented and computed more accurately (`BigDecimal` has higher precision
than `double`).
Please see sample implementation in PR.
> Support numeric column type in CSV and File adapter
> ---------------------------------------------------
>
> Key: CALCITE-4841
> URL: https://issues.apache.org/jira/browse/CALCITE-4841
> Project: Calcite
> Issue Type: Improvement
> Components: csv-adapter, file-adapter
> Reporter: Louis Kuang
> Priority: Minor
> Labels: pull-request-available
> Time Spent: 40m
> Remaining Estimate: 0h
>
> Currently, the csv adapter does not support the numeric column type (see
> supported types in
> [CsvFieldType|https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/file/src/main/java/org/apache/calcite/adapter/file/CsvFieldType.java#L35].
> Any type that is not supported will be interpreted by the
> [CsvEnumerator|https://github.com/apache/calcite/blob/master/file/src/main/java/org/apache/calcite/adapter/file/CsvEnumerator.java]
> as string.
> When dealing with decimal numbers, the currently most appropriate type is
> `double`. However, this is not accurate enough for financial data. This
> feature request proposes adding a `numeric` column type that will be
> implemented by the Java `BigDecimal` type (and by conversion in
> [JavaToSqlTypeConversionRules|https://github.com/apache/calcite/blob/4bc916619fd286b2c0cc4d5c653c96a68801d74e/core/src/main/java/org/apache/calcite/sql/type/JavaToSqlTypeConversionRules.java#L74]
> be represented as a `Decimal` SQL type). This allow financial data to be
> represented and computed more accurately (`BigDecimal` has higher precision
> than `double`).
> Please see sample implementation in PR.
> Context: I am trying to leverage Calcite to add some SQL support to
> [ledger|https://www.ledger-cli.org/] reporting.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)