Page 1 of 1

Coversion of double to Int

Posted: Fri Oct 31, 2008 7:20 am
by wfis
Hi All,

I am trying to convert double to integer using the modify stage.
The source column is the output column from the aggregator stage that is defined as double with no length.
The output column from modify stage is integer(10,0).

I am using the following function in the modify stage.
output_column:int32=int32_from_decimal(input_column)

I get the warning as follows:
Mdy_Col: When checking operator: When binding output schema variable "outRec": When binding output interface field "input_column" to field "output_column": Implicit conversion from source type "dfloat"to result type "decimal[1,0]". [api/interface_rep.C:6170]

Please advice.

Thanks

Posted: Fri Oct 31, 2008 9:12 am
by ray.wurlod
What you want to occur is happening. DataStage alerts you that what you are doing may not actually always work (some decimal numbers are too large to be represented as integers). You can use a message handler to demote this alert to an informational message or a NOWARN specification in your Modify stage.

Re: Coversion of double to Int

Posted: Fri Oct 31, 2008 1:53 pm
by ajmore
It can be done in a transformer as well using AsInteger(%number%) function

Posted: Mon Nov 03, 2008 8:09 am
by wfis
I earlier used transformer stage only to do this. But when it was possible for a modify stage do it, I changed it.

I am not sure why DataStage gives this error when it is performing the same function.

Thanks.

Posted: Mon Nov 03, 2008 10:31 am
by ray.wurlod
It's not an error.

It's an alert.

Not every decimal number, not every float number can be represented as an integer.

You need to be alerted to that fact, in case you don't know what you are doing.

Include a NOWARN specification in your Modify stage.

Posted: Mon Jul 30, 2018 12:17 pm
by BSridhar
Hi,

I am also having the same issue. Unable to convert from double to int by using Modify stage. How can we get rid if this warning? There is no length/scale passed in my input columns.

Posted: Mon Jul 30, 2018 12:46 pm
by chulett
Which same issue? Are you just asking about the warning message or are the conversions actually failing?

Posted: Tue Jul 31, 2018 8:16 pm
by ray.wurlod
We use AsInteger() for this conversion, in the knowledge that none of our Double values is out of range for Integer data type.