public static BaseResultsBlock buildEmptyQueryResults(QueryContext queryContext) {
    if (QueryContextUtils.isSelectionQuery(queryContext)) {
      return buildEmptySelectionQueryResults(queryContext);
    }
    if (QueryContextUtils.isAggregationQuery(queryContext)) {
      if (queryContext.getGroupByExpressions() == null) {
        return buildEmptyAggregationQueryResults(queryContext);
      } else {
        return buildEmptyGroupByQueryResults(queryContext);
      }
    }
    assert QueryContextUtils.isDistinctQuery(queryContext);
    return buildEmptyDistinctQueryResults(queryContext);
  }
@Test
  public void testBuildEmptyQueryResults()
      throws IOException {
    // Selection
    QueryContext queryContext = QueryContextConverterUtils.getQueryContext("SELECT * FROM testTable WHERE foo = 'bar'");
    DataTable dataTable = ResultsBlockUtils.buildEmptyQueryResults(queryContext).getDataTable();
    DataSchema dataSchema = dataTable.getDataSchema();
    assertEquals(dataSchema.getColumnNames(), new String[]{"*"});
    assertEquals(dataSchema.getColumnDataTypes(), new ColumnDataType[]{ColumnDataType.STRING});
    assertEquals(dataTable.getNumberOfRows(), 0);

    // Aggregation
    queryContext =
        QueryContextConverterUtils.getQueryContext("SELECT COUNT(*), SUM(a), MAX(b) FROM testTable WHERE foo = 'bar'");
    dataTable = ResultsBlockUtils.buildEmptyQueryResults(queryContext).getDataTable();
    dataSchema = dataTable.getDataSchema();
    assertEquals(dataSchema.getColumnNames(), new String[]{"count(*)", "sum(a)", "max(b)"});
    assertEquals(dataSchema.getColumnDataTypes(), new ColumnDataType[]{
        ColumnDataType.LONG, ColumnDataType.DOUBLE, ColumnDataType.DOUBLE
    });
    assertEquals(dataTable.getNumberOfRows(), 1);
    assertEquals(dataTable.getLong(0, 0), 0L);
    assertEquals(dataTable.getDouble(0, 1), 0.0);
    assertEquals(dataTable.getDouble(0, 2), Double.NEGATIVE_INFINITY);

    // Group-by
    queryContext = QueryContextConverterUtils.getQueryContext(
        "SELECT c, d, COUNT(*), SUM(a), MAX(b) FROM testTable WHERE foo = 'bar' GROUP BY c, d");
    dataTable = ResultsBlockUtils.buildEmptyQueryResults(queryContext).getDataTable();
    dataSchema = dataTable.getDataSchema();
    assertEquals(dataSchema.getColumnNames(), new String[]{"c", "d", "count(*)", "sum(a)", "max(b)"});
    assertEquals(dataSchema.getColumnDataTypes(), new ColumnDataType[]{
        ColumnDataType.STRING, ColumnDataType.STRING, ColumnDataType.LONG, ColumnDataType.DOUBLE, ColumnDataType.DOUBLE
    });
    assertEquals(dataTable.getNumberOfRows(), 0);

    // Distinct
    queryContext = QueryContextConverterUtils.getQueryContext("SELECT DISTINCT a, b FROM testTable WHERE foo = 'bar'");
    dataTable = ResultsBlockUtils.buildEmptyQueryResults(queryContext).getDataTable();
    dataSchema = dataTable.getDataSchema();
    assertEquals(dataSchema.getColumnNames(), new String[]{"a", "b"});
    assertEquals(dataSchema.getColumnDataTypes(), new ColumnDataType[]{
        ColumnDataType.STRING, ColumnDataType.STRING
    });
    assertEquals(dataTable.getNumberOfRows(), 0);
  }