mihaibudiu commented on code in PR #3945:
URL: https://github.com/apache/calcite/pull/3945#discussion_r1757275436
##########
core/src/test/java/org/apache/calcite/sql/type/RelDataTypeSystemTest.java:
##########
@@ -143,6 +145,31 @@ static class Fixture extends SqlTypeFixture {
final SqlTypeFactoryImpl customTypeFactory = new SqlTypeFactoryImpl(new
CustomTypeSystem());
}
+ @Test void testSupportNegativeScale() {
+ final SqlTypeFactoryImpl customTypeFactory =
+ new SqlTypeFactoryImpl(new DelegatingTypeSystem(new
CustomTypeSystem()) {
+ @Override public boolean supportsNegativeScale() {
+ return true;
+ }
+ });
+ RelDataType dataType =
customTypeFactory.createSqlType(SqlTypeName.DECIMAL, 10, -5);
+ assertEquals(SqlTypeName.DECIMAL, dataType.getSqlTypeName());
+ assertEquals(10, dataType.getPrecision());
+ assertEquals(-5, dataType.getScale());
+ }
+
+ @Test void testNotSupportNegativeScale() {
Review Comment:
if you support a negative scale, is there a lower limit?
For example, in Oracle the scale has maximum and minimum values:
https://docs.oracle.com/cd/B19306_01/server.102/b14200.pdf, page 44 in the pdf
##########
core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystem.java:
##########
@@ -62,6 +62,9 @@ public interface RelDataTypeSystem {
/** Returns the maximum precision of a NUMERIC or DECIMAL type. */
int getMaxNumericPrecision();
+ /** Returns whether the scale of a NUMERIC or DECIMAL type can be negative.
*/
Review Comment:
Based on my question below and other systems, maybe the right way to do this
is to have a minimumNumericScale(), and this function to return 'true' if the
minimum is less than 0.
You still have to have a rule to reject some types when the negative scale
is too large.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]