Vous êtes sur la page 1sur 11

Utility functions

The following table lists the functions available in the Utility category (square brackets indicate an argument is optional): Name GetEnvironment NextSKChain Description Returns the value of the given environment variable Arguments environment variable (string) Output result (string) result (int64) result (int64) result (int64)

Returns the value of the surrogate key value (number) column for the next record in the chain, or value for the newest record

NextSurrogateKey Returns the value of the next surrogate key None PrevSKChain Returns the value of the surrogate key column for the previous record in the chain, or value for the first record value (number)

Type "casting" functions


There is a special class of type conversion function to help you when performing mathematical calculations using numeric fields. For example, if you have a calculation using an output column of type float derived from an input column of type integer in a Parallel Transformer stage the result will be derived as an integer regardless of its float type. If you want a non-integral result for a calculation using integral operands, you can use the following functions (which act in a similar way as casting in C) to cast the integer operands into nonintegral operands: Name Description Arguments Output

AsDouble Treat the given number as a double AsFloat Treat the given number as a float

number (number) number (double) number (number) number (float)

AsInteger Treat the given number as an integer number (number) number (int)

Type Conversion Functions


The following table lists the functions available in the Type Conversion category (square brackets indicate an argument is optional):
Name Description Arguments Output

Name DateToString

Description Return the string representation of the given date Returns the given decimal in decimal representation with specified precision and scale Returns the given decimal in dfloat representation Return the string representation of the given decimal Returns the given dfloat in decimal representation

Arguments date

Output result (string) result (decimal)

[format (string)]
DecimalToDecimal decimal (decimal) [rtype (string)] [packedflag (int8)] number (decimal) ["fix_zero"] number (decimal) ["fix_zero"] number (dfloat) [rtype (string)]

DecimalToDFloat

result (dfloat) result (string) result (decimal) result (string)

DecimalToString

DfloatToDecimal

number (dfloat) DfloatToStringNoExp Returns the given dfloat in its string representation with no exponent, using the scale (string) specified scale IsValid Return whether the given string is valid for type (string) the given type. Valid types are "date", format (string) "decimal", "dfloat", "sfloat", "int8", "uint8", "int16", "uint16", "int32", "uint32", "int64", "uint64", "raw", "string", "time", "timestamp". "ustring" Returns a date from the given string in the given format Returns the given string in decimal representation Returns a string in raw representation date (string)

result (int8)

StringToDate

date

format (string)
StringToDecimal string (string) [rtype (string)] string (string) result (decimal) result (raw) time

StringToRaw

StringToTime

Returns a time representation of the given string Returns a timestamp representation of the

string (string) [format (string)] string (string)

StringToTimestamp

timestamp

Name given string TimestampToDate TimestampToString

Description

Arguments [format (string)] timestamp

Output

Returns a date from the given timestamp Return the string representation of the given timestamp Returns the time from a given timestamp Return the string representation of the given time Returns a ustring from the given string, optionally using the specified map (otherwise uses project default) Returns a string from the given ustring, optionally using the specified map (otherwise uses project default)

date

timestamp [format result (string)] (string) timestamp time [format (string)] string (string) [,mapname (string)] string(ustring) time result (string) result (ustring)

TimestampToTime TimeToString

StringToUstring

UstringToString

result (string)

[,mapname (string)]

Rtype. The rtype argument is a string, and should contain one of the following:

ceil. Round the source field toward positive infinity. E.g, 1.4 -> 2, -1.6 -> -1. floor. Round the source field toward negative infinity. E.g, 1.6 -> 1, -1.4 -> -2. round_inf. Round or truncate the source field toward the nearest representable value, breaking ties by rounding positive values toward positive infinity and negative values toward negative infinity. E.g, 1.4 -> 1, 1.5 -> 2, -1.4 -> -1, -1.5 -> -2. trunc_zero. Discard any fractional digits to the right of the rightmost fractional digit supported in the destination, regardless of sign. For example, if the destination is an integer, all fractional digits are truncated. If the destination is another decimal with a smaller scale, round or truncate to the scale size of the destination decimal. E.g, 1.6 -> 1, -1.6 -> -1.

The default is trunc_zero. Format string. Date, Time, and Timestamp functions that take a format string (e.g., timetostring(time, stringformat)) need to have the date format specified. The format strings are described in Date and time formats. Where your dates, times, or timestamps convert to or from ustrings, WebSphere DataStage will pick this up automatically. In these cases the separators in your format string (for example, `:' or `-') can themselves be Unicode characters.

fix_zero. By default decimal numbers comprising all zeros are treated as invalid. If the string fix_zero is specified as a second argument, then all zero decimal values are regarded as valid.

String functions
The following table lists the functions available in the String category (square brackets indicate an argument is optional): Name AlNum Alpha CompactWhiteSpace Description Return whether the given string consists of alphanumeric characters Returns 1 if string is purely alphabetic Return the string after reducing all consective whitespace to a single space Compares two strings for sorting Arguments string (string) string (string) string (string) Output true/false (int8) result (int8) result (string) result (int8)

Compare

string1 (string) string2 (string) [justification (L or R)]

ComparNoCase ComparNum

Case insensitive comparison of two strings

string1 (string) string2 (string)

result (int8) result (int8)

Compare the first n characters of the string1 (string) two strings string2 (string) length (int16)

CompareNumNoCase Caseless comparison of the first n characters of the two strings

string1 (string) string2 (string) length (int16)

result (int8)

Convert

Converts specified characters in a string to designated replacement characters

fromlist (string) tolist (string) expression (string)

result (string)

Count

Count number of times a substring occurs in a string Count number of delimited fields in a string

string (string) substring (string)

result (int32) result (int32)

Dcount

string (string) delimiter (string)

Name DownCase DQuote Field

Description Change all uppercase letters in a string to lowercase Enclose a string in double quotation marks Return 1 or more delimited substrings

Arguments string (string) string (string) string (string) delimiter (string) occurrence (int32) [number (int32)]

Output result (string) result (string) result (string)

Index

Find starting character position of substring Leftmost n characters of string

string (string) substring (string) occurrence (int32) string (string) number (int32)

result (int32) result (string) result (int32) result (int8) result (string) result (string) result (string)

Left

Len Num PadString

Length of string in characters

string (string)

Return 1 if string can be converted to string (string) a number Return the string padded with the optional pad character and optional length Rightmost n characters of string string (string) padlength (int32) string (string) number (int32)

Right

Soundex

Returns a string which identifies a set of words that are (roughly) phonetically alike based on the standard, open algorithm for SOUNDEX evaluation

string (string)

Space Squote Str

Return a string of N space characters length (int32) Enclose a string in single quotation marks Repeat a string string (string) string (string) repeats (int32)

result (string) result (string) result (string) result (string) result

StripWhiteSpace Trim

Return the string after stripping all whitespace from it Remove all leading and trailing

string (string) string (string)

Name

Description spaces and tabs plus reduce internal occurrences to one

Arguments [stripchar (string)] [options (string)] string (string) string (string) string (string) string (string)

Output (string) result (string) result (string) result (string) result (string)

TrimB TrimF Trim Leading Trailing Upcase

Remove all trailing spaces and tabs Remove all leading spaces and tabs Returns a string with leading and trailing whitespace removed Change all lowercase letters in a string to uppercase

true = 1 false = 0 Possible options for the Trim function are:


L Removes leading occurrences of character. T Removes trailing occurrences of character. B Removes leading and trailing occurrences of character. R Removes leading and trailing occurrences of character, and reduces multiple occurrences to a single occurrence. A Removes all occurrences of character. F Removes leading spaces and tabs. E Removes trailing spaces and tabs. D Removes leading and trailing spaces and tabs, and reduces multiple spaces and tabs to single ones.

Date and time functions


The following table lists the functions that are available in the Date and Time category (Square brackets indicate an argument is optional): Name DateFromDaysSince Description Returns a date by adding an integer to a baseline date Arguments number (int32) [baseline date] date Output

DateFromJulianDay DaysSinceFromDate

Returns a date from juliandate (uint32) the given julian date Returns the number of days from source date to the given source_date given_date

date days since (int32)

Name date HoursFromTime JulianDayFromDate MicroSecondsFromTime

Description

Arguments

Output

Returns the hour portion of a time Returns julian day from the given date

time date

hours (int8) julian date (int32) microseconds (int32) minutes (int8) day (int8)

Returns the time microsecond portion from a time Returns the minute portion from a time Returns the day of the month given the date Returns the month number given the date time date

MinutesFromTime MonthDayFromDate

MonthFromDate

date

month number (int8)

NextWeekdayFromDate

Returns the date of source date date the specified day of the week soonest day of week (string) after the source date Returns the date of the specified day of the week most recent before the source date Returns the second portion from a time source date day of week (string) date

PreviousWeekdayFromDate

SecondsFromTime

time timestamp base timestamp -

seconds (dfloat) seconds (dfloat)

SecondsSinceFromTimestamp Returns the number of seconds between two timestamps TimeDate Returns the system time and date as a formatted string

system time and date (string) time

TimeFromMidnightSeconds

Returns the time seconds (dfloat) given the number of seconds since midnight Returns a timestamp date time form the given date and time

TimestampFromDateTime

timestamp

Name

Description

Arguments seconds (dfloat) [base timestamp]

Output timestamp

TimestampFromSecondsSince Returns the timestamp from the number of seconds from the base timestamp TimestampFromTimet

Returns a timestamp timet (int32) from the given unix time_t value Returns a unix timestamp time_t value from the given timestamp Returns the day date [origin day] number of the week from the given date. Origin day optionally specifies the day regarded as the first in the week and is Sunday by default Returns the day number in the year from the given date Returns the year from the given date Returns the week number in the year from the given date date

timestamp

TimetFromTimestamp

timet (int32)

WeekdayFromDate

day (int8)

YeardayFromDate

day (int16)

YearFromDate YearweekFromDate

date date

year (int16) week (int16)

Date, Time, and Timestamp functions that specify dates, times, or timestamps in the argument use strings with specific formats: For a date, the format is %yyyy-%mm-%dd For a time, the format is %hh:%nn:%ss, or, if extended to include microseconds, %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to. For a timestamp the format is %yyyy-%mm-%dd %hh:%nn:%ss, or, if extended to include microseconds, %yyyy-%mm-%dd %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to. This applies to the arguments date, baseline date, given date, time, timestamp, and base timestamp.

Functions that have days of week in the argument take a string specifying the day of the week, this applies to day of week and origin day.

Date and time formats Parallel jobs provide flexible handling of date and time formats.

Logical Functions
The following table lists the functions available in the Logical category (square brackets indicate an argument is optional):
Name Not Description Returns the complement of the logical value of an expression Returns the bitwise AND of the two integer arguments Arguments expression Output Complement (int8) number (uint64)

BitAnd

number 1 (uint64) number 2 (uint64) number 1 (uint64) number 2 (uint64)

BitOr

Returns the bitwise OR of the two integer arguments

number (uint64)

BitXOr

Returns the bitwise Exclusive OR of the two integer number 1 (uint64) number arguments 2 (uint64) Returns a string containing the binary number (uint64) representation in "1"s and "0"s of the given integer number (string)

number (uint64)

BitExpand

string

BitCompress Returns the integer made from the string argument, which contains a binary representation of "1"s and "0"s. SetBit Returns an integer with specific bits set to a specific state, where

number (uint64)

origfield (uint64) bitlist (string)

number (uint64)

origfield is the input value to perform the action on, bitlist is a string containing a list of comma separated bit numbers to set the state of, and bitstate is either 1 or 0, indicating which state

bitstate (uint8)

Name

Description

Arguments

Output

to set those bits.

Null handling functions


The following table lists the functions available in the Null Handling category (square brackets indicate an argument is optional):
Name IsNotNull Description Returns true when an expression does not evaluate to the null value Returns true when an expression evaluates to the null value Change an in-band null to out of band null Arguments any Output true/false (int8)

IsNull

any

true/false (int8)

MakeNull

any (column)

string (string)
NullToEmpty Returns an empty string if input column is input column null, otherwise returns the input column value NullToZero Returns zero if input column is null, otherwise input column returns the input column value input column value or empty string input column value or zero input column value or value -

NullToValue Returns specified value if input column is null, input column, otherwise returns the input column value value SetNull Assign a null value to the target column -

true = 1 false = 0

Number functions
The following table lists the functions available in the Number category (square brackets indicate an argument is optional):

Name

Description

Arguments number (decimal) number (dfloat)

Output result (dfloat) result (dfloat)

MantissaFromDecimal Returns the mantissa from the given decimal MantissaFromDFloat Returns the mantissa from the given dfloat

Raw functions
The following table lists the functions available in the Raw category (square brackets indicate an argument is optional):
Name Description Arguments Output

RawLength Returns the length of a raw string input string (raw) Result (int32)

Vector function
The following function can be used within expressions to access an element in a vector column. The vector index starts at 0.
Name Description Arguments Output

ElementAt Accesses an element of a vector input column index (int) element of vector

This can be used as part of, or the whole of an expression. For example, an expression to add 1 to the third element of an vector input column 'InLink.col1' would be:
ElementAt(InLink.col1, 2) + 1

Vous aimerez peut-être aussi