Source:
public static Datum cast(Datum operandDatum, DataType target, @Nullable TimeZone tz) { switch (target.getType()) { case BOOLEAN: return DatumFactory.createBool(operandDatum.asBool()); case CHAR: return DatumFactory.createChar(operandDatum.asChar()); case INT1: case INT2: return DatumFactory.createInt2(operandDatum.asInt2()); case INT4: return DatumFactory.createInt4(operandDatum.asInt4()); case INT8: return DatumFactory.createInt8(operandDatum.asInt8()); case FLOAT4: return DatumFactory.createFloat4(operandDatum.asFloat4()); case FLOAT8: return DatumFactory.createFloat8(operandDatum.asFloat8()); case VARCHAR: case TEXT: switch (operandDatum.type()) { case TIMESTAMP: { TimestampDatum timestampDatum = (TimestampDatum)operandDatum; if (tz != null) { return DatumFactory.createText(TimestampDatum.asChars(operandDatum.asTimeMeta(), tz, false)); } else { return DatumFactory.createText(timestampDatum.asChars()); } } case TIME: { TimeDatum timeDatum = (TimeDatum)operandDatum; if (tz != null) { return DatumFactory.createText(TimeDatum.asChars(operandDatum.asTimeMeta(), tz, false)); } else { return DatumFactory.createText(timeDatum.asChars()); } } default: return DatumFactory.createText(operandDatum.asTextBytes()); } case DATE: return DatumFactory.createDate(operandDatum); case TIME: return DatumFactory.createTime(operandDatum, tz); case TIMESTAMP: return DatumFactory.createTimestamp(operandDatum, tz); case BLOB: return DatumFactory.createBlob(operandDatum.asByteArray()); case INET4: return DatumFactory.createInet4(operandDatum.asByteArray()); case ANY: return DatumFactory.createAny(operandDatum); default: throw new TajoRuntimeException(Errors.ResultCode.INVALID_CAST, operandDatum.type().name(), target.getType().name()); } }

Target:
public static Datum cast(Datum operandDatum, DataType target, @Nullable TimeZone tz) { switch (target.getType()) { case BOOLEAN: return DatumFactory.createBool(operandDatum.asBool()); case CHAR: return DatumFactory.createChar(operandDatum.asChar()); case INT1: case INT2: return DatumFactory.createInt2(operandDatum.asInt2()); case INT4: return DatumFactory.createInt4(operandDatum.asInt4()); case INT8: return DatumFactory.createInt8(operandDatum.asInt8()); case FLOAT4: return DatumFactory.createFloat4(operandDatum.asFloat4()); case FLOAT8: return DatumFactory.createFloat8(operandDatum.asFloat8()); case VARCHAR: case TEXT: switch (operandDatum.type()) { case TIMESTAMP: { TimestampDatum timestampDatum = (TimestampDatum)operandDatum; if (tz != null) { return DatumFactory.createText(TimestampDatum.asChars(operandDatum.asTimeMeta(), tz, false)); } else { return DatumFactory.createText(timestampDatum.asChars()); } } case TIME: { TimeDatum timeDatum = (TimeDatum)operandDatum; if (tz != null) { return DatumFactory.createText(TimeDatum.asChars(operandDatum.asTimeMeta(), tz, false)); } else { return DatumFactory.createText(timeDatum.asChars()); } } default: return DatumFactory.createText(operandDatum.asTextBytes()); } case DATE: return DatumFactory.createDate(operandDatum); case TIME: return DatumFactory.createTime(operandDatum, tz); case TIMESTAMP: return DatumFactory.createTimestamp(operandDatum, tz); case BLOB: return DatumFactory.createBlob(operandDatum.asByteArray()); case INET4: return DatumFactory.createInet4(operandDatum.asByteArray()); case ANY: return DatumFactory.createAny(operandDatum); default: throw new TajoRuntimeException(new InvalidCastException(operandDatum.type(), target.getType())); } }