You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by Alessandro Portosa <al...@eng.it> on 2016/03/03 18:02:48 UTC

Error when using GROUPBY and ORBERBY with different fields

Hi meta-folks,
I'm having a problem when trying to supply some SQL query to MetaModel 
(4.5.1).

1) If i use SELECT SUM(total_children) AS total_children_SUM, city AS 
city FROM schema.table GROUP BY city I get the right results.
2) If i use (SELECT SUM(total_children) AS total_children_SUM , city AS 
city FROM schema.tableGROUP BY city ORDER BY city asc then I get the 
right results.
3) But if I use*SELECT SUM(total_children) AS total_children_SUM, city 
AS city FROM schema.table GROUP BY city ORDER BY country asc *I wrong 
results. I do get results, but these are the same as 1) where no 
ordering was required. The same happen with I use any other field that 
is not city (which is the field that I'm using for the grouping).

This is how I use it:

    /String newSqlQuery =
    Query query = dataContext.parseQuery(newSqlQuery);//
    //CompiledQuery cQuery = dataContext.compileQuery(query);//
    //DataSet dataSet = dataContext.executeQuery(cQuery);/

No error or exception. Just wrong data.

Any ideas?

Many thanks!
Alessandro.

Re: Error when using GROUPBY and ORBERBY with different fields

Posted by Alessandro Portosa <al...@eng.it>.
I created the JIRA issue here:

https://issues.apache.org/jira/browse/METAMODEL-238


Il 09/03/2016 09:25, Kasper Sørensen ha scritto:
> Hi Alessandro,
>
> This does sound like a bug ... Best thing to do is probably that we
> register it in JIRA, preferably followed also by a unittest that reproduces
> the issue.
>
> 2016-03-03 18:02 GMT+01:00 Alessandro Portosa <al...@eng.it>:
>
>> Hi meta-folks,
>> I'm having a problem when trying to supply some SQL query to MetaModel
>> (4.5.1).
>>
>> 1) If i use SELECT SUM(total_children) AS total_children_SUM, city AS city
>> FROM schema.table GROUP BY city I get the right results.
>> 2) If i use (SELECT SUM(total_children) AS total_children_SUM , city AS
>> city FROM schema.tableGROUP BY city ORDER BY city asc then I get the right
>> results.
>> 3) But if I use*SELECT SUM(total_children) AS total_children_SUM, city AS
>> city FROM schema.table GROUP BY city ORDER BY country asc *I wrong results.
>> I do get results, but these are the same as 1) where no ordering was
>> required. The same happen with I use any other field that is not city
>> (which is the field that I'm using for the grouping).
>>
>> This is how I use it:
>>
>>     /String newSqlQuery =
>>     Query query = dataContext.parseQuery(newSqlQuery);//
>>     //CompiledQuery cQuery = dataContext.compileQuery(query);//
>>     //DataSet dataSet = dataContext.executeQuery(cQuery);/
>>
>> No error or exception. Just wrong data.
>>
>> Any ideas?
>>
>> Many thanks!
>> Alessandro.
>>

-- 

-- 

*Alessandro Portosa*
SpagoBI Consultant

*SpagoBI Labs
Engineering Group*
Via Marconi, 10 - 40125 Bologna - Italy
Tel. + 39 051 0435090
Skype: alessandro.portosa
www.spagobi.org <http://www.spagobi.org> - www.eng.it 
<http://www.eng.it/web/eng_en/home>


	  Respect the environment. Please don't print this e-mail unless you 
really need to.

The information transmitted is intended only for the person or entity to 
which it is addressed and may contain confidential and/or privileged 
material. Any review, retransmission, dissemination or other use of, or 
taking of any action in reliance upon, this information by persons or 
entities other than the intended recipient is prohibited. If you 
received this in error, please contact the sender and delete the 
material from any computer.


Re: Error when using GROUPBY and ORBERBY with different fields

Posted by Kasper Sørensen <i....@gmail.com>.
Hi Alessandro,

This does sound like a bug ... Best thing to do is probably that we
register it in JIRA, preferably followed also by a unittest that reproduces
the issue.

2016-03-03 18:02 GMT+01:00 Alessandro Portosa <al...@eng.it>:

> Hi meta-folks,
> I'm having a problem when trying to supply some SQL query to MetaModel
> (4.5.1).
>
> 1) If i use SELECT SUM(total_children) AS total_children_SUM, city AS city
> FROM schema.table GROUP BY city I get the right results.
> 2) If i use (SELECT SUM(total_children) AS total_children_SUM , city AS
> city FROM schema.tableGROUP BY city ORDER BY city asc then I get the right
> results.
> 3) But if I use*SELECT SUM(total_children) AS total_children_SUM, city AS
> city FROM schema.table GROUP BY city ORDER BY country asc *I wrong results.
> I do get results, but these are the same as 1) where no ordering was
> required. The same happen with I use any other field that is not city
> (which is the field that I'm using for the grouping).
>
> This is how I use it:
>
>    /String newSqlQuery =
>    Query query = dataContext.parseQuery(newSqlQuery);//
>    //CompiledQuery cQuery = dataContext.compileQuery(query);//
>    //DataSet dataSet = dataContext.executeQuery(cQuery);/
>
> No error or exception. Just wrong data.
>
> Any ideas?
>
> Many thanks!
> Alessandro.
>