Package com.google.visualization.datasource.query

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


    QuerySelection selection = new QuerySelection();
    selection.addColumn(new SimpleColumn("name"));
    selection.addColumn(new SimpleColumn("weight"));
    q.setSelection(selection);

    AbstractColumn col1 = new ScalarFunctionColumn(
      Lists.<AbstractColumn>newArrayList(), new Constant(new NumberValue(2)));
    AbstractColumn col2 = new ScalarFunctionColumn(
      Lists.<AbstractColumn>newArrayList(new SimpleColumn("weight"), col1),
      Modulo.getInstance());

    QueryFilter filter = new ColumnValueFilter(col2,
      new NumberValue(0), ComparisonFilter.Operator.EQ);
View Full Code Here


  public void testFormatAndLabelOnPivotColumns() throws Exception {
    Query query = new Query();
    QuerySelection selection = new QuerySelection(); // SELECT (sum(sales) / 7)
    List<AbstractColumn> columns = Lists.newArrayList();
    columns.add(new AggregationColumn(new SimpleColumn("Sales"), AggregationType.SUM));
    columns.add(new ScalarFunctionColumn(Lists.<AbstractColumn>newArrayList(),
        new Constant(new NumberValue(7))));
    AbstractColumn selectedColumn = new ScalarFunctionColumn(columns, Quotient.getInstance());
    selection.addColumn(selectedColumn);

    query.setSelection(selection);
    QueryGroup group = new QueryGroup();
    group.addColumn(new SimpleColumn("Year"));
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

                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("(");
                for(AbstractColumn abstractColumn : columns) {
                    label.append(getColumnDescriptionLabel(originalTable, abstractColumn));
                }
                label.append(")");
            }
View Full Code Here

        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(
                                        TimeComponentExtractor.TimeComponent.YEAR)));

        ScalarFunctionColumnTitle titleSecondWithAggregation =
                new ScalarFunctionColumnTitle(Lists.<Value>newArrayList(),
                        new ScalarFunctionColumn(aggregationColumns,
                                TimeComponentExtractor.getInstance(
                                        TimeComponentExtractor.TimeComponent.SECOND)));

        ScalarFunctionColumnTitle titleMonthWithPivot =
                new ScalarFunctionColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new ScalarFunctionColumn(simpleColumns,
                        TimeComponentExtractor.getInstance(
                                TimeComponentExtractor.TimeComponent.MONTH)));

        ScalarFunctionColumnTitle titleDayWithPivotAndAgg =
                new ScalarFunctionColumnTitle(Lists.newArrayList(new NumberValue(3.14),
                        BooleanValue.TRUE), new ScalarFunctionColumn(aggregationColumns,
                        TimeComponentExtractor.getInstance(
                                TimeComponentExtractor.TimeComponent.DAY)));

        ColumnDescription resultColumnDescriptionYear = titleYear.createColumnDescription(table);
View Full Code Here

        jj_consume_token(OP_COMMA);
        column = abstractColumnDescriptor();
            columns.add(column);
      }
      jj_consume_token(OP_RPAREN);
            result = new ScalarFunctionColumn(
              GenericsHelper.makeTypedList(columns), scalarFunction);
    } else {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OP_LPAREN:
        jj_consume_token(OP_LPAREN);
        column = abstractColumnDescriptor();
        jj_consume_token(OP_RPAREN);
         result = column;
        break;
      case KW_TRUE:
      case KW_FALSE:
      case KW_DATE:
      case KW_TIMEOFDAY:
      case KW_DATETIME:
      case KW_TIMESTAMP:
      case INTEGER_LITERAL:
      case DECIMAL_LITERAL:
      case STRING_LITERAL:
      case OP_MINUS:
        value = literal();
         result = new ScalarFunctionColumn(new ArrayList(),
           new Constant(value));
        break;
      case KW_MIN:
      case KW_MAX:
      case KW_AVG:
View Full Code Here

      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OP_PLUS:
        jj_consume_token(OP_PLUS);
        column1 = possibleMultiplicationOrDivision();
    column =
      new ScalarFunctionColumn(GenericsHelper.makeAbstractColumnList(
          new AbstractColumn[] {column, column1}), Sum.getInstance() );
        break;
      case OP_MINUS:
        jj_consume_token(OP_MINUS);
        column1 = possibleMultiplicationOrDivision();
    column =
      new ScalarFunctionColumn(GenericsHelper.makeAbstractColumnList(
          new AbstractColumn[]{column, column1}),
          Difference.getInstance());
        break;
      default:
        jj_la1[35] = jj_gen;
View Full Code Here

      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case OP_ASTERISK:
        jj_consume_token(OP_ASTERISK);
        column1 = atomicAbstractColumnDescriptor();
    column =
      new ScalarFunctionColumn(GenericsHelper.makeAbstractColumnList(
          new AbstractColumn[] {column, column1}), Product.getInstance() );
        break;
      case OP_SLASH:
        jj_consume_token(OP_SLASH);
        column1 = atomicAbstractColumnDescriptor();
    column =
      new ScalarFunctionColumn(GenericsHelper.makeAbstractColumnList(
          new AbstractColumn[]{column, column1}),
          Quotient.getInstance());
        break;
      default:
        jj_la1[37] = jj_gen;
View Full Code Here

        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("(");
        for (AbstractColumn abstractColumn : columns) {
          label.append(getColumnDescriptionLabel(originalTable, abstractColumn));
        }
        label.append(")");
      }
View Full Code Here

TOP

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

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.