Default and explicit type conversions
When you are mapping data from source to target, you might need to perform data type conversions. Some conversions happen automatically, and can take place across the output mapping of any parallel job stage that has an input and an output link. Other conversions need a function to explicitly perform the conversion.
These functions can be called from a Modify stage or a Transformer stage, and are listed in Appendix B of InfoSphere® DataStage® Parallel Job Developer Guide. The Modify stage is the preferred stage for such conversions. For more information, see Using Transformer stages.
The following table shows which conversions are performed automatically and which need to be explicitly performed. "d" indicates automatic (default) conversion, "m" indicates that manual conversion is required, a blank square indicates that conversion is not possible:
Destination | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
Source | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64 | sfloat | dfloat |
int8 | d | d | d | d | d | d | d | d | d m | |
uint8 | d | d | d | d | d | d | d | d | d | |
int16 | d m | d | d | d | d | d | d | d | d | |
uint16 | d | d | d | d | d | d | d | d | d | |
int32 | d m | d | d | d | d | d | d | d | d | |
uint32 | d | d | d | d | d | d | d | d | d | |
int64 | d m | d | d | d | d | d | d | d | d | |
uint64 | d | d | d | d | d | d | d | d | d | |
sfloat | d m | d | d | d | d | d | d | d | d | |
dfloat | d m | d | d | d | d | d | d | d | d | |
decimal | d m | d | d | d | d m | d | d m | d m | d | d m |
string | d m | d | d m | d | d | d m | d | d | d | d m |
ustring | d m | d | d m | d | d | d m | d | d | d | d m |
raw | m | m | ||||||||
date | m | m | m | m | ||||||
time | m | m | m | |||||||
time stamp | m | m | m |
Destination | |||||||
---|---|---|---|---|---|---|---|
Source | decimal | string | ustring | raw | date | time | timestamp |
int8 | d | d m | d m | m | m | m | |
uint8 | d | d | d | ||||
int16 | d | d m | d m | ||||
uint16 | d | d m | d m | ||||
int32 | d | d m | d m | m | m | ||
uint32 | d | m | m | m | |||
int64 | d | d | d | ||||
uint64 | d | d | d | ||||
sfloat | d | d | d | ||||
dfloat | d m | d m | d m | m | m | ||
decimal | d m | d m | |||||
string | d m | d | m | m | m | ||
ustring | d m | d | m | m | |||
raw | |||||||
date | m | m | m | ||||
time | m | m | d m | ||||
timestamp | m | m | m | m |
d = default conversion; m = modify operator conversion; blank = no conversion needed or provided
You should also note the following points about type conversion:
- When converting from variable-length to fixed-length strings using default conversions, parallel jobs pad the remaining length with NULL (ASCII zero) characters.
- The environment variable APT_STRING_PADCHAR can be used to change the default pad character from an ASCII NULL (0x0) to another character; for example, an ASCII space (Ox20) or a unicode space (U+0020).
- As an alternate solution, the PadString function can be used to pad a variable-length (Varchar) string to a specified length using a specified pad character. Note that PadString does not work with fixed-length (Char) string types. You must first convert Char to Varchar before using PadString.