in jdbc/src/main/java/software/amazon/timestream/jdbc/TimestreamStruct.java [236:266]
static List<Datum> populateObjectToDatum(Object[] attributes) throws SQLException {
final List<Datum> resultList = new ArrayList<>();
for (final Object attribute : attributes) {
if (attribute instanceof TimestreamStruct) {
resultList.add(new Datum()
.withRowValue(new Row()
.withData(((TimestreamStruct) attribute).getStruct())));
continue;
}
if (attribute instanceof TimestreamArray) {
// Check for situation when there is a nested TimeSeries object in an array.
if (JdbcType.JAVA_OBJECT.name().equals(((TimestreamArray) attribute).getBaseTypeName())) {
resultList.add(new Datum()
.withArrayValue((Datum) ((TimestreamArray) attribute).getTimestreamArray().get(0)));
continue;
}
final List<Object> nestedArray = TimestreamArray.populateArrayListToDatum(
((TimestreamArray) attribute).getArrayList(), (TimestreamArray) attribute);
resultList.add(new Datum().withArrayValue((List<Datum>) (List<?>) nestedArray));
continue;
}
// When there is TimeSeries object in array, it is wrapped up with an array list outside.
if (attribute instanceof ArrayList) {
resultList.add(new Datum()
.withTimeSeriesValue((List<TimeSeriesDataPoint>) attribute));
continue;
}
resultList.add(new Datum().withScalarValue(attribute.toString()));
}
return resultList;
}