public static Set<String> extractColumnsWithGranularity(TableConfig tableConfig) {
    if (tableConfig.getFieldConfigList() == null) {
      return Collections.emptySet();
    }
    Set<String> columnsWithGranularity = new HashSet<>();
    for (FieldConfig fieldConfig : tableConfig.getFieldConfigList()) {
      TimestampConfig timestampConfig = fieldConfig.getTimestampConfig();
      if (timestampConfig == null || CollectionUtils.isEmpty(timestampConfig.getGranularities())) {
        continue;
      }
      String timestampColumn = fieldConfig.getName();
      for (TimestampIndexGranularity granularity : timestampConfig.getGranularities()) {
        columnsWithGranularity.add(getColumnWithGranularity(timestampColumn, granularity));
      }
    }
    return columnsWithGranularity.isEmpty() ? Collections.emptySet() : columnsWithGranularity;
  }
@Test
  public void testExtractColumnsWithGranularity() {
    TableConfig tableConfig = new TableConfigBuilder(TableType.OFFLINE).setTableName("testTable").setFieldConfigList(
        Arrays.asList(
            new FieldConfig("ts1", FieldConfig.EncodingType.DICTIONARY, FieldConfig.IndexType.TIMESTAMP, null, null,
                new TimestampConfig(Arrays.asList(TimestampIndexGranularity.SECOND, TimestampIndexGranularity.MINUTE,
                    TimestampIndexGranularity.HOUR)), null),
            new FieldConfig("ts2", FieldConfig.EncodingType.RAW, FieldConfig.IndexType.TIMESTAMP, null, null,
                new TimestampConfig(Arrays.asList(TimestampIndexGranularity.HOUR, TimestampIndexGranularity.DAY,
                    TimestampIndexGranularity.WEEK)), null),
            new FieldConfig("ts3", FieldConfig.EncodingType.RAW, FieldConfig.IndexType.TIMESTAMP, null,
                FieldConfig.CompressionCodec.PASS_THROUGH, new TimestampConfig(
                Arrays.asList(TimestampIndexGranularity.WEEK, TimestampIndexGranularity.MONTH,
                    TimestampIndexGranularity.YEAR)), null))).build();
    Set<String> columnsWithGranularity = TimestampIndexUtils.extractColumnsWithGranularity(tableConfig);
    assertEquals(columnsWithGranularity, new HashSet<>(
        Arrays.asList("$ts1$SECOND", "$ts1$MINUTE", "$ts1$HOUR", "$ts2$HOUR", "$ts2$DAY", "$ts2$WEEK", "$ts3$WEEK",
            "$ts3$MONTH", "$ts3$YEAR")));
  }