_subQuerySelectItem null

1 view
Skip to first unread message

Paritosh Ranjan

unread,
Dec 7, 2010, 4:33:37 AM12/7/10
to DataCleaner-dev
I have a MetaModelInputColumn from table:

table = schema.getTableByName("DATASET");

Column[]_columns = table.getColumns();
MetaModelInputColumn[] metaModelInputColumns = new
MetaModelInputColumn[_columns.length];
for (int i = 0; i < _columns.length; i++) {
metaModelInputColumns[i] = new MetaModelInputColumn(_columns[i]);
}

And then I transform it into input row and run the csvOutputAnalyzer.

InputRow inputRow = new MetaModelInputRow(i, row);
csvOutputAnalyzer.run(inputRow, i);


The problem is, that the _subQuerySelectItem of SelectItem is null.
which results into equalsIgnoreAlias(SelectItem that) returning false,
and finally we don't get any value for one of the columns which was
aggregated ( SUM ).

The query is

Query query = dc.query().from(table).select(representationColumn,
regionCodeColumn, knowledgeTypeColumn). select(FunctionType.SUM,
frequencyColumn). as("FREQUENCY"). toQuery(). where(frequency_fColumn,
OperatorType.EQUALS_TO, -1000). groupBy ( representationColumn ,
knowledgeTypeColumn, regionCodeColumn);

And the _subQuerySelectItem is null for FREQUENCY.

Any help will be appreciated.

Kasper Sørensen

unread,
Dec 7, 2010, 5:08:08 AM12/7/10
to datacle...@googlegroups.com
Hmm I think you're maybe focusing on the wrong symptom here (the equalsIgnoreAlias method of SelectItem). Rather I think it's because youre trying to retrieve values from the dataset based on a column qualifier which is unappropriate when in deed you're selecting an aggregated value (SUM(...)).

If you look at the DataSet interface there are three getValue(...) methods:

getValue(int)
getValue(SelectItem)
getValue(Column)

The two first are the low level ways of getting a value because they retrieve the values based on very precise qualifiers (ie. things that reside in the query - either a select item index or the actual select item).

The last one uses a column which is only possible if you're actually selecting such a column in your SELECT clause. You're not doing this, you're selecting an aggregatet value. So you can do two things:

1) Retrieve by index, if you know the index of your aggregate in the SELECT clause
2) Retrieve by SelectItem. To do this you need to keep a reference to the select item that you've created (new SelectItem(SUM, ...)).

Hope it helps.

/Kasper


--
You received this message because you are subscribed to the Google Groups "DataCleaner-dev" group.
To post to this group, send email to datacle...@googlegroups.com.
To unsubscribe from this group, send email to datacleaner-d...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/datacleaner-dev?hl=en.


paritosh ranjan

unread,
Dec 7, 2010, 6:20:09 AM12/7/10
to datacle...@googlegroups.com
The problem is that I am using InputRow which does not have getValue(int) method.

Row row = ds.getRow();

InputRow inputRow = new MetaModelInputRow(i, row);
csvOutputAnalyzer.run(inputRow, i);


public void run(InputRow row, int distinctCount){
...
InputColumn<Object> objectCol = (InputColumn<Object>) col;
outputRow.setValue(objectCol, row.getValue(col));
...
}

2010/12/7 Kasper Sørensen <kas...@eobjects.dk>

Kasper Sørensen

unread,
Dec 7, 2010, 8:40:21 AM12/7/10
to datacle...@googlegroups.com
Hmm yes OK I see that... I guess this is actually a limitation of MetaModelInputRow and MetaModelInputColumn. For now you can work around it by using MockInputRow and MockInputColumn. I will post a bug on Trac about making sure that MetaModelInputColumns should be possible to use with aggregations in addition to "pure" columns.

Best,
Kasper
Reply all
Reply to author
Forward
0 new messages