Examples of DataTable


Examples of com.google.visualization.datasource.datatable.DataTable

    ColumnDescription simpleColumnDescription =
        new ColumnDescription("simpleColumn", ValueType.DATE, "simpleLabel");
    ColumnDescription aggreationColumnDescription =
        new ColumnDescription("min-simpleColumn", ValueType.DATE,
            "aggLabel");
    DataTable table = new DataTable();
    table.addColumn(simpleColumnDescription);
    table.addColumn(aggreationColumnDescription);

    List<AbstractColumn> simpleColumns =
        Lists.newArrayList((AbstractColumn) new SimpleColumn("simpleColumn"));
    List<AbstractColumn> aggregationColumns =
        Lists.newArrayList((AbstractColumn) new AggregationColumn(
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

  }

  public void testLabels() throws Exception {
    Query query = new Query();

    DataTable data = MockDataSource.getData(0);

    QuerySelection selection = new QuerySelection();
    selection.addColumn(new SimpleColumn("name"));
    selection.addColumn(new SimpleColumn("isAlive"));
    query.setSelection(selection);

    QueryLabels labels = new QueryLabels();
    labels.addLabel(new SimpleColumn("isAlive"),
        "New isAlive Label");
    query.setLabels(labels);

    DataTable res = QueryEngine.executeQuery(query, data, ULocale.US);

    assertEquals("Pet Name", res.getColumnDescription("name").getLabel());
    assertEquals("New isAlive Label", res.getColumnDescription("isAlive").getLabel());
  }
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

    query.setLabels(labels);
    QueryFormat format = new QueryFormat();
    format.addPattern(selectedColumn, "'$'@@@");
    query.setUserFormatOptions(format);

    DataTable data = MockDataSource.getData(1);

    // Also tests different locale (note the commas in the numbers)
    DataTable res = QueryEngine.executeQuery(query, data, ULocale.FRENCH);

    List<ColumnDescription> columnDescriptions = res.getColumnDescriptions();
    assertEquals(5, columnDescriptions.size());
    assertEquals("", res.getRow(0).getCell(0).getFormattedValue()); // null
    assertEquals("$2,29", res.getRow(0).getCell(1).getFormattedValue());
    assertEquals("$1,14", res.getRow(0).getCell(2).getFormattedValue());
    assertEquals("$4,57", res.getRow(0).getCell(3).getFormattedValue());
    assertEquals("$0,571", res.getRow(0).getCell(4).getFormattedValue());
    assertEquals("Collection,2.0 foo", columnDescriptions.get(0).getLabel());
    assertEquals("Contraband,2.0 foo", columnDescriptions.get(1).getLabel());
    assertEquals("Contraband,4.0 foo", columnDescriptions.get(2).getLabel());
    assertEquals("Youthanasia,2.0 foo", columnDescriptions.get(3).getLabel());
    assertEquals("Youthanasia,4.0 foo", columnDescriptions.get(4).getLabel());
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

 
  // We used to have a bug with this throwing a runtime exception
  public void testAggregationAppearsTwice() throws Exception {
    Query q = QueryBuilder.getInstance().parseQuery("SELECT isAlive, sum(weight), sum(weight)+1"
        + " GROUP BY isAlive");
    DataTable data = MockDataSource.getData(0);
    DataTable res = QueryEngine.executeQuery(q, data, ULocale.US);
    assertEquals(2, res.getNumberOfRows());
    assertEquals("false", res.getRow(0).getCell(0).getValue().toString());
    assertEquals("2011.0", res.getRow(0).getCell(1).getValue().toString());
    assertEquals("2012.0", res.getRow(0).getCell(2).getValue().toString());
    assertEquals("true", res.getRow(1).getCell(0).getValue().toString());
    assertEquals("1567.0", res.getRow(1).getCell(1).getValue().toString());
    assertEquals("1568.0", res.getRow(1).getCell(2).getValue().toString());
  }
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

  }
 
  // Tests that the format operation saves the pattern on the column description.
  public void testFormatStoresPattern() throws Exception {
    Query q = QueryBuilder.getInstance().parseQuery("FORMAT weight 'a#'");
    DataTable data = MockDataSource.getData(0);
    DataTable res = QueryEngine.executeQuery(q, data, ULocale.US);
    assertEquals("a#", res.getColumnDescription("weight").getPattern());
  }
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

  }
 
  public void testQueryDoesntRuinDataSourcePatterns() throws Exception {
    Query q = QueryBuilder.getInstance().parseQuery("SELECT isAlive, weight WHERE height > 20 "
        + "ORDER BY weight LIMIT 3 OFFSET 2");
    DataTable data = MockDataSource.getData(0).clone();
    data.getColumnDescription("weight").setPattern("f#");
    DataTable res = QueryEngine.executeQuery(q, data, ULocale.US);
    assertEquals("f#", res.getColumnDescription("weight").getPattern());
  }
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

    assertEquals("f#", res.getColumnDescription("weight").getPattern());
  }

  public void testQueryWithLikeOperator() throws InvalidQueryException {
    Query q = QueryBuilder.getInstance().parseQuery("SELECT Band WHERE Band like 'Co%'");
    DataTable data = MockDataSource.getData(1).clone();
    DataTable res = QueryEngine.executeQuery(q, data, ULocale.US);
    assertEquals(28, res.getNumberOfRows());
    for (int i = 0; i < res.getNumberOfRows(); i++) {
      assertTrue(res.getValue(i, 0).toString().startsWith("Co"));
    }
  }
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

    }
  }
 
  public void testScalarFunctions() throws InvalidQueryException {
    Query q = QueryBuilder.getInstance().parseQuery("SELECT upper(name),salary format salary '$0'");
    DataTable data = MockDataSource.getData(3);
    DataTable res = QueryEngine.executeQuery(q, data, ULocale.US);
    assertEquals("JOHN", res.getValue(0, 0).toString());
    assertEquals("$1000", res.getCell(0, 1).getFormattedValue());
  }
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

    assertEquals("JOHN", res.getValue(0, 0).toString());
    assertEquals("$1000", res.getCell(0, 1).getFormattedValue());
  }

  public void testSkipping() throws Exception {
    DataTable res = MockDataSource.getData(1);
   
    // The returned mock data table should consist of 45 rows
    assertEquals(45, res.getNumberOfRows());
   
    Query q = QueryBuilder.getInstance().parseQuery("SELECT Year, Band, Songs SKIPPING 10");
   
    q.validate();

    DataTable result = QueryEngine.executeQuery(q, res, ULocale.US);

    // Test column description
    List<ColumnDescription> cols =  result.getColumnDescriptions();

    assertEquals(3, cols.size());
    assertEquals("Year", cols.get(0).getId());
    assertEquals("Band", cols.get(1).getId());
    assertEquals("Songs", cols.get(2).getId());
View Full Code Here

Examples of com.google.visualization.datasource.datatable.DataTable

    assertStringArraysEqual(new String[]{"2003", "Collection", "2.0"},
      resultStrings[4]);
  }
 
  public void testSkippingWithPagination() throws Exception {
    DataTable res = MockDataSource.getData(1);

    // The returned mock data table should consist of 45 rows
    assertEquals(45, res.getNumberOfRows());
   
    Query q = QueryBuilder.getInstance().parseQuery("SELECT Year, Band, Songs " +
        "SKIPPING 4 LIMIT 4 OFFSET 4");
   
    q.validate();

    DataTable result = QueryEngine.executeQuery(q, res, ULocale.US);

    // Test column description
    List<ColumnDescription> cols =  result.getColumnDescriptions();

    assertEquals(3, cols.size());
    assertEquals("Year", cols.get(0).getId());
    assertEquals("Band", cols.get(1).getId());
    assertEquals("Songs", cols.get(2).getId());
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.