Package com.google.visualization.datasource.query

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


  }

  public void testOneValidLabelWithSingleQuote() throws Exception {
    Query query = QueryBuilder.getInstance().parseQuery("select c1 label c1 'Label 1' ");
    QueryLabels labels = query.getLabels();
    assertEquals("Label 1", labels.getLabel(new SimpleColumn("c1")));
  }
View Full Code Here


  public void testTwoValidLabels() throws Exception {
    Query query = QueryBuilder.getInstance().parseQuery(
        "select c1,c2 label c1 'Label 1', c2 'Label 2' ");
    QueryLabels labels = query.getLabels();
    assertEquals("Label 1", labels.getLabel(new SimpleColumn("c1")));
    assertEquals("Label 2", labels.getLabel(new SimpleColumn("c2")));
  }
View Full Code Here

  // FORMAT clause tests

  public void testOneValidFormatWithDoubleQuotes() throws Exception {
    Query query = QueryBuilder.getInstance().parseQuery("select c1 Format c1 \"Format 1\" ");
    QueryFormat formats = query.getUserFormatOptions();
    assertEquals("Format 1", formats.getPattern(new SimpleColumn("c1")));
  }
View Full Code Here

  }

  public void testOneValidFormatWithSingleQuote() throws Exception {
    Query query = QueryBuilder.getInstance().parseQuery("select c1 Format c1 'Format 1' ");
    QueryFormat formats = query.getUserFormatOptions();
    assertEquals("Format 1", formats.getPattern(new SimpleColumn("c1")));
  }
View Full Code Here

  public void testTwoValidFormats() throws Exception {
    Query query = QueryBuilder.getInstance().parseQuery(
        "select c1,c2 Format c1 'Format 1', c2 'Format 2' ");
    QueryFormat formats = query.getUserFormatOptions();
    assertEquals("Format 1", formats.getPattern(new SimpleColumn("c1")));
    assertEquals("Format 2", formats.getPattern(new SimpleColumn("c2")));
  }
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

  }

  public void testSelectionOfArithmeticExpressions() throws Exception {
    Query query = QueryBuilder.getInstance().parseQuery("SELECT ((c1+c2)/c3*c4)-(c5/c6+year(c7))");
    ScalarFunctionColumn col1 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c1"),
            new SimpleColumn("c2")), Sum.getInstance());
    ScalarFunctionColumn col2 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col1, new SimpleColumn("c3")),
        Quotient.getInstance());
    ScalarFunctionColumn col3 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col2, new SimpleColumn("c4")),
        Product.getInstance());
    ScalarFunctionColumn col4 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c5"),
            new SimpleColumn("c6")), Quotient.getInstance());
    ScalarFunctionColumn col5 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col4,
            new ScalarFunctionColumn(Lists.<AbstractColumn>newArrayList(
                new SimpleColumn("c7")), TimeComponentExtractor.getInstance(
                TimeComponentExtractor.TimeComponent.YEAR))),
        Sum.getInstance());
    ScalarFunctionColumn col6 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col3, col5),
        Difference.getInstance());
View Full Code Here

    QueryFilter f1 = subFilters.get(0);
    QueryFilter f2 = subFilters.get(1);

    // f1: ((c1+c2)/c3*c4) > (c5/c6+year(c7))
    ScalarFunctionColumn col1 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c1"),
            new SimpleColumn("c2")), Sum.getInstance());
    ScalarFunctionColumn col2 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col1, new SimpleColumn("c3")),
        Quotient.getInstance());
    ScalarFunctionColumn col3 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col2, new SimpleColumn("c4")),
        Product.getInstance());
    ScalarFunctionColumn col4 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c5"),
            new SimpleColumn("c6")), Quotient.getInstance());
    ScalarFunctionColumn col5 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col4,
            new ScalarFunctionColumn(Lists.<AbstractColumn>newArrayList(
                new SimpleColumn("c7")), TimeComponentExtractor.getInstance(
                TimeComponentExtractor.TimeComponent.YEAR))),
        Sum.getInstance());
    assertTrue(f1 instanceof ColumnColumnFilter);
    ColumnColumnFilter ccf = (ColumnColumnFilter) f1;
    assertEquals(col3, ccf.getFirstColumn());
    assertEquals(col5, ccf.getSecondColumn());

    // f2: (c8+c9=0 or c10<>c11)
    assertTrue(f2 instanceof CompoundFilter);
    CompoundFilter cf = (CompoundFilter) f2;
    assertEquals(CompoundFilter.LogicalOperator.OR, cf.getOperator());
    subFilters = cf.getSubFilters();
    assertEquals(2, subFilters.size());
    assertTrue(subFilters.get(0) instanceof ColumnValueFilter);
    assertTrue(subFilters.get(1) instanceof ColumnColumnFilter);
    assertEquals(new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c8"),
            new SimpleColumn("c9")), Sum.getInstance()),
        ((ColumnValueFilter) subFilters.get(0)).getColumn());
    assertEquals(new NumberValue(0),
        ((ColumnValueFilter) subFilters.get(0)).getValue());
    assertEquals(Sets.newHashSet("c10", "c11"),
        subFilters.get(1).getAllColumnIds());
View Full Code Here

    Query query = QueryBuilder.getInstance().parseQuery("order by ((c1+c2)/c3/c4)");
    QuerySort sort = query.getSort();
    List<ColumnSort> columnSorts = sort.getSortColumns();
    assertEquals(1, columnSorts.size());
    ScalarFunctionColumn col1 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c1"),
            new SimpleColumn("c2")), Sum.getInstance());
    ScalarFunctionColumn col2 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col1, new SimpleColumn("c3")),
        Quotient.getInstance());
    ScalarFunctionColumn col3 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col2, new SimpleColumn("c4")),
        Quotient.getInstance());
    assertEquals(col3, columnSorts.get(0).getColumn());
    assertEquals(SortOrder.ASCENDING, columnSorts.get(0).getOrder());
  }
View Full Code Here

    assertEquals(1, groupColumns.size());
    List<AbstractColumn> pivotColumns = pivot.getColumns();
    assertEquals(1, pivotColumns.size());

    ScalarFunctionColumn col1 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c1"),
            new SimpleColumn("c2")), Sum.getInstance());
    ScalarFunctionColumn col2 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col1, new SimpleColumn("c3")),
        Product.getInstance());
    ScalarFunctionColumn col3 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(col2, new SimpleColumn("c4")),
        Quotient.getInstance());
    assertEquals(col3,  groupColumns.get(0));

    ScalarFunctionColumn col4 = new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(new SimpleColumn("c5"),
            new SimpleColumn("c6")), Difference.getInstance());
    assertEquals(col4,  pivotColumns.get(0));
  }
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.