private void populateCurrentRows()

in jdbc/src/main/java/software/amazon/timestream/jdbc/TimestreamArrayResultSet.java [85:142]


  private void populateCurrentRows(final List<Object> array) throws SQLException {
    for (int i = 0; i < array.size(); i++) {
      final Datum indexDatum = new Datum().withScalarValue(String.valueOf(i + 1));
      switch (this.timestreamDataType) {
        case ROW: {
          arrayResultSet.add(new Row().withData(
            indexDatum,
            new Datum().withRowValue(new Row().withData(((TimestreamStruct) array.get(i)).getStruct()))
          ));
          break;
        }

        case TIMESERIES: {
          arrayResultSet.add(new Row().withData(
            indexDatum,
            new Datum().withTimeSeriesValue((List<TimeSeriesDataPoint>) array.get(i))
          ));
          break;
        }

        case ARRAY: {
          final List<Datum> datumList = new ArrayList<>();
          datumList.add(indexDatum);
          for (Object o : array) {
            if (o instanceof TimestreamArray) {
              // The value is a TimestreamArray. This happens when we are inside a nested array.
              // We need to call `getArrayList` here to retrieve the parsed values in the
              // TimestreamArray.
              o = ((TimestreamArray) o).getArrayList();
            }

            final List<Datum> arrayValueList = new ArrayList<>();
            for (final Object val : ((List<Object>) o)) {
              arrayValueList.add(TimestreamDataType.createDatum(
                new Datum(),
                val,
                this.baseType.getArrayColumnInfo().getType()));
            }
            datumList.add(new Datum().withArrayValue(arrayValueList));

          }
          arrayResultSet.add(new Row().withData(datumList));
          break;
        }

        default: {
          arrayResultSet.add(new Row().withData(
            indexDatum,
            new Datum().withScalarValue(String.valueOf(array.get(i)))
          ));

          break;
        }
      }
    }

    this.rowItr = arrayResultSet.iterator();
  }