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
[CALCITE-6380] Casts from INTERVAL and STRING to DECIMAL are incorrect #3790
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Mihai Budiu <mbudiu@feldera.com>
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.
Overall LGTM
@@ -770,41 +773,39 @@ void testCastIntervalToNumeric(CastType castType, SqlOperatorFixture f) { | |||
f.setFor(SqlStdOperatorTable.CAST, VmName.EXPAND); | |||
|
|||
// interval to decimal |
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.
Interval to Decimal
Expressions.constant(scale), | ||
Expressions.constant(sourceType.getSqlTypeName().getEndUnit().multiplier)); | ||
} | ||
} |
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.
Should we throw an exception when a situation does not include the above three cases
// string to decimal | ||
f.checkScalarExact("cast('1.29' as decimal(2,1))", | ||
"DECIMAL(2, 1) NOT NULL", | ||
"1.3"); | ||
"1.2"); |
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.
Different systems have different interception methods, I think the return value 1.3
is also reasonable. Most systems return 1.3
, such as MySQL, PostgreSQL, Hive, and Spark, but ClickHouse returns 1.2
.
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.
There doesn't seem to be a standard set of sql rules here, so maybe we should think about what makes sense mathematically or what makes sense to follow the rules of most databases
No description provided.