Package com.google.visualization.datasource.query

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


    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


    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

   */
  @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"),
                                               ComparisonFilter.Operator.GT);
    q.setFilter(filter);
    q.setRowLimit(7);
    q.setRowOffset(17);
    QueryLabels labels = new QueryLabels();
    labels.addLabel(new SimpleColumn("A"), "bar");
    q.setLabels(labels);
    QueryFormat format = new QueryFormat();
    format.addPattern(new SimpleColumn("A"), "foo");
    q.setUserFormatOptions(format);
    QueryOptions options = new QueryOptions();
    options.setNoFormat(true);
    q.setOptions(options);
    QueryGroup group = new QueryGroup();
    group.addColumn(new SimpleColumn("A"));
    q.setGroup(group);
    QueryPivot pivot = new QueryPivot();
    pivot.addColumn(new SimpleColumn("C"));
    q.setPivot(pivot);
  }
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

    q.setGroup(null);
    q.setFilter(null);
    q.setPivot(null);
    // Remove aggregation column:
    QuerySelection newSel = new QuerySelection();
    newSel.addColumn(new SimpleColumn("A"));
    q.setSelection(newSel);

    QueryPair split = QuerySplitter.splitQuery(q, Capabilities.SORT_AND_PAGINATION);
    Query dataSourceQuery = split.getDataSourceQuery();
    Query completionQuery = split.getCompletionQuery();
View Full Code Here

  /**
   * Tests the query splitter with a datasource with SQL/SORT_AND_PAGINATION
   * CapabilitySets, when the query contains a scalar function column.
   */
  public void testSplittingWithScalarFunctions() throws Exception {
    List<AbstractColumn> columnList = Lists.<AbstractColumn>newArrayList(new SimpleColumn("A"));
    q.setFilter(new ColumnIsNullFilter(new ScalarFunctionColumn(columnList,
        TimeComponentExtractor.getInstance(TimeComponentExtractor.TimeComponent.YEAR))));
   
    QueryPair split = QuerySplitter.splitQuery(q, Capabilities.SQL);
    Query dataSourceQuery = split.getDataSourceQuery();
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

   */
  public static DataTable executeQuery(Query query, DataTable table, ULocale locale) {
    ColumnIndices columnIndices = new ColumnIndices();
    List<ColumnDescription> columnsDescription = table.getColumnDescriptions();
    for (int i = 0; i < columnsDescription.size(); i++) {
      columnIndices.put(new SimpleColumn(columnsDescription.get(i).getId()), i);
    }

    // A map of column lookups by their list of pivot values. This is utilized in
    // the grouping and pivoting queries.
    TreeMap<List<Value>, ColumnLookup> columnLookups =
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

                    // 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 skipping, options, labels, format).
            dataSourceQuery.copyFrom(query);
            dataSourceQuery.setOptions(null);
            completionQuery.setOptions(query.getOptions());
            try {
                // If there is skipping pagination should be done in the completion query
                if(query.hasRowSkipping()) {
                    dataSourceQuery.setRowSkipping(0);
                    dataSourceQuery.setRowLimit(-1);
                    dataSourceQuery.setRowOffset(0);

                    completionQuery.copyRowSkipping(query);
                    completionQuery.copyRowLimit(query);
                    completionQuery.copyRowOffset(query);
                }
                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) {
View Full Code Here

TOP

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

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.