Examples of SimpleColumn


Examples of adipe.translate.sql.SimpleColumn

        q2          = schema.schemaTable("xy");
        new_p       = schema.schemaTable("p");
        withAmbiguousColumnNames = schema3.schemaTable("withAmbiguousColumnNames");
        withAliases = new ColumnNamesImpl();
        withAliases.addColumn("alias_r", new SimpleColumn(AnyType.INSTANCE, "r"));

        scope1 = new ColumnScope(null);
        scope2 = new ColumnScope(scope1);

        scope2.addTable("alias_p",  alias_p);
View Full Code Here

Examples of adipe.translate.sql.SimpleColumn

            if (bothColumnsFromSameOperand) {
                pIsEq = false;
            } else if (isInnerJoin) {
                index2 = index2 - r1.relation().columns().size();

                SimpleColumn replacedColumn = r2.relation().columns().get(index2 - 1);
                SimpleColumn replacedBy = r1.relation().columns().get(index1 - 1);
                for (ColumnNamesImpl cibn : relationsFound.values()) {
                    // TODO improve time complexity
                    cibn.replace(replacedColumn, replacedBy);
                }
                named.replace(replacedColumn, replacedBy);
View Full Code Here

Examples of ar.com.fdvs.dj.domain.entities.columns.SimpleColumn

  /**
   * For creating regular columns
   * @return
   */
  protected AbstractColumn buildSimpleColumn() {
    SimpleColumn column = new SimpleColumn();
    populateCommonAttributes(column);
    columnProperty.getFieldProperties().putAll(fieldProperties);
    column.setColumnProperty(columnProperty);
    column.setExpressionToGroupBy(customExpressionToGroupBy);
    column.setFieldDescription(fieldDescription);
    return column;
  }
View Full Code Here

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

    // select sum(age), count(dept), hour(lunchTime) group by hour(lunchtime)
    Query q = new Query();

    // Add selection.
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("age"),
        AggregationType.SUM));
    selection.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    selection.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setSelection(selection);

    // Add group.
    QueryGroup group = new QueryGroup();
    group.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setGroup(group);

    q.validate();

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

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

    assertEquals(3, cols.size());
    assertEquals("sum-age", cols.get(0).getId());
    assertEquals("count-dept", cols.get(1).getId());
    assertEquals("hour_lunchTime", cols.get(2).getId());

    String[][] resultStrings = MockDataSource.queryResultToStringMatrix(result);
    assertEquals(2, resultStrings.length);

    assertStringArraysEqual(new String[]{"119.0", "4.0", "12.0"},
        resultStrings[0]);
    assertStringArraysEqual(new String[]{"54.0", "2.0", "13.0"},
        resultStrings[1]);

    // Select sum(age), count(name), datediff(hireDate, seniorityStartTime),
    // dept group by datediff(hireDate, seniorityStartTime), dept.
    q = new Query();

    // Add selection.
    selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("age"),
        AggregationType.SUM));
    selection.addColumn(new AggregationColumn(new SimpleColumn("name"),
        AggregationType.COUNT));
    selection.addColumn(new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(
            new SimpleColumn("seniorityStartTime"),
            new SimpleColumn("hireDate")), DateDiff.getInstance()));
    selection.addColumn(new SimpleColumn("dept"));
    q.setSelection(selection);

    // Add group.
    group = new QueryGroup();
    group.addColumn(new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(
            new SimpleColumn("seniorityStartTime"),
            new SimpleColumn("hireDate")), DateDiff.getInstance()));
    group.addColumn(new SimpleColumn("dept"));
    q.setGroup(group);

    q.validate();

    result = QueryEngine.executeQuery(q, res.clone(), ULocale.US);
View Full Code Here

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

    // select sum(age), count(dept) pivot hour(lunchtime)
    Query q = new Query();

    // Add selection.
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("age"),
        AggregationType.SUM));
    selection.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    q.setSelection(selection);

    // Add pivot.
    QueryPivot pivot = new QueryPivot();
    pivot.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setPivot(pivot);

    q.validate();
    DataTable result = QueryEngine.executeQuery(q, res.clone(), ULocale.US);
    // Test column description
    List<ColumnDescription> cols = result.getColumnDescriptions();

    assertEquals(4, cols.size());
    assertEquals("12.0 sum-age", cols.get(0).getId());
    assertEquals("13.0 sum-age", cols.get(1).getId());
    assertEquals("12.0 count-dept", cols.get(2).getId());
    assertEquals("13.0 count-dept", cols.get(3).getId());

    String[][] resultStrings = MockDataSource.queryResultToStringMatrix(result);
    assertEquals(1, resultStrings.length);

    assertStringArraysEqual(new String[]{"119.0", "54.0", "4.0", "2.0"},
        resultStrings[0]);

    // select count(dept) pivot hour(lunchtime), datediff(hireDate,
    // seniorityStartTime)
    Query q1 = new Query();

    // Add selection.
    QuerySelection selection1 = new QuerySelection();
    selection1.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    q1.setSelection(selection1);

    // Add pivot.
    QueryPivot pivot1 = new QueryPivot();
    pivot1.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    pivot1.addColumn(new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(
            new SimpleColumn("seniorityStartTime"),
            new SimpleColumn("hireDate")), DateDiff.getInstance()));
    q1.setPivot(pivot1);

    q1.validate();

    DataTable result1 = QueryEngine.executeQuery(q1, res.clone(), ULocale.US);
View Full Code Here

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

    // pivot isSenior.
    Query q = new Query();

    // Add selection.
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("age"),
        AggregationType.SUM));
    selection.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    selection.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setSelection(selection);

    // Add group.
    QueryGroup group = new QueryGroup();
    group.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setGroup(group);

    // Add pivot.
    QueryPivot pivot = new QueryPivot();
    pivot.addColumn(new SimpleColumn("isSenior"));
    q.setPivot(pivot);

    q.validate();

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

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

    assertEquals(5, cols.size());
    assertEquals("false sum-age", cols.get(0).getId());
    assertEquals("true sum-age", cols.get(1).getId());
    assertEquals("false count-dept", cols.get(2).getId());
    assertEquals("true count-dept", cols.get(3).getId());
    assertEquals("hour_lunchTime", cols.get(4).getId());

    String[][] resultStrings = MockDataSource.queryResultToStringMatrix(result);
    assertEquals(2, resultStrings.length);

    assertStringArraysEqual(new String[]{"52.0", "67.0", "2.0", "2.0", "12.0"},
        resultStrings[0]);
    assertStringArraysEqual(new String[]{"30.0", "24.0", "1.0", "1.0", "13.0"},
        resultStrings[1]);

    res = MockDataSource.getData(3);

    // select count(dept), datediff(hireDate, seniorityStartTime) group by
    // datediff(hireDate, seniorityStartTime) pivot isSenior.
    q = new Query();

    // Add selection.
    selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    selection.addColumn(new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(
            new SimpleColumn("seniorityStartTime"),
            new SimpleColumn("hireDate")), DateDiff.getInstance()));
    q.setSelection(selection);

    // Add group.
    group = new QueryGroup();
    group.addColumn(new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(
            new SimpleColumn("seniorityStartTime"),
            new SimpleColumn("hireDate")), DateDiff.getInstance()));
    q.setGroup(group);

    // Add pivot.
    pivot = new QueryPivot();
    pivot.addColumn(new SimpleColumn("isSenior"));
    q.setPivot(pivot);

    q.validate();

    result = QueryEngine.executeQuery(q, res, ULocale.US);
View Full Code Here

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

    // select sum(age), count(dept) group by isSenior pivot hour(lunchtime)
    Query q = new Query();

    // Add selection.
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("age"),
        AggregationType.SUM));
    selection.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    selection.addColumn(new SimpleColumn("isSenior"));
    q.setSelection(selection);

    // Add Group.
    QueryGroup group = new QueryGroup();
    group.addColumn(new SimpleColumn("isSenior"));
    q.setGroup(group);

    // Add pivot.
    QueryPivot pivot = new QueryPivot();
    pivot.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setPivot(pivot);

    q.validate();

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

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

    assertEquals(5, cols.size());
    assertEquals("12.0 sum-age", cols.get(0).getId());
    assertEquals("13.0 sum-age", cols.get(1).getId());
    assertEquals("12.0 count-dept", cols.get(2).getId());
    assertEquals("13.0 count-dept", cols.get(3).getId());
    assertEquals("isSenior", cols.get(4).getId());

    String[][] resultStrings = MockDataSource.queryResultToStringMatrix(result);
    assertEquals(2, resultStrings.length);

    assertStringArraysEqual(new String[]{"52.0", "30.0", "2.0", "1.0",
        "false"}, resultStrings[0]);
    assertStringArraysEqual(new String[]{"67.0", "24.0", "2.0", "1.0",
        "true"}, resultStrings[1]);

    // selectcount(dept) group by isSenior pivot datediff(hireDate,
    // seniorityStartTime)
    q = new Query();
    res = MockDataSource.getData(3);

    // Add selection.
    selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    selection.addColumn(new SimpleColumn("isSenior"));
    q.setSelection(selection);

    // Add Group.
    group = new QueryGroup();
    group.addColumn(new SimpleColumn("isSenior"));
    q.setGroup(group);

    // Add pivot.
    pivot = new QueryPivot();
    pivot.addColumn(new ScalarFunctionColumn(
        Lists.<AbstractColumn>newArrayList(
            new SimpleColumn("seniorityStartTime"),
            new SimpleColumn("hireDate")), DateDiff.getInstance()));
    q.setPivot(pivot);

    q.validate();

    result = QueryEngine.executeQuery(q, res, ULocale.US);
View Full Code Here

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

    // year(seniorityStartTime) pivot hour(lunchtime)
    Query q = new Query();

    // Add selection.
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("dept"),
        AggregationType.COUNT));
    selection.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn)
            new SimpleColumn("seniorityStartTime")), TimeComponentExtractor.
        getInstance(TimeComponentExtractor.TimeComponent.YEAR)));

    q.setSelection(selection);

    // Add Group.
    QueryGroup group = new QueryGroup();
    group.addColumn(new ScalarFunctionColumn(Lists.newArrayList((AbstractColumn)
        new SimpleColumn("seniorityStartTime")), TimeComponentExtractor.
        getInstance(TimeComponentExtractor.TimeComponent.YEAR)));
    q.setGroup(group);

    // Add pivot.
    QueryPivot pivot = new QueryPivot();
    pivot.addColumn(new ScalarFunctionColumn(Lists.newArrayList(
        (AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setPivot(pivot);

    q.validate();
View Full Code Here

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

    DataTable res = MockDataSource.getData(3);

    // select name, dept, hour(lunchTime)
    Query q = new Query();
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new SimpleColumn("name"));
    selection.addColumn(new SimpleColumn("dept"));
    selection.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));

    q.setSelection(selection);
    q.validate();
View Full Code Here

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

    // select sum(age), dept, hour(min(lunchTime)) group by dept
    Query q = new Query();

    // Add selection.
    QuerySelection selection = new QuerySelection();
    selection.addColumn(new AggregationColumn(new SimpleColumn("age"),
        AggregationType.SUM));
    selection.addColumn(new SimpleColumn("dept"));
    selection.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new AggregationColumn(
            new SimpleColumn("lunchTime"), AggregationType.MIN)),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setSelection(selection);

    // Add group.
    QueryGroup group = new QueryGroup();
    group.addColumn(new SimpleColumn("dept"));
    q.setGroup(group);

    q.validate();

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

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

    assertEquals(3, cols.size());
    assertEquals("sum-age", cols.get(0).getId());
    assertEquals("dept", cols.get(1).getId());
    assertEquals("hour_min-lunchTime", cols.get(2).getId());

    String[][] resultStrings = MockDataSource.queryResultToStringMatrix(result);
    assertEquals(3, resultStrings.length);

    assertStringArraysEqual(new String[]{"92.0", "Eng", "12.0"},
        resultStrings[0]);
    assertStringArraysEqual(new String[]{"24.0", "Marketing", "13.0"},
        resultStrings[1]);
    assertStringArraysEqual(new String[]{"57.0", "Sales", "12.0"},
        resultStrings[2]);

    // Test group-by column with scalar function in the selection:
    // select count(name), hour(lunchTime) group by lunchtime
    q = new Query();
    // Add selection
    QuerySelection selection1 = new QuerySelection();
    selection1.addColumn(new AggregationColumn(new SimpleColumn("name"),
        AggregationType.COUNT));
    selection1.addColumn(new ScalarFunctionColumn(
        Lists.newArrayList((AbstractColumn) new SimpleColumn("lunchTime")),
        TimeComponentExtractor.getInstance(
            TimeComponentExtractor.TimeComponent.HOUR)));
    q.setSelection(selection1);

    // Add group.
    QueryGroup group1 = new QueryGroup();
    group1.addColumn(new SimpleColumn("lunchTime"));
    q.setGroup(group1);

    q.validate();

    DataTable result1 = QueryEngine.executeQuery(q, res, ULocale.US);
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.