Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -11393,10 +11389,6 @@ Sql withPostgresqlModifiedDecimalTypeSystem() {
}
}

@Override public int getMaxNumericPrecision() {
return getMaxPrecision(SqlTypeName.DECIMAL);
}

@Override public int getMaxPrecision(SqlTypeName typeName) {
switch (typeName) {
case DECIMAL:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions core/src/test/java/org/apache/calcite/tools/FrameworksTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Loading