Coversion of double to Int

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
wfis
Premium Member
Premium Member
Posts: 70
Joined: Wed Feb 28, 2007 2:38 am
Location: India

Coversion of double to Int

Post 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
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
ajmore
Participant
Posts: 22
Joined: Fri Aug 25, 2006 5:25 am

Re: Coversion of double to Int

Post by ajmore »

It can be done in a transformer as well using AsInteger(%number%) function
wfis
Premium Member
Premium Member
Posts: 70
Joined: Wed Feb 28, 2007 2:38 am
Location: India

Post 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.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
BSridhar
Participant
Posts: 4
Joined: Fri May 25, 2018 9:53 am

Post 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.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Which same issue? Are you just asking about the warning message or are the conversions actually failing?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post 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.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply