Package com.google.visualization.datasource.query

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


      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);
    } else {
      // When there is no pivoting, sql does everything (except options, labels, format).
      dataSourceQuery.copyFrom(query);
      dataSourceQuery.setOptions(null);
      completionQuery.setOptions(query.getOptions());
      try {
        if (query.hasLabels()) {
          dataSourceQuery.setLabels(null);
          QueryLabels labels = query.getLabels();
          QueryLabels newLabels = new QueryLabels();
          for (AbstractColumn column : labels.getColumns()) {
            newLabels.addLabel(new SimpleColumn(column.getId()), labels.getLabel(column));
          }
          completionQuery.setLabels(newLabels);
        }
        if (query.hasUserFormatOptions()) {
          dataSourceQuery.setUserFormatOptions(null);
          QueryFormat formats = query.getUserFormatOptions();
          QueryFormat newFormats = new QueryFormat();
          for (AbstractColumn column : formats.getColumns()) {
            newFormats.addPattern(new SimpleColumn(column.getId()), formats.getPattern(column));
          }
          completionQuery.setUserFormatOptions(newFormats);
        }
      } catch (InvalidQueryException e) {
        // Should not happen.
View Full Code Here


   * @return a negative integer, zero, or a positive integer as the first
   *     argument is less than, equal to, or greater than the second.
   */
  public int compare(TableRow r1, TableRow r2) {
    for (int i = 0; i < sortColumns.length; i++) {
      AbstractColumn col = sortColumns[i];
      int cc = valueComparator.compare(col.getValue(columnLookup, r1),
          col.getValue(columnLookup, r2));
      if (cc != 0) {
        return (sortColumnOrder[i] == SortOrder.ASCENDING) ? cc  : -cc;
      }
    }
    return 0;
View Full Code Here

// A comparison expression, i.e., a binary comparison operator between two
// operands that may be literals or column ids. Or an IS NULL or IS NOT NULL.
  final public QueryFilter primitiveFilter() throws ParseException, InvalidQueryException {
  QueryFilter filter;
  AbstractColumn col1;
  AbstractColumn col2;
  ComparisonFilter.Operator op;
  Value val;
    if (jj_2_3(2147483647)) {
      val = literal();
      op = comparisonOperator();
View Full Code Here

// An abstract column descriptor, i.e., either a column id, an aggregation
// function name followed by parentheses with column id (e.g., max(c1)) or a
// scalar function followed by parentheses with abstract columns
// (e.g., curr_time(), year(d1), year(sum(c1)), month(c2)), ....
  final public AbstractColumn abstractColumnDescriptor() throws ParseException, InvalidQueryException {
  AbstractColumn column;
  AbstractColumn result = null;
    if (jj_2_4(2)) {
      column = arithmeticExpression();
                                                     result = column;
    } else {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
View Full Code Here

// except it does not include arithmetic expressions like: c1+c2/c3*(c4+c5).
  final public AbstractColumn atomicAbstractColumnDescriptor() throws ParseException, InvalidQueryException {
  AggregationType aggregationType;
  ScalarFunction scalarFunction;
  String columnId;
  AbstractColumn column;
  ArrayList columns = new ArrayList();
  AbstractColumn result = null;
  Value value;
    if (jj_2_5(2)) {
      aggregationType = aggregationFunction();
      jj_consume_token(OP_LPAREN);
      columnId = columnId();
View Full Code Here

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

// An arithmetic expression, e.g., c1 + c2 / c1 * 3 - (c3 + c4).
  final public AbstractColumn arithmeticExpression() throws ParseException, InvalidQueryException {
  AbstractColumn column;
    column = possibleSummationOrSubtraction();
    {if (true) return column;}
    throw new Error("Missing return statement in function");
  }
View Full Code Here

// A possible sum or subtraction expression of possible multiplication or division expressions.
// It is "possible" because it can also match a single expression without any
// multiplications and divisions, and then it is just returned as is.
  final public AbstractColumn possibleSummationOrSubtraction() throws ParseException, InvalidQueryException {
  AbstractColumn column;
  AbstractColumn column1;
    column = possibleMultiplicationOrDivision();
    label_11:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OP_PLUS:
View Full Code Here

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

// A possible multiplication or division expression of atomic abstract column descriptors.
  final public AbstractColumn possibleMultiplicationOrDivision() throws ParseException, InvalidQueryException {
  AbstractColumn column;
  AbstractColumn column1;
    column = atomicAbstractColumnDescriptor();
    label_12:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OP_ASTERISK:
View Full Code Here

  }

// 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:
View Full Code Here

  }

// The group by clause (e.g. GROUP BY c1, c2)
  final public void groupByClause(Query query) throws ParseException, InvalidQueryException {
  QueryGroup group = new QueryGroup();
  AbstractColumn column;
    jj_consume_token(KW_GROUP);
    jj_consume_token(KW_BY);
    column = abstractColumnDescriptor();
    group.addColumn(column);
    label_2:
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.query.AbstractColumn

Copyright © 2018 www.massapicom. 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.