[
https://issues.apache.org/jira/browse/METAMODEL-232?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15136992#comment-15136992
]
Kasper Sørensen commented on METAMODEL-232:
-------------------------------------------
Confirmed that this happens because of string comparison. I'm looking into it
with my debugger and finding two hot spots:
FilteredDataSet.java line 54 (here I can see that the individual lines are
being evaluated, but wrongly)
QueryPostprocessDataContext.java line 206 (here I am wondering what to do
differently - seems that the scalar functions should somehow be
respected/decorated when the dataset is passed into the
MetaModelHelper.getAggregated(...) call.
> Incorrect Select Count Using Where Clause with Type Conversion
> --------------------------------------------------------------
>
> Key: METAMODEL-232
> URL: https://issues.apache.org/jira/browse/METAMODEL-232
> Project: Apache MetaModel
> Issue Type: Bug
> Affects Versions: 4.5.0
> Reporter: Michael Diep
> Priority: Minor
> Attachments: CountTest.java, data-source-test-3.xlsx
>
>
> I've found an issue where using select count in a query where columns have
> been converted from a String does not return the correct result. However,
> when running the same query with a select *, the correct number of Rows will
> be in the DataSet.
> In other words, the number of Rows from the following:
> {code}
> Query selectAllQuery = dataContext.query()
> .from(TABLE)
> .selectAll()
> .where(FunctionType.TO_NUMBER, COLUMN).lessThan(lessThanNumber)
> .toQuery();
> {code}
> ... may not equal the count from the following:
> {code}
> Query selectCountQuery = dataContext.query()
> .from(TABLE)
> .selectCount()
> .where(FunctionType.TO_NUMBER, COLUMN).lessThan(lessThanNumber)
> .toQuery();
> {code}
> The issue seems to be due to the select count query making comparisons based
> on the actual column type (a String) against a given operand (a non-String).
> I've only tested this with Excel, but I imagine it could happen with any
> DataContext where all of the data types are read as Strings (e.g. CSV).
> I will attach a test with a sample file that showcases the issue.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)