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 (JIRA)" <ji...@apache.org> on 2016/03/09 11:30:41 UTC

[jira] [Updated] (METAMODEL-238) Error when using GROUPBY and ORBERBY with different fields

     [ https://issues.apache.org/jira/browse/METAMODEL-238?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alessandro Portosa updated METAMODEL-238:
-----------------------------------------
    Description: 
MetaModel does not act as expected when providing it a different field for GROUPING and ORDERING.

Let's say the we have a table with the following columns: total_children, city, country.

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.table GROUP 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 get the wrong results.

I do always 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:

   Query query = dataContext.parseQuery(sqlQuery);
   CompiledQuery cQuery = dataContext.compileQuery(query);
   DataSet dataSet = dataContext.executeQuery(cQuery);

The used DataContext is a PojoDataContext.

No error or exception. Just wrong data.

  was:
MetaModel does not act as expected when providing it a different field for GROUPING and ORDERING.

Let's say the we have a table with the following columns: total_children, city, country.

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.table GROUP 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 get the 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:

   Query query = dataContext.parseQuery(sqlQuery);
   CompiledQuery cQuery = dataContext.compileQuery(query);
   DataSet dataSet = dataContext.executeQuery(cQuery);

The used DataContext is a PojoDataContext.

No error or exception. Just wrong data.


> Error when using GROUPBY and ORBERBY with different fields
> ----------------------------------------------------------
>
>                 Key: METAMODEL-238
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-238
>             Project: Apache MetaModel
>          Issue Type: Bug
>    Affects Versions: 4.5.1
>            Reporter: Alessandro Portosa
>
> MetaModel does not act as expected when providing it a different field for GROUPING and ORDERING.
> Let's say the we have a table with the following columns: total_children, city, country.
> 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.table GROUP 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 get the wrong results.
> I do always 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:
>    Query query = dataContext.parseQuery(sqlQuery);
>    CompiledQuery cQuery = dataContext.compileQuery(query);
>    DataSet dataSet = dataContext.executeQuery(cQuery);
> The used DataContext is a PojoDataContext.
> No error or exception. Just wrong data.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)