Examples of SimpleColumn


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

    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

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

    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

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

    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

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

   * Test sorting by a number column.
   */
  public void testSortByNumberAscending() throws Exception {
    Query q = new Query();
    QuerySort sort = new QuerySort();
    sort.addSort(new ColumnSort(new SimpleColumn("weight"),
        SortOrder.ASCENDING));
    q.setSort(sort);
    DataTable res = QueryEngine.executeQuery(q, input, ULocale.US);

    assertEquals(3, res.getRows().size());
View Full Code Here

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

   * Test sorting by a number column.
   */
  public void testSortByNumberDescending() throws Exception {
    Query q = new Query();
    QuerySort sort = new QuerySort();
    sort.addSort(new ColumnSort(new SimpleColumn("weight"),
        SortOrder.DESCENDING));
    q.setSort(sort);
    DataTable res = QueryEngine.executeQuery(q, input, ULocale.US);

    assertEquals(3, res.getRows().size());
View Full Code Here

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

   * Test sorting by a text column.
   */
  public void testSortByTextAscending() throws Exception {
    Query q = new Query();
    QuerySort sort = new QuerySort();
    sort.addSort(new ColumnSort(new SimpleColumn("name"), SortOrder.ASCENDING));
    q.setSort(sort);
    DataTable res = QueryEngine.executeQuery(q, input, ULocale.US);

    assertEquals(3, res.getRows().size());
    assertEquals("aaa", res.getRows().get(0).getCells().get(0).toString());
View Full Code Here

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

   * Test sorting by a text column.
   */
  public void testSortByTextDescnding() throws Exception {
    Query q = new Query();
    QuerySort sort = new QuerySort();
    sort.addSort(new ColumnSort(new SimpleColumn("name"),
        SortOrder.DESCENDING));
    q.setSort(sort);
    DataTable res = QueryEngine.executeQuery(q, input, ULocale.US);

    assertEquals(3, res.getRows().size());
View Full Code Here

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

   * Test selection of the first col only.
   */
  public void testSelectionOfFirstCol() throws Exception {
    Query q = new Query();
    QuerySelection sel = new QuerySelection();
    sel.addColumn(new SimpleColumn("name"));
    q.setSelection(sel);
    DataTable res = QueryEngine.executeQuery(q, input, ULocale.US);
    List<ColumnDescription> cols = res.getColumnDescriptions();

    assertEquals(1, cols.size());
View Full Code Here

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

   * Test selection of all but the first col.
   */
  public void testSelectionOfAllButFirstCol() throws Exception {
    Query q = new Query();
    QuerySelection sel = new QuerySelection();
    sel.addColumn(new SimpleColumn("weight"));
    sel.addColumn(new SimpleColumn("isPig"));
    q.setSelection(sel);
    DataTable res = QueryEngine.executeQuery(q, input, ULocale.US);
    List<ColumnDescription> cols = res.getColumnDescriptions();

    assertEquals(2, cols.size());
View Full Code Here

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

   * Test sorting by a text column, while this is the only selected column.
   */
  public void testSelectionAndSortByTextDescending() throws Exception {
    Query q = new Query();
    QuerySort sort = new QuerySort();
    sort.addSort(new ColumnSort(new SimpleColumn("name"),
        SortOrder.DESCENDING));
    q.setSort(sort);

    QuerySelection selection = new QuerySelection();
    selection.addColumn(new SimpleColumn("name"));
    q.setSelection(selection);
    DataTable res = QueryEngine.executeQuery(q, input, ULocale.US);
    List<ColumnDescription> cols = res.getColumnDescriptions();

    assertEquals(1, cols.size());
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.