[
https://issues.apache.org/jira/browse/IGNITE-18969?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Maksim Zhuravkov updated IGNITE-18969:
--------------------------------------
Description:
The current implement of IgniteTypeFactory::leastRestrictiveType returns the
first custom data type it encounters, which is obviously not correct.
Add generic rules on how `leastRestrictiveType` should work for some custom
data type (e.g. when a type has precision it possible to choose such, when type
do not have precision, etc).
{code:java}
var type1 = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR, 10);
var type2 = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR, 20);
var actualType = TYPE_FACTORY.leastRestrictive(Arrays.asList(type1, type2));
// prints VARCHAR(20)
System.out.println(actualType);
{code}
Javadoc on RelDataTypeFactory::leastRestrictiveType:
{code:java}
Returns the most general of a set of types (that is, one type to which they can
all be cast), or null if conversion is not possible. The result may be a new
type that is less restrictive than any of the input types, e.g.
leastRestrictive(INT, NUMERIC(3, 2)) could be NUMERIC(12, 2).
{code}
was:
The current implement of IgniteTypeFactory::leastRestrictiveType returns the
first custom data type it encounters, which is obviously not correct.
Add generic rules on how `leastRestrictiveType` should work for some custom
data type (e.g. when a type has precision it possible to choose such, when type
do not have precision, etc).
{code:java}
var type1 = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR, 10);
var type2 = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR, 20);
var actualType = TYPE_FACTORY.leastRestrictive(Arrays.asList(type1, type2));
// prints VARCHAR(20)
System.out.println(actualType);
{code}
> Sql. Implement of leastRestrictiveType for custom data types within the same
> type family.
> -----------------------------------------------------------------------------------------
>
> Key: IGNITE-18969
> URL: https://issues.apache.org/jira/browse/IGNITE-18969
> Project: Ignite
> Issue Type: Improvement
> Components: sql
> Reporter: Maksim Zhuravkov
> Priority: Minor
> Labels: calcite3-required, ignite-3
> Fix For: 3.0.0-beta2
>
>
> The current implement of IgniteTypeFactory::leastRestrictiveType returns the
> first custom data type it encounters, which is obviously not correct.
> Add generic rules on how `leastRestrictiveType` should work for some custom
> data type (e.g. when a type has precision it possible to choose such, when
> type do not have precision, etc).
> {code:java}
> var type1 = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR, 10);
> var type2 = TYPE_FACTORY.createSqlType(SqlTypeName.VARCHAR, 20);
> var actualType = TYPE_FACTORY.leastRestrictive(Arrays.asList(type1, type2));
> // prints VARCHAR(20)
> System.out.println(actualType);
> {code}
> Javadoc on RelDataTypeFactory::leastRestrictiveType:
> {code:java}
> Returns the most general of a set of types (that is, one type to which they
> can all be cast), or null if conversion is not possible. The result may be a
> new type that is less restrictive than any of the input types, e.g.
> leastRestrictive(INT, NUMERIC(3, 2)) could be NUMERIC(12, 2).
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)