return new MaterializedRow(prestoRow.getPrecision(), convertedValues);
private static MaterializedRow toTimeZone(MaterializedRow prestoRow, DateTimeZone oldTimeZone, DateTimeZone newTimeZone) { List<Object> values = new ArrayList<>(); for (int field = 0; field < prestoRow.getFieldCount(); field++) { Object value = prestoRow.getField(field); if (value instanceof Date) { long oldMillis = ((Date) value).getTime(); long newMillis = oldTimeZone.getMillisKeepLocal(newTimeZone, oldMillis); value = new Date(newMillis); } values.add(value); } return new MaterializedRow(prestoRow.getPrecision(), values); }
private static MaterializedRow convertToJdbcTypes(MaterializedRow prestoRow) { List<Object> jdbcValues = new ArrayList<>(); for (int field = 0; field < prestoRow.getFieldCount(); field++) { Object prestoValue = prestoRow.getField(field); Object jdbcValue; if (prestoValue instanceof SqlDate) { int days = ((SqlDate) prestoValue).getDays(); jdbcValue = new Date(TimeUnit.DAYS.toMillis(days)); } else if (prestoValue instanceof SqlTime) { jdbcValue = new Time(((SqlTime) prestoValue).getMillisUtc()); } else if (prestoValue instanceof SqlTimeWithTimeZone) { jdbcValue = new Time(((SqlTimeWithTimeZone) prestoValue).getMillisUtc()); } else if (prestoValue instanceof SqlTimestamp) { jdbcValue = new Timestamp(((SqlTimestamp) prestoValue).getMillisUtc()); } else if (prestoValue instanceof SqlTimestampWithTimeZone) { jdbcValue = new Timestamp(((SqlTimestampWithTimeZone) prestoValue).getMillisUtc()); } else { jdbcValue = prestoValue; } jdbcValues.add(jdbcValue); } return new MaterializedRow(prestoRow.getPrecision(), jdbcValues); }
.map(row -> new MaterializedRow(row.getPrecision(), newArrayList(concat(row.getFields(), ImmutableList.of("2015-07-0" + row.getField(0)))))) .collect(toList()), ImmutableList.<Type>builder()