Package com.google.visualization.datasource.query

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


    QuerySelection selection = query.getSelection();
    QueryGroup group = query.getGroup();
    QueryPivot pivot = query.getPivot();
    assertEquals(Lists.newArrayList(new SimpleColumn("a, b"),
        new SimpleColumn("avg"),
        new AggregationColumn(new SimpleColumn("min"), AggregationType.MIN),
        new AggregationColumn(new SimpleColumn("max"), AggregationType.MAX)),
        selection.getColumns());
    assertEquals(Lists.newArrayList("a, b", "avg"), group.getColumnIds());
    assertEquals(Lists.newArrayList("count"), pivot.getColumnIds());
  }
View Full Code Here


  public void testSimpleGroupAndPivot() throws Exception {
    Query query = QueryBuilder.getInstance().parseQuery("select min(salary), "
        + "avg(height) group by dept, subdept pivot year, month");
    assertEquals(Lists.<AbstractColumn>newArrayList(
        new AggregationColumn(new SimpleColumn("salary"), AggregationType.MIN),
        new AggregationColumn(new SimpleColumn("height"), AggregationType.AVG)),
        query.getSelection().getColumns());
    assertEquals(Lists.newArrayList("dept", "subdept"),
        query.getGroup().getColumnIds());
    assertEquals(Lists.newArrayList("year", "month"),
        query.getPivot().getColumnIds());
View Full Code Here

  @Override
  public void setUp() throws Exception {
    q = new Query();
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new SimpleColumn("A"));
    selection.addColumn(new AggregationColumn(new SimpleColumn("B"), AggregationType.MAX));
    q.setSelection(selection);
    QuerySort sort = new QuerySort();
    sort.addSort(new ColumnSort(new SimpleColumn("A"), SortOrder.DESCENDING));
    q.setSort(sort);
    QueryFilter filter = new ColumnValueFilter(new SimpleColumn("A"), new TextValue("foo"),
View Full Code Here

   * Tests the query splitter with a datasource with SQL CapabilitySet, when the
   * query does not contain a pivot statement.
   */
  public void testSplitSQLWithoutPivot() throws Exception {
    q.setPivot(null);
    AggregationColumn maxB = new AggregationColumn(new SimpleColumn("B"), AggregationType.MAX);
    q.getLabels().addLabel(maxB, "maxBLabel");
    q.getUserFormatOptions().addPattern(maxB, "maxB#");
    QueryPair split = QuerySplitter.splitQuery(q, Capabilities.SQL);
    Query dataSourceQuery = split.getDataSourceQuery();
    Query completionQuery = split.getCompletionQuery();
View Full Code Here

    assertFalse(dataSourceQuery.hasPivot());
  }
 
  public void testSplittingSQLWithPivotWithLabel() throws Exception {
    QueryLabels labels = q.getLabels();
    labels.addLabel(new AggregationColumn(new SimpleColumn("B"), AggregationType.MAX), "bar");
    q.setLabels(labels);
    QueryPair split = QuerySplitter.splitQuery(q, Capabilities.SQL);
    Query dataSourceQuery = split.getDataSourceQuery();

    assertFalse(dataSourceQuery.hasSelection());
View Full Code Here

                    // 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

      columnId.append("`").append(abstractColumn.getId()).append("`");
    } else {
      // For aggregation column build the id from the aggregation type and the
      // column id (e.g. for aggregation type 'min' and column id 'salary', the
      // sql column id will be: min(`salary`);
      AggregationColumn aggregationColumn = (AggregationColumn) abstractColumn;
      columnId.append(getAggregationFunction(
          aggregationColumn.getAggregationType())).append("(`").
          append(aggregationColumn.getAggregatedColumn()).append("`)");
    }
    return columnId;
  }
View Full Code Here

        if(originalTable.containsColumn(column.getId())) {
            label.append(originalTable.getColumnDescription(column.getId()).getLabel());
        }
        else {
            if(column instanceof AggregationColumn) {
                AggregationColumn aggColumn = (AggregationColumn) column;
                label.append(aggColumn.getAggregationType().getCode()).append(" ").
                        append(originalTable.getColumnDescription(
                                aggColumn.getAggregatedColumn().getId()).getLabel());
            }
            else {
                ScalarFunctionColumn scalarFunctionColumn = (ScalarFunctionColumn) column;
                List<AbstractColumn> columns = scalarFunctionColumn.getColumns();
                label.append(scalarFunctionColumn.getFunction().getFunctionName()).append("(");
View Full Code Here

        ColumnDescription columnDescription = new ColumnDescription("id",
                ValueType.TEXT, "label");


        ColumnTitle columnTitleCount = new ColumnTitle(Lists.<Value>newArrayList(),
                new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.COUNT), false);

        ColumnTitle columnTitleMin = new ColumnTitle(Lists.<Value>newArrayList(),
                new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.MIN), true);

        ColumnTitle columnTitleCountWithPivot =
                new ColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.COUNT), false);

        ColumnTitle columnTitleMinWithPivot =
                new ColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new AggregationColumn(new SimpleColumn("id"),
                        AggregationType.MIN), true);


        ColumnDescription resultColumnDescriptionCount =
                columnTitleCount.createAggregationColumnDescription(columnDescription);
View Full Code Here

        table.addColumn(aggreationColumnDescription);

        List<AbstractColumn> simpleColumns =
                Lists.newArrayList((AbstractColumn) new SimpleColumn("simpleColumn"));
        List<AbstractColumn> aggregationColumns =
                Lists.newArrayList((AbstractColumn) new AggregationColumn(
                        new SimpleColumn("simpleColumn"), AggregationType.MIN));
        ScalarFunctionColumnTitle titleYear =
                new ScalarFunctionColumnTitle(Lists.<Value>newArrayList(),
                        new ScalarFunctionColumn(simpleColumns,
                                TimeComponentExtractor.getInstance(
View Full Code Here

TOP

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

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.