public static DataSchema canonicalizeDataSchemaForDistinct(QueryContext queryContext, DataSchema dataSchema) {
    List<ExpressionContext> selectExpressions = queryContext.getSelectExpressions();
    int numSelectExpressions = selectExpressions.size();
    Preconditions.checkState(dataSchema.size() == numSelectExpressions,
        "BUG: Expect same number of columns in SELECT clause and data schema, got %s in SELECT clause, %s in data "
            + "schema", numSelectExpressions, dataSchema.size());
    String[] columnNames = new String[numSelectExpressions];
    for (int i = 0; i < numSelectExpressions; i++) {
      columnNames[i] = selectExpressions.get(i).toString();
    }
    return new DataSchema(columnNames, dataSchema.getColumnDataTypes());
  }
@Test
  public void testCanonicalizeDataSchemaForDistinct() {
    QueryContext queryContext =
        QueryContextConverterUtils.getQueryContext("SELECT DISTINCT col1, col2 + col3 FROM testTable");
    // Intentionally make data schema not matching the string representation of the expression
    DataSchema dataSchema = new DataSchema(new String[]{"col1", "add(col2+col3)"},
        new ColumnDataType[]{ColumnDataType.INT, ColumnDataType.DOUBLE});
    DataSchema canonicalDataSchema = ReducerDataSchemaUtils.canonicalizeDataSchemaForDistinct(queryContext, dataSchema);
    assertEquals(canonicalDataSchema, new DataSchema(new String[]{"col1", "plus(col2,col3)"},
        new ColumnDataType[]{ColumnDataType.INT, ColumnDataType.DOUBLE}));
  }