-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IGNITE-23178 : Calcite. Least restrictive type priority DOUBLE over FLOAT #11520
Conversation
.../org/apache/ignite/internal/processors/query/calcite/planner/NumericTypesPrecisionsTest.java
Outdated
Show resolved
Hide resolved
.../org/apache/ignite/internal/processors/query/calcite/planner/NumericTypesPrecisionsTest.java
Outdated
Show resolved
Hide resolved
.../org/apache/ignite/internal/processors/query/calcite/planner/NumericTypesPrecisionsTest.java
Outdated
Show resolved
Hide resolved
.../org/apache/ignite/internal/processors/query/calcite/planner/NumericTypesPrecisionsTest.java
Outdated
Show resolved
Hide resolved
/** */ | ||
@Test | ||
public void testMaxPrecision() { | ||
assertEquals(STRING_PRECISION, typeSys.getMaxPrecision(SqlTypeName.CHAR)); | ||
assertEquals(STRING_PRECISION, typeSys.getMaxPrecision(SqlTypeName.VARCHAR)); | ||
assertEquals(STRING_PRECISION, typeSys.getMaxPrecision(SqlTypeName.BINARY)); | ||
assertEquals(STRING_PRECISION, typeSys.getMaxPrecision(SqlTypeName.VARBINARY)); | ||
|
||
assertEquals(3, typeSys.getMaxPrecision(SqlTypeName.TINYINT)); | ||
assertEquals(5, typeSys.getMaxPrecision(SqlTypeName.SMALLINT)); | ||
assertEquals(10, typeSys.getMaxPrecision(SqlTypeName.INTEGER)); | ||
assertEquals(19, typeSys.getMaxPrecision(SqlTypeName.BIGINT)); | ||
assertEquals(7, typeSys.getMaxPrecision(SqlTypeName.REAL)); | ||
assertEquals(15, typeSys.getMaxPrecision(SqlTypeName.FLOAT)); | ||
assertEquals(15, typeSys.getMaxPrecision(SqlTypeName.DOUBLE)); | ||
assertEquals(DECIMAL_PRECISION, typeSys.getMaxPrecision(SqlTypeName.DECIMAL)); | ||
|
||
assertEquals(0, typeSys.getMaxPrecision(SqlTypeName.DATE)); | ||
assertEquals(3, typeSys.getMaxPrecision(SqlTypeName.TIME)); | ||
assertEquals(3, typeSys.getMaxPrecision(SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE)); | ||
assertEquals(3, typeSys.getMaxPrecision(SqlTypeName.TIMESTAMP)); | ||
assertEquals(3, typeSys.getMaxPrecision(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE)); | ||
} | ||
|
||
/** */ | ||
@Test | ||
public void testDefaultPrecision() { | ||
assertEquals(1, typeSys.getDefaultPrecision(SqlTypeName.CHAR)); | ||
assertEquals(RelDataType.PRECISION_NOT_SPECIFIED, typeSys.getDefaultPrecision(SqlTypeName.VARCHAR)); | ||
assertEquals(1, typeSys.getDefaultPrecision(SqlTypeName.BINARY)); | ||
assertEquals(RelDataType.PRECISION_NOT_SPECIFIED, typeSys.getDefaultPrecision(SqlTypeName.VARBINARY)); | ||
|
||
assertEquals(3, typeSys.getDefaultPrecision(SqlTypeName.TINYINT)); | ||
assertEquals(5, typeSys.getDefaultPrecision(SqlTypeName.SMALLINT)); | ||
assertEquals(10, typeSys.getDefaultPrecision(SqlTypeName.INTEGER)); | ||
assertEquals(19, typeSys.getDefaultPrecision(SqlTypeName.BIGINT)); | ||
assertEquals(7, typeSys.getDefaultPrecision(SqlTypeName.REAL)); | ||
assertEquals(15, typeSys.getDefaultPrecision(SqlTypeName.FLOAT)); | ||
assertEquals(15, typeSys.getDefaultPrecision(SqlTypeName.DOUBLE)); | ||
assertEquals(DECIMAL_PRECISION, typeSys.getDefaultPrecision(SqlTypeName.DECIMAL)); | ||
|
||
assertEquals(0, typeSys.getDefaultPrecision(SqlTypeName.DATE)); | ||
assertEquals(0, typeSys.getDefaultPrecision(SqlTypeName.TIME)); | ||
assertEquals(3, typeSys.getDefaultPrecision(SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE)); | ||
assertEquals(3, typeSys.getDefaultPrecision(SqlTypeName.TIMESTAMP)); | ||
assertEquals(0, typeSys.getDefaultPrecision(SqlTypeName.TIMESTAMP_WITH_LOCAL_TIME_ZONE)); | ||
} | ||
|
||
|
||
/** */ | ||
@Test | ||
public void testMaxNumericPrecision() { | ||
assertEquals(DECIMAL_PRECISION, typeSys.getMaxNumericPrecision()); | ||
} | ||
|
||
/** */ | ||
@Test | ||
public void testMaxNumericScale() { | ||
assertEquals(DECIMAL_SCALE, typeSys.getMaxNumericScale()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need these tests? Values for max/default prcision are hardcoded in calcite and looks like we just compare one hardcoded value with another one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We manually implement several values. Like:
@Override public int getMaxNumericScale() {
return Short.MAX_VALUE;
}
/** {@inheritDoc} */
@Override public int getMaxNumericPrecision() {
return Short.MAX_VALUE;
}
or
@Override public int getDefaultPrecision(SqlTypeName typeName) {
// Timestamps internally stored as millis, precision more than 3 is redundant. At the same time,
// default Calcite precision 0 causes truncation when converting to TIMESTAMP without specifying precision.
if (typeName == SqlTypeName.TIMESTAMP || typeName == SqlTypeName.TIME_WITH_LOCAL_TIME_ZONE)
return 3;
return super.getDefaultPrecision(typeName);
}
It looks usefult to be sure that nothing would change. Or we can remove the tests. WDYT?
.../org/apache/ignite/internal/processors/query/calcite/planner/NumericTypesPrecisionsTest.java
Outdated
Show resolved
Hide resolved
Quality Gate passedIssues Measures |
Thank you for submitting the pull request to the Apache Ignite.
In order to streamline the review of the contribution
we ask you to ensure the following steps have been taken:
The Contribution Checklist
The description explains WHAT and WHY was made instead of HOW.
The following pattern must be used:
IGNITE-XXXX Change summary
whereXXXX
- number of JIRA issue.(see the Maintainers list)
the
green visa
attached to the JIRA ticket (see TC.Bot: Check PR)Notes
If you need any help, please email [email protected] or ask anу advice on http://asf.slack.com #ignite channel.