[
https://issues.apache.org/jira/browse/CALCITE-7120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Steve Carlin updated CALCITE-7120:
----------------------------------
Description:
Currently, for the following select statement:
SELECT 10_000_000_000, 1_000_000, 1_000, 100
, the RelDataType created would be a SqlTypeName.BIGINT for the 10,000,000
value and SqlTypeName.INTEGER for the other values.
It would be a nice feature to have finer granularities like
SqlTypeName.SMALLINT and SqlTypeName.INTEGER when the RexLiteral is produced.
We will have to be careful in that we probably shouldn't change the default
behavior which could break users of Calcite. Not sure how this should be
configured though.
The previous title to this Jira was:
Allow SqlNumericLiteral to create more restrictive integer types
and the comments up until August 7th are the discussion that narrowed down the
description to what is above. The information below this description was the
previous description, kept here for historical purpose.
======
It would be nice if SqlNumericLiteral created more restrictive datatypes for
integers.
There is already some logic in there that differentiates between INTEGER and
BIGINT
{code:java}
if ((l >= Integer.MIN_VALUE) && (l <= Integer.MAX_VALUE)) {
result = SqlTypeName.INTEGER;
} else {
result = SqlTypeName.BIGINT;
}
{code}
If we can enhance this for TINYINT and SMALLINT, oh how wonderful that would be
for me.
Background: Without this, it is causing me to use various workarounds by
overriding methods that are less than ideal. Upon upgrade from 1.37 to 1.40,
my current implementation failed. A query such as ...
"SELECT 1 INTERSECT SELECT tinyint_col FROM my_tbl"
... is generating a validated SQLNode tree which casts the tinyint_col to an
INTEGER (when using type coercing) which causes me issues. (side note, I need
type coercing enabled for other issues so I can't just turn it off)
Should we do this via a config option? Putting this in by default will
probably break a lot of people's code.
was:
Currently, i
It would be nice if SqlNumericLiteral created more restrictive datatypes for
integers.
There is already some logic in there that differentiates between INTEGER and
BIGINT
{code:java}
if ((l >= Integer.MIN_VALUE) && (l <= Integer.MAX_VALUE)) {
result = SqlTypeName.INTEGER;
} else {
result = SqlTypeName.BIGINT;
}
{code}
If we can enhance this for TINYINT and SMALLINT, oh how wonderful that would be
for me.
Background: Without this, it is causing me to use various workarounds by
overriding methods that are less than ideal. Upon upgrade from 1.37 to 1.40,
my current implementation failed. A query such as ...
"SELECT 1 INTERSECT SELECT tinyint_col FROM my_tbl"
... is generating a validated SQLNode tree which casts the tinyint_col to an
INTEGER (when using type coercing) which causes me issues. (side note, I need
type coercing enabled for other issues so I can't just turn it off)
Should we do this via a config option? Putting this in by default will
probably break a lot of people's code.
> Allow finer granularity for integer literals
> --------------------------------------------
>
> Key: CALCITE-7120
> URL: https://issues.apache.org/jira/browse/CALCITE-7120
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Reporter: Steve Carlin
> Priority: Major
>
> Currently, for the following select statement:
> SELECT 10_000_000_000, 1_000_000, 1_000, 100
> , the RelDataType created would be a SqlTypeName.BIGINT for the 10,000,000
> value and SqlTypeName.INTEGER for the other values.
> It would be a nice feature to have finer granularities like
> SqlTypeName.SMALLINT and SqlTypeName.INTEGER when the RexLiteral is produced.
> We will have to be careful in that we probably shouldn't change the default
> behavior which could break users of Calcite. Not sure how this should be
> configured though.
> The previous title to this Jira was:
> Allow SqlNumericLiteral to create more restrictive integer types
> and the comments up until August 7th are the discussion that narrowed down
> the description to what is above. The information below this description was
> the previous description, kept here for historical purpose.
> ======
> It would be nice if SqlNumericLiteral created more restrictive datatypes for
> integers.
> There is already some logic in there that differentiates between INTEGER and
> BIGINT
>
> {code:java}
> if ((l >= Integer.MIN_VALUE) && (l <= Integer.MAX_VALUE)) {
> result = SqlTypeName.INTEGER;
> } else {
> result = SqlTypeName.BIGINT;
> }
> {code}
> If we can enhance this for TINYINT and SMALLINT, oh how wonderful that would
> be for me.
> Background: Without this, it is causing me to use various workarounds by
> overriding methods that are less than ideal. Upon upgrade from 1.37 to 1.40,
> my current implementation failed. A query such as ...
> "SELECT 1 INTERSECT SELECT tinyint_col FROM my_tbl"
> ... is generating a validated SQLNode tree which casts the tinyint_col to an
> INTEGER (when using type coercing) which causes me issues. (side note, I
> need type coercing enabled for other issues so I can't just turn it off)
> Should we do this via a config option? Putting this in by default will
> probably break a lot of people's code.
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)