use of org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlTypeNameTest method testSqlxml.
@Test
void testSqlxml() {
SqlTypeName tn = SqlTypeName.getNameForJdbcType(ExtraSqlTypes.SQLXML);
// SQLXML not supported yet
assertEquals(null, tn, "SQLXML maps to non-null type");
}
use of org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlTypeNameTest method testNumeric.
@Test
void testNumeric() {
SqlTypeName tn = SqlTypeName.getNameForJdbcType(Types.NUMERIC);
assertEquals(DECIMAL, tn, "NUMERIC did not map to DECIMAL");
}
use of org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlTypeNameTest method testFloat.
@Test
void testFloat() {
SqlTypeName tn = SqlTypeName.getNameForJdbcType(Types.FLOAT);
assertEquals(FLOAT, tn, "FLOAT did not map to FLOAT");
}
use of org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlTypeNameTest method testTimestamp.
@Test
void testTimestamp() {
SqlTypeName tn = SqlTypeName.getNameForJdbcType(Types.TIMESTAMP);
assertEquals(TIMESTAMP, tn, "TIMESTAMP did not map to TIMESTAMP");
}
use of org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class DruidQuery method isValidLeafCast.
/**
* Returns whether a {@link RexNode} is a valid Druid cast operation.
*
* @param rexNode RexNode
*
* @return whether the operand is an inputRef and it is a valid Druid Cast
* operation
*/
private static boolean isValidLeafCast(RexNode rexNode) {
assert rexNode.isA(SqlKind.CAST);
final RexNode input = ((RexCall) rexNode).getOperands().get(0);
if (!input.isA(SqlKind.INPUT_REF)) {
// it is not a leaf cast don't bother going further.
return false;
}
final SqlTypeName toTypeName = rexNode.getType().getSqlTypeName();
if (toTypeName.getFamily() == SqlTypeFamily.CHARACTER) {
// CAST of input to character type
return true;
}
if (toTypeName.getFamily() == SqlTypeFamily.NUMERIC) {
// CAST of input to numeric type, it is part of a bounded comparison
return true;
}
if (toTypeName.getFamily() == SqlTypeFamily.TIMESTAMP || toTypeName.getFamily() == SqlTypeFamily.DATETIME) {
// CAST of literal to timestamp type
return true;
}
if (toTypeName.getFamily().contains(input.getType())) {
// same type it is okay to push it
return true;
}
// Currently other CAST operations cannot be pushed to Druid
return false;
}
Aggregations