Skip to content

Commit

Permalink
Reinstante deleted deprecated functions
Browse files Browse the repository at this point in the history
Signed-off-by: Mihai Budiu <[email protected]>
  • Loading branch information
mihaibudiu committed Nov 28, 2023
1 parent 01679c8 commit b719b3f
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,82 @@ public static long getMaxValue(RelDataType type) {
}
}

/** Returns whether a type has a representation as a Java primitive (ignoring
* nullability). */
@Deprecated // to be removed before 2.0
public static boolean isJavaPrimitive(RelDataType type) {
SqlTypeName typeName = type.getSqlTypeName();
if (typeName == null) {
return false;
}

switch (typeName) {
case BOOLEAN:
case TINYINT:
case SMALLINT:
case INTEGER:
case BIGINT:
case FLOAT:
case REAL:
case DOUBLE:
case SYMBOL:
return true;
default:
return false;
}
}

/** Returns the class name of the wrapper for the primitive data type. */
@Deprecated // to be removed before 2.0
public static @Nullable String getPrimitiveWrapperJavaClassName(@Nullable RelDataType type) {
if (type == null) {
return null;
}
SqlTypeName typeName = type.getSqlTypeName();
if (typeName == null) {
return null;
}

switch (typeName) {
case BOOLEAN:
return "Boolean";
default:
//noinspection deprecation
return getNumericJavaClassName(type);
}
}

/** Returns the class name of a numeric data type. */
@Deprecated // to be removed before 2.0
public static @Nullable String getNumericJavaClassName(@Nullable RelDataType type) {
if (type == null) {
return null;
}
SqlTypeName typeName = type.getSqlTypeName();
if (typeName == null) {
return null;
}

switch (typeName) {
case TINYINT:
return "Byte";
case SMALLINT:
return "Short";
case INTEGER:
return "Integer";
case BIGINT:
return "Long";
case REAL:
return "Float";
case DECIMAL:
case FLOAT:
case DOUBLE:
return "Double";
default:
return null;
}
}

private static boolean isAny(RelDataType t) {
return t.getFamily() == SqlTypeFamily.ANY;
}
Expand Down

0 comments on commit b719b3f

Please sign in to comment.