in jdbc/src/main/java/software/amazon/timestream/jdbc/TimestreamDataType.java [305:347]
static ColumnInfo createColumnInfo(final ColumnInfo columnInfo, Type type, String name) {
if (type.getScalarType() != null) {
return columnInfo
.withName(type.getScalarType())
.withType(new Type().withScalarType(type.getScalarType()));
}
final ColumnInfo arrayColumnInfo = type.getArrayColumnInfo();
if (arrayColumnInfo != null) {
return columnInfo
.withName(name)
.withType(new Type().withArrayColumnInfo(createColumnInfo(
new ColumnInfo(),
arrayColumnInfo.getType(),
TimestreamDataType.ARRAY.name())));
}
final List<ColumnInfo> rowColumnInfo = type.getRowColumnInfo();
if (rowColumnInfo != null) {
return columnInfo
.withName(name)
.withType(new Type().withRowColumnInfo(
rowColumnInfo
.parallelStream()
.map(rowCol -> createColumnInfo(
new ColumnInfo(),
rowCol.getType(),
TimestreamDataType.ROW.name()))
.collect(Collectors.toList())));
}
final ColumnInfo timeSeriesColumnInfo = type.getTimeSeriesMeasureValueColumnInfo();
if (timeSeriesColumnInfo != null) {
return columnInfo
.withName(name)
.withType(new Type().withTimeSeriesMeasureValueColumnInfo(createColumnInfo(
new ColumnInfo(),
timeSeriesColumnInfo.getType(),
TimestreamDataType.TIMESERIES.name())));
}
throw new RuntimeException(Error.getErrorMessage(LOGGER, Error.INVALID_TYPE, type));
}