Examples of QuerySelection


Examples of com.google.visualization.datasource.query.QuerySelection

     */
    private static QueryPair splitSelect(Query query) {
        Query dataSourceQuery = new Query();
        Query completionQuery = new Query();
        if(query.getSelection() != null) {
            QuerySelection selection = new QuerySelection();
            for(String simpleColumnId : query.getAllColumnIds()) {
                selection.addColumn(new SimpleColumn(simpleColumnId));
            }
            // Column selection can be empty. For example, for query "SELECT 1".
            dataSourceQuery.setSelection(selection);
        }

View Full Code Here

Examples of com.google.visualization.datasource.query.QuerySelection

      QueryGroup group = new QueryGroup();
      for (AbstractColumn col : newGroupColumns) {
        group.addColumn(col);
      }
      dataSourceQuery.setGroup(group);
      QuerySelection selection = new QuerySelection();
      for (AbstractColumn col : newSelectionColumns) {
        selection.addColumn(col);
      }
      dataSourceQuery.setSelection(selection);

      // Build the completion query to group by the grouping columns. Because an aggregation is
      // required, make a dummy aggregation on the original column by which the aggregation is
      // required.
      // This original column must be unique for a given set of values for the grouping/pivoting
      // columns so any aggregation operation out of MIN, MAX, AVG will return the value
      // itself and will not aggregate anything. The example from before,
      // SELECT A, max(B) GROUP BY A PIVOT C turns into SELECT A, min(max-B) GROUP BY A PIVOT C

      completionQuery.copyFrom(query);
      completionQuery.setFilter(null);

      QuerySelection completionSelection = new QuerySelection();
      List<AbstractColumn> originalSelectedColumns =
          query.getSelection().getColumns();
      for (int i = 0; i < originalSelectedColumns.size(); i++) {
        AbstractColumn column = originalSelectedColumns.get(i);
        if (query.getGroup().getColumns().contains(column)) {
          completionSelection.addColumn(column);
        } else { // Must be an aggregation column if doesn't appear in the grouping.
          // The id here is the id generated by the data source for the column containing
          // the aggregated data, e.g., max-B.
          String id = column.getId();
          // MIN is chosen arbitrarily, because there will be exactly one.
          completionSelection.addColumn(
              new AggregationColumn(new SimpleColumn(id), AggregationType.MIN));
        }
      }

      completionQuery.setSelection(completionSelection);
View Full Code Here

Examples of com.google.visualization.datasource.query.QuerySelection

   */
  private static QueryPair splitSelect(Query query) {
    Query dataSourceQuery = new Query();
    Query completionQuery = new Query();
    if (query.getSelection() != null) {
      QuerySelection selection = new QuerySelection();
      for (String simpleColumnId : query.getAllColumnIds()) {
        selection.addColumn(new SimpleColumn(simpleColumnId));
      }
      // Column selection can be empty. For example, for query "SELECT 1".
      dataSourceQuery.setSelection(selection);
    }

View Full Code Here

Examples of com.google.visualization.datasource.query.QuerySelection

    throw new Error("Missing return statement in function");
  }

// The select clause (e.g., SELECT c1, c2)
  final public void selectClause(Query query) throws ParseException, InvalidQueryException {
  QuerySelection selection = new QuerySelection();
  AbstractColumn column;
    jj_consume_token(KW_SELECT);
    switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
    case KW_TRUE:
    case KW_FALSE:
    case KW_DATE:
    case KW_TIMEOFDAY:
    case KW_DATETIME:
    case KW_TIMESTAMP:
    case KW_MIN:
    case KW_MAX:
    case KW_AVG:
    case KW_COUNT:
    case KW_SUM:
    case KW_NO_VALUES:
    case KW_NO_FORMAT:
    case KW_IS:
    case KW_NULL:
    case KW_YEAR:
    case KW_MONTH:
    case KW_DAY:
    case KW_HOUR:
    case KW_MINUTE:
    case KW_SECOND:
    case KW_MILLISECOND:
    case KW_WITH:
    case KW_CONTAINS:
    case KW_STARTS:
    case KW_ENDS:
    case KW_MATCHES:
    case KW_LIKE:
    case KW_NOW:
    case KW_DATEDIFF:
    case KW_QUARTER:
    case KW_LOWER:
    case KW_UPPER:
    case KW_DAYOFWEEK:
    case KW_TODATE:
    case ID:
    case INTEGER_LITERAL:
    case DECIMAL_LITERAL:
    case STRING_LITERAL:
    case QUOTED_ID:
    case OP_LPAREN:
    case OP_MINUS:
      column = abstractColumnDescriptor();
       selection.addColumn(column);
      label_1:
      while (true) {
        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
        case OP_COMMA:
          ;
          break;
        default:
          jj_la1[10] = jj_gen;
          break label_1;
        }
        jj_consume_token(OP_COMMA);
        column = abstractColumnDescriptor();
           selection.addColumn(column);
      }
       query.setSelection(selection);
      break;
    case OP_ASTERISK:
      jj_consume_token(OP_ASTERISK);
View Full Code Here

Examples of com.google.visualization.datasource.query.QuerySelection

    if (!queryHasAggregation(query) || (table.getNumberOfRows() == 0)) {
      return table;
    }
    QueryGroup group = query.getGroup();
    QueryPivot pivot = query.getPivot();
    QuerySelection selection = query.getSelection();

    List<String> groupByIds = Lists.newArrayList();
    if (group != null) {
      groupByIds = group.getColumnIds();
    }

    List<String> pivotByIds = Lists.newArrayList();
    if (pivot != null) {
      pivotByIds = pivot.getColumnIds(); // contained in groupByIds
    }

    List<String> groupAndPivotIds = Lists.newArrayList(groupByIds);
    groupAndPivotIds.addAll(pivotByIds);

    List<AggregationColumn> tmpColumnAggregations = selection.getAggregationColumns();
    List<ScalarFunctionColumn> selectedScalarFunctionColumns = selection.getScalarFunctionColumns();
   
    // Remove duplicates from tmpColumnAggregations, creating columnAggregations:
    List<AggregationColumn> columnAggregations =
      Lists.newArrayListWithExpectedSize(tmpColumnAggregations.size());
    for (AggregationColumn aggCol : tmpColumnAggregations) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.