use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class JdbcToEnumerableConverter method generateGet.
private void generateGet(EnumerableRelImplementor implementor, PhysType physType, BlockBuilder builder, ParameterExpression resultSet_, int i, Expression target, Expression calendar_, SqlDialect.CalendarPolicy calendarPolicy) {
final Primitive primitive = Primitive.ofBoxOr(physType.fieldClass(i));
final RelDataType fieldType = physType.getRowType().getFieldList().get(i).getType();
final List<Expression> dateTimeArgs = new ArrayList<Expression>();
dateTimeArgs.add(Expressions.constant(i + 1));
SqlTypeName sqlTypeName = fieldType.getSqlTypeName();
boolean offset = false;
switch(calendarPolicy) {
case LOCAL:
dateTimeArgs.add(calendar_);
break;
case NULL:
// instead use the version of the getXXX that doesn't take a Calendar
break;
case DIRECT:
sqlTypeName = SqlTypeName.ANY;
break;
case SHIFT:
switch(sqlTypeName) {
case TIMESTAMP:
case DATE:
offset = true;
}
break;
}
final Expression source;
switch(sqlTypeName) {
case DATE:
case TIME:
case TIMESTAMP:
source = Expressions.call(getMethod(sqlTypeName, fieldType.isNullable(), offset), Expressions.<Expression>list().append(Expressions.call(resultSet_, getMethod2(sqlTypeName), dateTimeArgs)).appendIf(offset, getTimeZoneExpression(implementor)));
break;
case ARRAY:
final Expression x = Expressions.convert_(Expressions.call(resultSet_, jdbcGetMethod(primitive), Expressions.constant(i + 1)), java.sql.Array.class);
source = Expressions.call(BuiltInMethod.JDBC_ARRAY_TO_LIST.method, x);
break;
default:
source = Expressions.call(resultSet_, jdbcGetMethod(primitive), Expressions.constant(i + 1));
}
builder.add(Expressions.statement(Expressions.assign(target, source)));
// object
if (primitive != null) {
builder.add(Expressions.ifThen(Expressions.call(resultSet_, "wasNull"), Expressions.statement(Expressions.assign(target, Expressions.constant(null)))));
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlLiteralChainOperator method inferReturnType.
// Result type is the same as all the args, but its size is the
// total size.
// REVIEW mb 8/8/04: Possibly this can be achieved by combining
// the strategy useFirstArgType with a new transformer.
public RelDataType inferReturnType(SqlOperatorBinding opBinding) {
// Here we know all the operands have the same type,
// which has a size (precision), but not a scale.
RelDataType ret = opBinding.getOperandType(0);
SqlTypeName typeName = ret.getSqlTypeName();
assert typeName.allowsPrecNoScale() : "LiteralChain has impossible operand type " + typeName;
int size = 0;
for (RelDataType type : opBinding.collectOperandTypes()) {
size += type.getPrecision();
assert type.getSqlTypeName() == typeName;
}
return opBinding.getTypeFactory().createSqlType(typeName, size);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlTypeNameTest method testStruct.
@Test
public void testStruct() {
SqlTypeName tn = SqlTypeName.getNameForJdbcType(Types.STRUCT);
assertEquals("STRUCT did not map to null", SqlTypeName.STRUCTURED, tn);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlTypeNameTest method testVarchar.
@Test
public void testVarchar() {
SqlTypeName tn = SqlTypeName.getNameForJdbcType(Types.VARCHAR);
assertEquals("VARCHAR did not map to VARCHAR", SqlTypeName.VARCHAR, tn);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.type.SqlTypeName in project calcite by apache.
the class SqlTypeNameTest method testDouble.
@Test
public void testDouble() {
SqlTypeName tn = SqlTypeName.getNameForJdbcType(Types.DOUBLE);
assertEquals("DOUBLE did not map to DOUBLE", SqlTypeName.DOUBLE, tn);
}
Aggregations