use of org.embulk.spi.util.dynamic.LongColumnSetter in project embulk by embulk.
the class DynamicColumnSetterFactory method newColumnSetter.
public DynamicColumnSetter newColumnSetter(PageBuilder pageBuilder, Column column) {
Type type = column.getType();
if (type instanceof BooleanType) {
return new BooleanColumnSetter(pageBuilder, column, defaultValue);
} else if (type instanceof LongType) {
return new LongColumnSetter(pageBuilder, column, defaultValue);
} else if (type instanceof DoubleType) {
return new DoubleColumnSetter(pageBuilder, column, defaultValue);
} else if (type instanceof StringType) {
TimestampFormatter formatter = TimestampFormatter.of(getTimestampFormatForFormatter(column), getTimeZoneId(column));
return new StringColumnSetter(pageBuilder, column, defaultValue, formatter);
} else if (type instanceof TimestampType) {
// TODO use flexible time format like Ruby's Time.parse
final TimestampParser parser;
if (this.useColumnForTimestampMetadata) {
final TimestampType timestampType = (TimestampType) type;
// https://github.com/embulk/embulk/issues/935
parser = TimestampParser.of(getFormatFromTimestampTypeWithDepracationSuppressed(timestampType), getTimeZoneId(column));
} else {
parser = TimestampParser.of(getTimestampFormatForParser(column), getTimeZoneId(column));
}
return new TimestampColumnSetter(pageBuilder, column, defaultValue, parser);
} else if (type instanceof JsonType) {
TimestampFormatter formatter = TimestampFormatter.of(getTimestampFormatForFormatter(column), getTimeZoneId(column));
return new JsonColumnSetter(pageBuilder, column, defaultValue, formatter);
}
throw new ConfigException("Unknown column type: " + type);
}
Aggregations