private Statistics buildStatistics(
      TsTableColumnCategory columnSchemaCategory,
      Statistics timeStatistics,
      Statistics[] valueStatistics,
      int columnIdx) {
    switch (columnSchemaCategory) {
      case TIME:
        return timeStatistics;
      case TAG:
        String id =
            getNthIdColumnValue(
                deviceEntries.get(currentDeviceIndex), aggColumnsIndexArray[columnIdx]);
        return getStatistics(
            timeStatistics, id == null ? null : new Binary(id, TSFileConfig.STRING_CHARSET));
      case ATTRIBUTE:
        Binary attr =
            deviceEntries.get(currentDeviceIndex)
                .getAttributeColumnValues()[aggColumnsIndexArray[columnIdx]];
        return getStatistics(timeStatistics, attr);
      case FIELD:
        return valueStatistics[aggColumnsIndexArray[columnIdx]];
      default:
        throw new IllegalStateException("Unsupported column type: " + columnSchemaCategory);
    }
  }
Calculate aggregation value on the time range from the tsBlock containing raw data.

@return left - whether the aggregation calculation of the current time range has done; right -
    remaining tsBlock
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/source/relational/AbstractAggTableScanOperator.java