private void generateGet(EnumerableRelImplementor implementor,
PhysType physType, BlockBuilder builder, ParameterExpression resultSet_,
int i, Expression target, Expression calendar_,
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:
// We don't specify a calendar at all, so we don't add an argument and
// 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)));