You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@metamodel.apache.org by "santoshnagda (JIRA)" <ji...@apache.org> on 2017/09/07 10:59:00 UTC

[jira] [Updated] (METAMODEL-1164) How to cast result of a query containing an aggregate function using apache metamodel

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

santoshnagda updated METAMODEL-1164:
------------------------------------
    Description: 

I am new to apache metamodel. And I need to run following query using apache metamodel.

*select sum(cast(columnName as decimal)) from table;"
*
I know that a query containing simple sum function looks like the one given below:

*Query query = dataContext.query().from(table).select(FunctionType.SUM, table.getColumnByName(columnName)).toQuery();*

But I need to use a cast function because depending on the number of records in particular table the result of the sum can be too big than a value which an integer can hold. Thus causing an exception "Arithmetic overflow error converting expression to data type int." to be thrown when there are millions of records in a table. Can anyone tell me how to apply a cast function when composing a query to be executed with apache metamodel.

  was:

1
down vote
favorite
I am new to apache metamodel. And I need to run following query using apache metamodel.

*"select sum(cast(columnName as decimal)) from table;"
*
I know that a query containing simple sum function looks like the one given below:

*Query query = dataContext.query().from(table).select(FunctionType.SUM, table.getColumnByName(columnName)).toQuery();*

But I need to use a cast function because depending on the number of records in particular table the result of the sum can be too big than a value which an integer can hold. Thus causing an exception "Arithmetic overflow error converting expression to data type int." to be thrown when there are millions of records in a table. Can anyone tell me how to apply a cast function when composing a query to be executed with apache metamodel.


> How to cast result of a query containing an aggregate function using apache metamodel
> -------------------------------------------------------------------------------------
>
>                 Key: METAMODEL-1164
>                 URL: https://issues.apache.org/jira/browse/METAMODEL-1164
>             Project: Apache MetaModel
>          Issue Type: Bug
>    Affects Versions: 4.5.4
>            Reporter: santoshnagda
>
> I am new to apache metamodel. And I need to run following query using apache metamodel.
> *select sum(cast(columnName as decimal)) from table;"
> *
> I know that a query containing simple sum function looks like the one given below:
> *Query query = dataContext.query().from(table).select(FunctionType.SUM, table.getColumnByName(columnName)).toQuery();*
> But I need to use a cast function because depending on the number of records in particular table the result of the sum can be too big than a value which an integer can hold. Thus causing an exception "Arithmetic overflow error converting expression to data type int." to be thrown when there are millions of records in a table. Can anyone tell me how to apply a cast function when composing a query to be executed with apache metamodel.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)