// select day(hireDate) + age * hour(seniorityStartTime), age
Query q = new Query();
// Add selection.
QuerySelection selection = new QuerySelection();
AbstractColumn col1 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(new SimpleColumn("hireDate")),
TimeComponentExtractor.getInstance(
TimeComponentExtractor.TimeComponent.DAY));
AbstractColumn col2 = new SimpleColumn("age");
AbstractColumn col3 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(
new SimpleColumn("seniorityStartTime")),
TimeComponentExtractor.getInstance(
TimeComponentExtractor.TimeComponent.HOUR));
AbstractColumn col4 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(col2, col3), Product.getInstance());
AbstractColumn col5 = new ScalarFunctionColumn(
Lists.<AbstractColumn>newArrayList(col1, col4), Sum.getInstance());
selection.addColumn(col5);
selection.addColumn(new SimpleColumn("age"));
q.setSelection(selection);
q.validate();
DataTable result = QueryEngine.executeQuery(q, res, ULocale.US);