This is an automated email from the ASF dual-hosted git repository.
asolimando pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/main by this push:
new 63a9f477b0 [CALCITE-7351] Make getMaxNumericScale() and
getMaxNumericPrecision() final
63a9f477b0 is described below
commit 63a9f477b09cdebfe49d5d35db9cc7970733ad68
Author: Alessandro Solimando <[email protected]>
AuthorDate: Fri Jan 2 19:18:22 2026 +0100
[CALCITE-7351] Make getMaxNumericScale() and getMaxNumericPrecision() final
Replace them with getMaxPrecision(SqlTypeName.DECIMAL) and
getMaxScale(SqlTypeName.DECIMAL), respectively.
---
.../apache/calcite/rel/type/RelDataTypeSystem.java | 52 ++++++----------------
.../calcite/rel/type/RelDataTypeSystemImpl.java | 17 +++----
.../calcite/sql/dialect/ClickHouseSqlDialect.java | 4 --
.../calcite/sql/dialect/DuckDBSqlDialect.java | 4 --
.../calcite/sql/dialect/PhoenixSqlDialect.java | 4 --
.../calcite/sql/dialect/PrestoSqlDialect.java | 4 --
.../calcite/sql/dialect/RedshiftSqlDialect.java | 8 ----
.../calcite/rel/rel2sql/RelToSqlConverterTest.java | 8 ----
.../calcite/sql/type/RelDataTypeSystemTest.java | 20 +++------
.../org/apache/calcite/tools/FrameworksTest.java | 10 -----
10 files changed, 27 insertions(+), 104 deletions(-)
diff --git
a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystem.java
b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystem.java
index 5becafc2b7..c9d6186747 100644
--- a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystem.java
+++ b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystem.java
@@ -96,53 +96,29 @@ public interface RelDataTypeSystem {
*
* @deprecated Replaced by {@link #getMaxScale}(DECIMAL).
*
- * <p>From Calcite release 1.38 onwards, instead of calling this method, you
- * should call {@code getMaxScale(DECIMAL)}.
+ * <p>Instead of calling this method, you should call
+ * {@code getMaxScale(DECIMAL)}.
*
- * <p>In Calcite release 1.38, if you wish to change the maximum
- * scale of {@link SqlTypeName#DECIMAL} values, you should do two things:
- *
- * <ul>
- * <li>Override the {@link #getMaxScale(SqlTypeName)} method,
- * changing its behavior for {@code DECIMAL};
- * <li>Make sure that the implementation of your
- * {@code #getMaxNumericScale} method calls
- * {@code getMaxScale(DECIMAL)}.
- * </ul>
- *
- * <p>In Calcite release 1.39, Calcite will cease calling this method,
- * and will remove the override of the method in
- * {@link RelDataTypeSystemImpl}. You should remove all calls to
- * and overrides of this method. */
- @Deprecated // calcite will cease calling in 1.39, and removed before 2.0
+ * <p>If you wish to change the maximum scale of {@link SqlTypeName#DECIMAL}
+ * values, override the {@link #getMaxScale(SqlTypeName)} method,
+ * changing its behavior for {@code DECIMAL}. */
+ @Deprecated // to be removed before 2.0
default int getMaxNumericScale() {
- return 19;
+ return getMaxScale(SqlTypeName.DECIMAL);
}
/** Returns the maximum precision of a NUMERIC or DECIMAL type.
* Default value is 19.
*
- * @deprecated Replaced by {@link #getMaxScale}(DECIMAL).
+ * @deprecated Replaced by {@link #getMaxPrecision}(DECIMAL).
*
- * <p>From Calcite release 1.38 onwards, instead of calling this method, you
- * should call {@code getMaxPrecision(DECIMAL)}.
- *
- * <p>In Calcite release 1.38, if you wish to change the maximum
- * precision of {@link SqlTypeName#DECIMAL} values, you should do two things:
- *
- * <ul>
- * <li>Override the {@link #getMaxPrecision(SqlTypeName)} method,
- * changing its behavior for {@code DECIMAL};
- * <li>Make sure that the implementation of your
- * {@code #getMaxNumericPrecision} method calls
- * {@code getMaxPrecision(DECIMAL)}.
- * </ul>
+ * <p>Instead of calling this method, you should call
+ * {@code getMaxPrecision(DECIMAL)}.
*
- * <p>In Calcite release 1.39, Calcite will cease calling this method,
- * and will remove the override of the method in
- * {@link RelDataTypeSystemImpl}. You should remove all calls to
- * and overrides of this method. */
- @Deprecated // calcite will cease calling in 1.39, and removed before 2.0
+ * <p>If you wish to change the maximum precision of {@link
SqlTypeName#DECIMAL}
+ * values, override the {@link #getMaxPrecision(SqlTypeName)} method,
+ * changing its behavior for {@code DECIMAL}. */
+ @Deprecated // to be removed before 2.0
default int getMaxNumericPrecision() {
return getMaxPrecision(SqlTypeName.DECIMAL);
}
diff --git
a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystemImpl.java
b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystemImpl.java
index b5eceedcce..50d66f5e5f 100644
--- a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystemImpl.java
+++ b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeSystemImpl.java
@@ -46,8 +46,7 @@ public abstract class RelDataTypeSystemImpl implements
RelDataTypeSystem {
@Override public int getMaxScale(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
- // from 1.39, this will be 'return 19;'
- return getMaxNumericScale();
+ return 19;
case INTERVAL_YEAR:
case INTERVAL_YEAR_MONTH:
case INTERVAL_MONTH:
@@ -107,8 +106,7 @@ public abstract class RelDataTypeSystemImpl implements
RelDataTypeSystem {
case VARBINARY:
return RelDataType.PRECISION_NOT_SPECIFIED;
case DECIMAL:
- // from 1.39, this will be 'return getMaxPrecision(typeName);'
- return getMaxNumericPrecision();
+ return getMaxPrecision(typeName);
case INTERVAL_YEAR:
case INTERVAL_YEAR_MONTH:
case INTERVAL_MONTH:
@@ -187,8 +185,7 @@ public abstract class RelDataTypeSystemImpl implements
RelDataTypeSystem {
@Override public int getMaxPrecision(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
- // from 1.39, this will be 'return 19;'
- return getMaxNumericPrecision();
+ return 19;
case VARCHAR:
case CHAR:
return 65536;
@@ -262,13 +259,13 @@ public abstract class RelDataTypeSystemImpl implements
RelDataTypeSystem {
}
@SuppressWarnings("deprecation")
- @Override public int getMaxNumericScale() {
- return 19;
+ @Override public final int getMaxNumericScale() {
+ return getMaxScale(SqlTypeName.DECIMAL);
}
@SuppressWarnings("deprecation")
- @Override public int getMaxNumericPrecision() {
- return 19;
+ @Override public final int getMaxNumericPrecision() {
+ return getMaxPrecision(SqlTypeName.DECIMAL);
}
@Override public RoundingMode roundingMode() {
diff --git
a/core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java
b/core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java
index 884bb81261..f33e49bb51 100644
---
a/core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java
+++
b/core/src/main/java/org/apache/calcite/sql/dialect/ClickHouseSqlDialect.java
@@ -69,10 +69,6 @@ public class ClickHouseSqlDialect extends SqlDialect {
return super.getMaxScale(typeName);
}
}
-
- @Override public int getMaxNumericScale() {
- return getMaxScale(SqlTypeName.DECIMAL);
- }
};
public static final SqlDialect.Context DEFAULT_CONTEXT =
SqlDialect.EMPTY_CONTEXT
diff --git
a/core/src/main/java/org/apache/calcite/sql/dialect/DuckDBSqlDialect.java
b/core/src/main/java/org/apache/calcite/sql/dialect/DuckDBSqlDialect.java
index e7d3333ba3..75b4dcc653 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/DuckDBSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/DuckDBSqlDialect.java
@@ -54,10 +54,6 @@ public class DuckDBSqlDialect extends SqlDialect {
return super.getMaxScale(typeName);
}
}
-
- @Override public int getMaxNumericScale() {
- return getMaxScale(SqlTypeName.DECIMAL);
- }
};
public static final SqlDialect.Context DEFAULT_CONTEXT =
SqlDialect.EMPTY_CONTEXT
diff --git
a/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java
b/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java
index 85bc64a89e..c3cebb92ae 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/PhoenixSqlDialect.java
@@ -55,10 +55,6 @@ public class PhoenixSqlDialect extends SqlDialect {
return super.getMaxScale(typeName);
}
}
-
- @Override public int getMaxNumericScale() {
- return getMaxScale(SqlTypeName.DECIMAL);
- }
};
public static final SqlDialect.Context DEFAULT_CONTEXT =
SqlDialect.EMPTY_CONTEXT
diff --git
a/core/src/main/java/org/apache/calcite/sql/dialect/PrestoSqlDialect.java
b/core/src/main/java/org/apache/calcite/sql/dialect/PrestoSqlDialect.java
index cd1aa5f5ec..1d8479aa58 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/PrestoSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/PrestoSqlDialect.java
@@ -84,10 +84,6 @@ public class PrestoSqlDialect extends SqlDialect {
return super.getMaxScale(typeName);
}
}
-
- @Override public int getMaxNumericScale() {
- return getMaxScale(SqlTypeName.DECIMAL);
- }
};
public static final Context DEFAULT_CONTEXT = SqlDialect.EMPTY_CONTEXT
diff --git
a/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java
b/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java
index 0875826a25..7caf2ab2be 100644
--- a/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java
+++ b/core/src/main/java/org/apache/calcite/sql/dialect/RedshiftSqlDialect.java
@@ -49,10 +49,6 @@ public class RedshiftSqlDialect extends SqlDialect {
}
}
- @Override public int getMaxNumericPrecision() {
- return getMaxPrecision(SqlTypeName.DECIMAL);
- }
-
@Override public int getMaxScale(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
@@ -61,10 +57,6 @@ public class RedshiftSqlDialect extends SqlDialect {
return super.getMaxScale(typeName);
}
}
-
- @Override public int getMaxNumericScale() {
- return getMaxScale(SqlTypeName.DECIMAL);
- }
};
public static final SqlDialect.Context DEFAULT_CONTEXT =
SqlDialect.EMPTY_CONTEXT
diff --git
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index 27e9c23fec..2c34707258 100644
---
a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++
b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -11380,10 +11380,6 @@ Sql withPostgresqlModifiedDecimalTypeSystem() {
new PostgresqlSqlDialect(PostgresqlSqlDialect.DEFAULT_CONTEXT
.withDataTypeSystem(
new RelDataTypeSystemImpl() {
- @Override public int getMaxNumericScale() {
- return getMaxScale(SqlTypeName.DECIMAL);
- }
-
@Override public int getMaxScale(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
@@ -11393,10 +11389,6 @@ Sql withPostgresqlModifiedDecimalTypeSystem() {
}
}
- @Override public int getMaxNumericPrecision() {
- return getMaxPrecision(SqlTypeName.DECIMAL);
- }
-
@Override public int getMaxPrecision(SqlTypeName typeName)
{
switch (typeName) {
case DECIMAL:
diff --git
a/core/src/test/java/org/apache/calcite/sql/type/RelDataTypeSystemTest.java
b/core/src/test/java/org/apache/calcite/sql/type/RelDataTypeSystemTest.java
index f21779f2c1..2a96292ead 100644
--- a/core/src/test/java/org/apache/calcite/sql/type/RelDataTypeSystemTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/type/RelDataTypeSystemTest.java
@@ -127,15 +127,15 @@ private static final class CustomTypeSystem extends
RelDataTypeSystemImpl {
return type1;
}
- @Override public int getMaxNumericPrecision() {
- return 38;
- }
-
@Override public int getMaxPrecision(SqlTypeName typeName) {
- if (typeName == SqlTypeName.TIMESTAMP) {
+ switch (typeName) {
+ case DECIMAL:
+ return 38;
+ case TIMESTAMP:
return CUSTOM_MAX_TIMESTAMP_PRECISION;
+ default:
+ return super.getMaxPrecision(typeName);
}
- return super.getMaxPrecision(typeName);
}
}
@@ -209,10 +209,6 @@ static class Fixture extends SqlTypeFixture {
* Custom type system class that overrides the default max precision and
max scale.
*/
final class CustomTypeSystem extends RelDataTypeSystemImpl {
- @Override public int getMaxNumericPrecision() {
- return getMaxPrecision(SqlTypeName.DECIMAL);
- }
-
@Override public int getMaxPrecision(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
@@ -222,10 +218,6 @@ final class CustomTypeSystem extends RelDataTypeSystemImpl
{
}
}
- @Override public int getMaxNumericScale() {
- return getMaxScale(SqlTypeName.DECIMAL);
- }
-
@Override public int getMaxScale(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
diff --git a/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
b/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
index ed93b27c3d..b413cc8b01 100644
--- a/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
+++ b/core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
@@ -530,11 +530,6 @@ public static class HiveLikeTypeSystem extends
RelDataTypeSystemImpl {
private HiveLikeTypeSystem() {}
- @Override public int getMaxNumericPrecision() {
- assert super.getMaxNumericPrecision() == 19;
- return getMaxPrecision(SqlTypeName.DECIMAL);
- }
-
@Override public int getMaxPrecision(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
@@ -550,11 +545,6 @@ private HiveLikeTypeSystem() {}
public static class HiveLikeTypeSystem2 extends RelDataTypeSystemImpl {
public HiveLikeTypeSystem2() {}
- @Override public int getMaxNumericPrecision() {
- assert super.getMaxNumericPrecision() == 19;
- return getMaxPrecision(SqlTypeName.DECIMAL);
- }
-
@Override public int getMaxPrecision(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL: