8.0 Environment Variables
8.0 Environment Variables
Version 8.0.1
LC18-9892-01
Version 8.0.1
LC18-9892-01
Note Before using this information and the product that it supports, be sure to read the general information under Notices and trademarks on page 899.
Ascential Software Corporation 2001, 2005. Copyright International Business Machines Corporation 2006, 2007. All rights reserved. US Government Users Restricted Rights Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
Contents
Chapter 1. Introduction . . . . . . . . 1
Terminology . . . . . . . . . . . . . . 1 Buffering assumptions . . . . . . . . . . Controlling buffering . . . . . . . . . . Buffering policy . . . . . . . . . . . Overriding default buffering behavior . . . Operators with special buffering requirements . . . . . . 27 28 28 28 29
. 26
iii
APT_EXECUTION_MODE . . . . . . . . 60 APT_PM_DBX . . . . . . . . . . . . 60 APT_PM_GDB . . . . . . . . . . . . 60 APT_PM_LADEBUG . . . . . . . . . . 60 APT_PM_SHOW_PIDS . . . . . . . . . 60 APT_PM_XLDB . . . . . . . . . . . . 61 APT_PM_XTERM . . . . . . . . . . . 61 APT_SHOW_LIBLOAD . . . . . . . . . 61 Decimal support . . . . . . . . . . . . . 61 APT_DECIMAL_INTERM_PRECISION . . . . 61 APT_DECIMAL_INTERM_SCALE . . . . . . 61 APT_DECIMAL_INTERM_ROUND_MODE . . 61 Disk I/O . . . . . . . . . . . . . . . 61 APT_BUFFER_DISK_WRITE_INCREMENT . . . 61 APT_CONSISTENT_BUFFERIO_SIZE. . . . . 61 APT_EXPORT_FLUSH_COUNT . . . . . . 62 APT_IO_MAP/APT_IO_NOMAP and APT_BUFFERIO_MAP/ APT_BUFFERIO_NOMAP . . . . . . . . 62 APT_PHYSICAL_DATASET_BLOCK_SIZE . . . 62 General Job Administration . . . . . . . . . 62 APT_CHECKPOINT_DIR . . . . . . . . . 62 APT_CLOBBER_OUTPUT . . . . . . . . 62 APT_CONFIG_FILE . . . . . . . . . . 62 APT_DISABLE_COMBINATION . . . . . . 62 APT_EXECUTION_MODE . . . . . . . . 63 APT_ORCHHOME . . . . . . . . . . . 63 APT_STARTUP_SCRIPT . . . . . . . . . 63 APT_NO_STARTUP_SCRIPT . . . . . . . 63 APT_STARTUP_STATUS . . . . . . . . . 64 APT_THIN_SCORE. . . . . . . . . . . 64 Job Monitoring . . . . . . . . . . . . . 64 APT_MONITOR_SIZE . . . . . . . . . . 64 APT_MONITOR_TIME . . . . . . . . . 64 APT_NO_JOBMON. . . . . . . . . . . 64 APT_PERFORMANCE_DATA . . . . . . . 64 Look up support . . . . . . . . . . . . 64 APT_LUTCREATE_MMAP . . . . . . . . 64 APT_LUTCREATE_NO_MMAP . . . . . . 65 Miscellaneous . . . . . . . . . . . . . 65 APT_COPY_TRANSFORM_OPERATOR . . . . 65 APT_DATE_CENTURY_BREAK_YEAR . . . . 65 APT_EBCDIC_VERSION . . . . . . . . . 65 APT_IMPEXP_ALLOW_ZERO_LENGTH_FIXED_NULL 65 APT_IMPORT_REJECT_STRING_FIELD_OVERRUNS 65 APT_INSERT_COPY_BEFORE_MODIFY . . . . 66 APT_OLD_BOUNDED_LENGTH . . . . . . 66 APT_OPERATOR_REGISTRY_PATH . . . . . 66 APT_PM_NO_SHARED_MEMORY . . . . . 66 APT_PM_NO_NAMED_PIPES . . . . . . . 66 APT_PM_SOFT_KILL_WAIT . . . . . . . 66 APT_PM_STARTUP_CONCURRENCY . . . . 66 APT_RECORD_COUNTS . . . . . . . . . 66 APT_SAVE_SCORE . . . . . . . . . . . 67 APT_SHOW_COMPONENT_CALLS . . . . . 67 APT_STACK_TRACE . . . . . . . . . . 67 APT_WRITE_DS_VERSION . . . . . . . . 67 OSH_PRELOAD_LIBS . . . . . . . . . . 67 Network . . . . . . . . . . . . . . . 67 APT_IO_MAXIMUM_OUTSTANDING . . . . 68 APT_IOMGR_CONNECT_ATTEMPTS . . . . 68
APT_PM_CONDUCTOR_HOSTNAME . . . . 68 APT_PM_NO_TCPIP . . . . . . . . . . 68 APT_PM_NODE_TIMEOUT . . . . . . . . 68 APT_PM_SHOWRSH . . . . . . . . . . 68 APT_PM_USE_RSH_LOCALLY . . . . . . . 68 NLS Support . . . . . . . . . . . . . . 68 APT_COLLATION_SEQUENCE . . . . . . 68 APT_COLLATION_STRENGTH . . . . . . 69 APT_ENGLISH_MESSAGES . . . . . . . . 69 APT_IMPEXP_CHARSET . . . . . . . . . 69 APT_INPUT_CHARSET . . . . . . . . . 69 APT_OS_CHARSET . . . . . . . . . . 69 APT_OUTPUT_CHARSET . . . . . . . . 69 APT_STRING_CHARSET . . . . . . . . . 69 Oracle Support . . . . . . . . . . . . . 69 APT_ORACLE_LOAD_DELIMITED . . . . . 69 APT_ORACLE_LOAD_OPTIONS . . . . . . 70 APT_ORACLE_NO_OPS . . . . . . . . . 70 APT_ORACLE_PRESERVE_BLANKS . . . . . 70 APT_ORA_IGNORE_CONFIG_FILE_PARALLELISM 70 APT_ORA_WRITE_FILES . . . . . . . . 70 APT_ORAUPSERT_COMMIT_ROW_INTERVAL APT_ORAUPSERT_COMMIT_TIME_INTERVAL . 70 Partitioning . . . . . . . . . . . . . . 71 APT_NO_PART_INSERTION . . . . . . . 71 APT_PARTITION_COUNT . . . . . . . . 71 APT_PARTITION_NUMBER . . . . . . . . 71 Reading and writing files . . . . . . . . . . 71 APT_DELIMITED_READ_SIZE . . . . . . . 71 APT_FILE_IMPORT_BUFFER_SIZE . . . . . 71 APT_FILE_EXPORT_BUFFER_SIZE . . . . . 72 APT_IMPORT_PATTERN_USES_FILESET . . . 72 APT_MAX_DELIMITED_READ_SIZE . . . . 72 APT_PREVIOUS_FINAL_DELIMITER_COMPATIBLE 72 APT_STRING_PADCHAR . . . . . . . . 72 Reporting . . . . . . . . . . . . . . . 72 APT_DUMP_SCORE . . . . . . . . . . 72 APT_ERROR_CONFIGURATION . . . . . . 72 APT_MSG_FILELINE . . . . . . . . . . 74 APT_PM_PLAYER_MEMORY . . . . . . . 74 APT_PM_PLAYER_TIMING . . . . . . . . 74 APT_RECORD_COUNTS . . . . . . . . . 74 OSH_DUMP . . . . . . . . . . . . . 75 OSH_ECHO . . . . . . . . . . . . . 75 OSH_EXPLAIN . . . . . . . . . . . . 75 OSH_PRINT_SCHEMAS . . . . . . . . . 75 SAS Support . . . . . . . . . . . . . . 75 APT_HASH_TO_SASHASH . . . . . . . . 75 APT_NO_SASOUT_INSERT . . . . . . . . 75 APT_NO_SAS_TRANSFORMS . . . . . . . 75 APT_SAS_ACCEPT_ERROR . . . . . . . . 75 APT_SAS_CHARSET . . . . . . . . . . 76 APT_SAS_CHARSET_ABORT . . . . . . . 76 APT_SAS_COMMAND . . . . . . . . . 76 APT_SASINT_COMMAND . . . . . . . . 76 APT_SAS_DEBUG . . . . . . . . . . . 76 APT_SAS_DEBUG_IO . . . . . . . . . . 76 APT_SAS_DEBUG_LEVEL . . . . . . . . 76 APT_SAS_DEBUG_VERBOSE . . . . . . . 76 APT_SAS_NO_PSDS_USTRING . . . . . . 77 APT_SAS_S_ARGUMENT . . . . . . . . 77
iv
APT_SAS_SCHEMASOURCE_DUMP. . . APT_SAS_SHOW_INFO . . . . . . . APT_SAS_TRUNCATION . . . . . . Sorting . . . . . . . . . . . . . . APT_NO_SORT_INSERTION . . . . . APT_SORT_INSERTION_CHECK_ONLY . Teradata Support . . . . . . . . . . APT_TERA_64K_BUFFERS . . . . . . APT_TERA_NO_ERR_CLEANUP . . . . APT_TERA_NO_SQL_CONVERSION . . APT_TERA_NO_PERM_CHECKS . . . . APT_TERA_SYNC_DATABASE . . . . . APT_TERA_SYNC_PASSWORD . . . . APT_TERA_SYNC_USER . . . . . . . Transport Blocks . . . . . . . . . . . APT_AUTO_TRANSPORT_BLOCK_SIZE . APT_LATENCY_COEFFICIENT . . . . APT_DEFAULT_TRANSPORT_BLOCK_SIZE APT_MAX_TRANSPORT_BLOCK_SIZE/ APT_MIN_TRANSPORT_BLOCK_SIZE . . Guide to setting environment variables . . . Environment variable settings for all jobs . Optional environment variable settings . .
. . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . .
77 77 77 77 77 77 78 78 78 78 78 78 78 78 78 79 79 79 79 79 79 79
Chapter 7. Operators . . . . . . . . . 81
Stage to Operator Mapping . . . . . . . Changeapply operator . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Schemas . . . . . . . . . . . . Syntax and options . . . . . . . . . Example . . . . . . . . . . . . Changecapture operator . . . . . . . . Data flow diagram . . . . . . . . . Key and value fields . . . . . . . . Syntax and options . . . . . . . . . Example 1: all output results . . . . . Example 2: dropping output results . . . Compare operator . . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Example 1: running the compare operator in parallel . . . . . . . . . . . . Example 2: running the compare operator sequentially . . . . . . . . . . . Copy operator . . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Preventing WebSphere DataStage from removing a copy operator . . . . . . Example 1: The copy operator . . . . . Example 2: running the copy operator sequentially . . . . . . . . . . . Diff operator . . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Transfer behavior . . . . . . . . . Syntax and options . . . . . . . . Example 1: general example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 84 84 85 86 86 89 91 91 91 92 95 96 97 97 97 99
Example 2: Dropping Output Results . . . Encode operator . . . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Encoding WebSphere DataStage data sets . . Example . . . . . . . . . . . . . Filter operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Job monitoring information . . . . . . . Expressions . . . . . . . . . . . . Input data types . . . . . . . . . . Example 1: comparing two fields . . . . . Example 2: testing for a null . . . . . . Example 3: evaluating input records . . . . Job scenario: mailing list for a wine auction . Funnel operators . . . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Funnel operator . . . . . . . . . . Sort funnel operators . . . . . . . . . Generator operator . . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Using the generator operator . . . . . . Example 1: using the generator operator . . Example 2: executing the operator in parallel Example 3: using generator with an input data set . . . . . . . . . . . . . . . Defining the schema for the operator . . . Timestamp fields . . . . . . . . . . Head operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Example 1: head operator default behavior . Example 2: extracting records from a large data set . . . . . . . . . . . . . . . Example 3: locating a single record . . . . Lookup operator . . . . . . . . . . . Data flow diagrams . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Partitioning . . . . . . . . . . . . Create-only mode . . . . . . . . . . Example 1: single lookup table record . . . Example 2: multiple lookup table record . . Example 3: interest rate lookup example . . Example 4: handling duplicate fields example Merge operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Merging records . . . . . . . . . . Understanding the merge operator . . . . Example 1: updating national data with state data . . . . . . . . . . . . . . Example 2: handling duplicate fields . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
111 112 112 112 113 113 114 114 114 115 115 116 117 118 119 120 120 120 122 122 122 123 123 126 127 127 127 128 129 130 130 131 136 137 138 138 138 139 139 140 140 140 141 142 145 145 146 146 147 148 149 150 150 150 152 154
. . . . . . . . . . . . . . . . . . . . . . . . .
. 157 . 159
Contents
Job scenario: galactic industries . . . . Missing records . . . . . . . . . Modify operator . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Transfer behavior . . . . . . . . . Avoiding contiguous modify operators . . Performing conversions . . . . . . . Allowed conversions . . . . . . . . pcompress operator . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Compressed data sets . . . . . . . Example . . . . . . . . . . . . Peek operator . . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Using the operator . . . . . . . . PFTP operator . . . . . . . . . . . Data flow diagram . . . . . . . . Operator properties . . . . . . . . Syntax and options . . . . . . . . Restartability . . . . . . . . . . Remdup operator . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Removing duplicate records . . . . . Using options to the operator . . . . . Using the operator . . . . . . . . Example 1: using remdup . . . . . . Example 2: using the -last option . . . . Example 3: case-insensitive string matching Example 4: using remdup with two keys . Sample operator . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Example sampling of a data set . . . . Sequence operator . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Example of Using the sequence Operator . Switch operator . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Job monitoring information . . . . . . Example metadata and summary messages Customizing job monitor messages . . . Tail operator. . . . . . . . . . . . Data flow diagram . . . . . . . . Properties . . . . . . . . . . . Syntax and options . . . . . . . . Example 1: tail operator default behavior . Example 2: tail operator with both options Transform operator . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
161 163 165 165 166 166 167 167 167 198 200 200 200 200 201 202 203 203 203 204 205 206 206 207 207 212 213 213 213 214 215 215 217 217 217 217 218 218 218 218 219 220 221 221 221 222 222 223 223 224 224 228 228 229 229 229 229 230 230 230 231
Running your job on a non-NFS MPP . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . Transfer behavior . . . . . . . . . . . The transformation language . . . . . . . The transformation language versus C . . . . Using the transform operator . . . . . . . Example 1: student-score distribution . . . . Example 2: student-score distribution with a letter grade added to example . . . . . . . Example 3: student-score distribution with a class field added to example . . . . . . . Example 4. student record distribution with null score values and a reject . . . . . . . . . Example 5. student record distribution with null score values handled . . . . . . . . . . Example 6. student record distribution with vector manipulation . . . . . . . . . . Example 7: student record distribution using sub-record . . . . . . . . . . . . . Example 8: external C function calls . . . . . Writerangemap operator . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . Using the writerange operator . . . . . . .
231 231 231 232 240 241 277 278 278 281 284 287 289 292 296 299 301 301 301 302 303
305
. . . . . . . . . . . . . 306 306 306 307 308 312 315 316 322 322 322 323 330 332 333 334 334 335 336 340 344 345 346 346 348 355
. . . . . . . . . . .
vi
Properties . . . . . . . . . . . . Syntax . . . . . . . . . . . . . . The hash partitioner . . . . . . . . . . Specifying hash keys . . . . . . . . . Example . . . . . . . . . . . . . Using the partitioner . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and option . . . . . . . . . . The modulus partitioner . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and option . . . . . . . . . . Example . . . . . . . . . . . . . The random partitioner . . . . . . . . . Using the partitioner . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax . . . . . . . . . . . . . . The range Partitioner . . . . . . . . . . Considerations when using range partitioning The range partitioning algorithm . . . . . Specifying partitioning keys . . . . . . Creating a range map . . . . . . . . Example: configuring and using range partitioner . . . . . . . . . . . . Using the partitioner . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Writerangemap operator . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Using the writerange operator . . . . . . The makerangemap utility . . . . . . . . Syntax and options . . . . . . . . . Using the makerangemap utility . . . . . The roundrobin partitioner . . . . . . . . Using the partitioner . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax . . . . . . . . . . . . . . The same partitioner . . . . . . . . . . Using the partitioner . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . .
402 403 403 404 404 405 405 405 406 407 407 408 408 408 409 410 410 410 411 411 412 . 412 . 412 . 413 415 415 416 416 416 418 418 419 419 420 421 421 423 423 424 424 424 424 425 425 425 426 426
. . .
. . .
. . .
. . .
. . .
. . .
435
435 435 436 436 438 438 439 440 440 441 441 442 443 443 444 444 445 447 447 448 448 448 449 450 450 450 451 451 451 452 452 453 453 454 454 454 455 455 455 456 456 457 457 458 458 458 459 459 460 460 461 461
. . . . . . . . . . . . . . . . . . . . . . .
The aggtorec operator . . . . . . . . . . Output formats . . . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . Example 1: the aggtorec operator without the toplevelkeys option . . . . . . . . . . Example 2: the aggtorec operator with multiple key options . . . . . . . . . . . . . Example 3: The aggtorec operator with the toplevelkeys option . . . . . . . . . . The field_export operator . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . Example . . . . . . . . . . . . . . The field_import operator . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . Example . . . . . . . . . . . . . . The makesubrec operator . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Transfer behavior . . . . . . . . . . . Subrecord length . . . . . . . . . . . Syntax and options . . . . . . . . . . The makevect operator . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Transfer Behavior . . . . . . . . . . . Non-consecutive fields . . . . . . . . . Syntax and option . . . . . . . . . . . Example 1: The makevect operator . . . . . Example 2: The makevect operator with missing input fields . . . . . . . . . . . . . The promotesubrec Operator . . . . . . . . Data Flow Diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and Option . . . . . . . . . . Example . . . . . . . . . . . . . . The splitsubrec Operator . . . . . . . . . Data Flow Diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and Option . . . . . . . . . . Example . . . . . . . . . . . . . . The splitvect operator . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and option . . . . . . . . . . . Example . . . . . . . . . . . . . . The tagbatch operator . . . . . . . . . . Tagged fields and operator limitations . . . . Operator action and transfer behavior . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Added, missing, and duplicate fields . . . .
Contents
vii
Input data set requirements . . . . . . . Syntax and options . . . . . . . . . . Example 1: The tagbatch operator, simple flattening of tag cases . . . . . . . . . Example 2: The tagbatch operator, missing and duplicate cases . . . . . . . . . . . . Example 3: The tagbatch operator with multiple keys . . . . . . . . . . . . . . . The tagswitch operator . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Input and output interface schemas . . . . . The case option. . . . . . . . . . . . Using the operator . . . . . . . . . . Syntax and options . . . . . . . . . . Example 1: The tagswitch operator, default behavior . . . . . . . . . . . . . . Example 2: the tagswitch operator, one case chosen. . . . . . . . . . . . . . .
462 462 464 465 466 467 467 468 468 468 468 469 470 471
Example . . . . rightouterjoin operator Syntax and options Example . . . . fullouterjoin operator . Syntax and options Example . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
543
. 543 . 543 544 . 545 . 545 . 546
viii
Representing SAS and non-SAS Data in DataStage . . . . . . . . . . . . . Getting input from a SAS data set . . . . . Getting input from a WebSphere DataStage data set or a SAS data set . . . . . . . . . . Converting between data set types . . . . . Converting SAS data to WebSphere DataStage data a WebSphere DataStage example . . . . . . . Parallelizing SAS steps . . . . . . . . . Executing PROC steps in parallel . . . . . . Some points to consider in parallelizing SAS code . . . . . . . . . . . . . . . Using SAS with European languages . . . . . Using SAS to do ETL . . . . . . . . . . . The SAS interface operators . . . . . . . . Specifying a character set and SAS mode . . . Parallel SAS data sets and SAS International Specifying an output schema . . . . . . . Controlling ustring truncation . . . . . . . Generating a proc contents report . . . . . WebSphere DataStage-inserted partition and sort components . . . . . . . . . . . . . Long name support . . . . . . . . . . Environment variables . . . . . . . . . The sasin operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . The sas operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . The sasout operator . . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . The sascontents operator . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . Example reports . . . . . . . . . . .
547 548 549 550 551 552 553 559 563 564 565 566 566 568 569 569 570 570 570 571 572 573 573 573 577 577 577 578 582 583 583 583 585 585 586 586 587
Join operations . . . . . . . . . . . Syntax and options . . . . . . . . . . Example 1: reading an Oracle table and modifying a field name . . . . . . . . Example 2: reading from an Oracle table in parallel with the query option . . . . . . The orawrite operator . . . . . . . . . Writing to a multibyte database . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Operator action . . . . . . . . . . . Data type conversion . . . . . . . . . Write modes . . . . . . . . . . . . Matched and unmatched fields . . . . . Syntax and options . . . . . . . . . Example 1: writing to an existing Oracle table Example 2: creating an Oracle table . . . . Example 3: writing to an Oracle table using the modify operator . . . . . . . . . . The oraupsert operator . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Operator Action . . . . . . . . . . Associated environment variables . . . . Syntax and options . . . . . . . . . Example . . . . . . . . . . . . . The oralookup operator . . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Example . . . . . . . . . . . . .
. 595 . 595 . 598 . . . . . . . . . . 599 599 599 600 600 600 602 602 603 604 610 . 611 611 612 613 613 613 614 615 617 617 619 619 619 621
. . . . . . . . . . . . .
623
. 623 . 624 . 624 . 625 . . . . . . . . . . . . 625 626 626 626 627 627 627 627 628 629 630 631
ix
Properties . . . . . . . . . . . . . Actions of the write operators . . . . . . . How WebSphere DataStage writes the table: the default SQL INSERT statement . . . . . . Field conventions in write operations to DB2 Data type conversion . . . . . . . . . . Write modes . . . . . . . . . . . . . Matched and unmatched fields . . . . . . Syntax and options . . . . . . . . . . db2load special characteristics . . . . . . . Example 1: Appending Data to an Existing DB2 Table . . . . . . . . . . . . . . . Example 2: writing data to a DB2 table in truncate mode . . . . . . . . . . . . Example 3: handling unmatched WebSphere DataStage fields in a DB2 write operation . . . Example 4: writing to a DB2 table containing an unmatched column . . . . . . . . . . The db2upsert operator . . . . . . . . . . Partitioning for db2upsert . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Operator action . . . . . . . . . . . . Syntax and options . . . . . . . . . . The db2part operator . . . . . . . . . . . Syntax and options . . . . . . . . . . Example . . . . . . . . . . . . . . The db2lookup operator . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and options . . . . . . . . . . Example . . . . . . . . . . . . . . Considerations for reading and writing DB2 tables Data translation anomalies . . . . . . . . Using a node map . . . . . . . . . . .
635 636 636 637 637 638 639 639 646 647 648 649 650 651 651 651 651 652 653 655 656 657 658 659 659 659 661 662 662 662
Example 4: Handling unmatched WebSphere DataStage fields in an Informix write operation . Example 5: Writing to an INFORMIX table with an unmatched column . . . . . . . . . hplread operator . . . . . . . . . . . . Special operator features . . . . . . . . Establishing a remote connection to the hplread operator . . . . . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties of the hplread operator . . . . . Syntax and options . . . . . . . . . . Example . . . . . . . . . . . . . . hplwrite operator for Informix. . . . . . . . Special operator features . . . . . . . . Data flow diagram . . . . . . . . . . Properties of the hplwrite operator . . . . . Syntax and options . . . . . . . . . . Examples . . . . . . . . . . . . . . infxread operator . . . . . . . . . . . . Data Flow Diagram . . . . . . . . . . Properties . . . . . . . . . . . . . Syntax and Options . . . . . . . . . . Example . . . . . . . . . . . . . . infxwrite operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties of the infxwrite operator . . . . . Syntax and options . . . . . . . . . . Examples . . . . . . . . . . . . . . xpsread operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties of the xpsread operator . . . . . Syntax and options . . . . . . . . . . Example . . . . . . . . . . . . . . xpswrite operator . . . . . . . . . . . . Data flow diagram . . . . . . . . . . Properties of the xpswrite operator . . . . . Syntax and options . . . . . . . . . . Examples . . . . . . . . . . . . . .
675 676 677 677 677 678 678 679 680 680 680 681 681 681 683 683 683 684 684 685 686 686 686 686 688 688 689 689 689 691 691 691 692 692 693
. .
. .
. .
. .
. .
. .
. .
. .
. 705 . 705
SQL Server record size . . . . . . . . Targeting the read operation . . . . . . Join operations . . . . . . . . . . . Syntax and options . . . . . . . . . Example 1: Reading a SQL Server table and modifying a field name . . . . . . . . The sqlsrvrwrite operator . . . . . . . . Writing to a multibyte database . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Operator action . . . . . . . . . . . Where the sqlsrvrwrite operator runs . . . Data conventions on write operations to SQL Server . . . . . . . . . . . . . . Write modes . . . . . . . . . . . . Syntax and options . . . . . . . . . Example 1: Writing to an existing SQL Server table . . . . . . . . . . . . . . Example 2: Creating a SQL Server table . . Example 3: Writing to a SQL Server table using the modify operator . . . . . . . . . The sqlsrvrupsert operator . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Operator action . . . . . . . . . . . Syntax and options . . . . . . . . . Example . . . . . . . . . . . . . The sqlsrvrlookup operator . . . . . . . . Data flow diagram . . . . . . . . . Properties . . . . . . . . . . . . Syntax and options . . . . . . . . . Example . . . . . . . . . . . . .
. . . . . . . . . . .
742 742 742 743 744 745 745 746 746 746 746
. 747 . 748 . 749 . 751 . 752 . . . . . . . . . . . . 753 754 754 754 754 755 757 758 759 759 760 762
Contents
xi
. 775
Chapter 25. WebSphere DataStage development kit (job control interfaces) . . . . . . . . . . . . . 795
WebSphere DataStage development kit . . . . The dsapi.h header file . . . . . . . . Data structures, result data, and threads . . Writing WebSphere DataStage API programs Building a WebSphere DataStage API application . . . . . . . . . . . . Redistributing applications . . . . . . . API functions . . . . . . . . . . . DSAddEnvVar . . . . . . . . . . . . DSAddProject . . . . . . . . . . . . DSCloseJob . . . . . . . . . . . . . DSCloseProject . . . . . . . . . . . . DSDeleteEnvVar . . . . . . . . . . . DSDeleteProject . . . . . . . . . . . DSFindFirstLogEntry . . . . . . . . . . DSFindNextLogEntry . . . . . . . . . . DSGetProjectList . . . . . . . . . . . DSGetJobInfo . . . . . . . . . . . . DSGetLastError . . . . . . . . . . . . DSGetLastErrorMsg . . . . . . . . . . DSGetLinkInfo . . . . . . . . . . . . DSGetLogEntry . . . . . . . . . . . . DSGetNewestLogId . . . . . . . . . . DSGetParamInfo . . . . . . . . . . . DSGetProjectInfo . . . . . . . . . . . DSGetProjectList . . . . . . . . . . . . 795 . 795 . 795 796 . . . . . . . . . . . . . . . . . . . . . 796 797 797 798 799 800 800 801 801 802 803 804 805 807 807 808 809 810 811 812 813
DSGetReposInfo . . . . DSGetReposUsage . . . . DSGetStageInfo . . . . . DSGetProjectList . . . . DSListEnvVars . . . . . DSListProjectProperties . . DSLockJob . . . . . . DSLogEvent . . . . . . DSMakeJobReport . . . . DSOpenJob . . . . . . DSOpenProject . . . . . DSRunJob . . . . . . DSSetEnvVar . . . . . DSSetGenerateOpMetaData . DSSetJobLimit . . . . . DSSetParam . . . . . . DSSetProjectProperty . . . DSSetServerParams . . . DSStopJob . . . . . . DSUnlockJob . . . . . DSWaitForJob . . . . . Data Structures . . . . . DSCUSTINFO . . . . . DSJOBINFO . . . . . . DSLINKINFO . . . . . DSLOGDETAIL . . . . DSLOGEVENT . . . . . DSPARAM . . . . . . DSPARAMINFO . . . . DSPROJECTINFO . . . . DSREPOSINFO . . . . . DSREPOSUSAGE . . . . DSSTAGEINFO . . . . . DSLINKINFO . . . . . Error codes . . . . . . WebSphere DataStage BASIC DSAttachJob . . . . . . DSCheckRoutine . . . . DSDetachJob . . . . . DSExecute . . . . . . DSGetCustInfo . . . . . DSIPCPageProps . . . . DSGetJobInfo . . . . . DSGetJobMetaBag . . . . DSGetLinkInfo . . . . . DSGetLinkMetaData . . . DSGetLogEntry . . . . . DSGetLogSummary . . . DSGetNewestLogId . . . DSGetParamInfo . . . . DSGetProjectInfo . . . . DSGetStageInfo . . . . . DSGetStageLinks . . . . DSGetStagesOfType . . . DSGetStagesTypes . . . . DSGetVarInfo . . . . . DSLogEvent . . . . . . DSLogFatal . . . . . . DSLogInfo . . . . . . DSLogToController . . . DSLogWarn . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
813 814 815 817 818 819 820 820 821 822 823 823 824 825 826 827 828 829 830 830 831 831 832 832 835 836 837 837 839 840 841 842 842 844 845 850 851 852 852 853 853 854 854 857 857 858 859 860 861 861 863 863 865 866 866 867 867 868 868 869 869
xii
DSMakeJobReport . . . . DSMakeMsg . . . . . . DSPrepareJob . . . . . DSRunJob . . . . . . DSSendMail . . . . . . DSSetGenerateOpMetaData . DSSetJobLimit . . . . . DSSetParam . . . . . . DSSetUserStatus . . . . DSStopJob . . . . . . DSTransformError . . . . DSTranslateCode . . . . DSWaitForFile . . . . . DSWaitForJob . . . . . Job Status Macros . . . . Command line interface . . Commands for controlling DataStage jobs . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . WebSphere . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
869 870 871 871 872 873 873 874 874 875 875 876 876 877 877 878
Commands for administering WebSphere DataStage . . . . . . . . . . . Commands for searching jobs . . . . . XML schemas and sample stylesheets . . .
. . .
Index . . . . . . . . . . . . . . . 903
. 878
Contents
xiii
xiv
Chapter 1. Introduction
This manual is intended for the IBM WebSphere DataStage user who has mastered the basics of parallel job design and now wants to progress further. The manual covers the following topics: v Job Design Tips. This chapter contains miscellaneous tips about designing parallel jobs, from use of the WebSphere DataStage Designer interface to handling large volumes of data. v Improving Performance. This chapter describes methods by which you can evaluate the performance of your parallel job designs and come up with strategies for improving them. v Link Buffering. This chapter contains an in-depth description of when and how WebSphere DataStage buffers data within a job, and how you can change the automatic settings if required. v Specifying Your Own Parallel Stages. This chapter describe the interface WebSphere DataStage provides for defining your own parallel job stage types. v Environment Variables. This chapter list all the environment variables that are available for affecting the set up and operation of parallel jobs. v Operators. A number of chapters describe the operators that underlie the parallel job stages. v WebSphere DataStage Development Kit (Job Control Interfaces). This chapter lists the various interfaces that enable you to run and control WebSphere DataStage jobs without using the WebSphere DataStage Director client.
Terminology
Because of the technical nature of some of the descriptions in this manual, it sometimes talks about details of the engine that drives parallel jobs. This involves the use of terms that may be unfamiliar to ordinary parallel job users. v Operators. These underlie the stages in a WebSphere DataStage job. A single stage may correspond to a single operator, or a number of operators, depending on the properties you have set, and whether you have chosen to partition or collect or sort data on the input link to a stage. At compilation, WebSphere DataStage evaluates your job design and will sometimes optimize operators out if they are judged to be superfluous, or insert other operators if they are needed for the logic of the job. v OSH. This is the scripting language used internally by the WebSphere DataStage parallel engine. v Players. Players are the workhorse processes in a parallel job. There is generally a player for each operator on each node. Players are the children of section leaders; there is one section leader per processing node. Section leaders are started by the conductor process running on the conductor node (the conductor node is defined in the configuration file).
Modular development
You should aim to use modular development techniques in your job designs in order to maximize the reuse of parallel jobs and components and save yourself time.
v Use job parameters in your design and supply values at run time. This allows a single job design to process different data in different circumstances, rather than producing multiple copies of the same job with slightly different arguments. v Using job parameters allows you to exploit the WebSphere DataStage Directors multiple invocation capability. You can run several invocations of a job at the same time with different runtime arguments. v Use shared containers to share common logic across a number of jobs. Remember that shared containers are inserted when a job is compiled. If the shared container is changed, the jobs using it will need recompiling.
Avoid reading from sequential files using the Same partitioning method.
Unless you have specified more than one source file, this will result in the entire file being read into a single partition, making the entire downstream flow run sequentially unless you explicitly repartition (see Using Sequential File Stages for more tips on using Sequential file stages).
Combining data
The two major ways of combining data in a WebSphere DataStage job are via a Lookup stage or a Join stage. How do you decide which one to use? Lookup and Join stages perform equivalent operations: combining two or more input data sets based on one or more specified keys. When one unsorted input is very large or sorting is not feasible, Lookup is preferred. When all inputs are of manageable size or are pre-sorted, Join is the preferred solution.
The Lookup stage is most appropriate when the reference data for all Lookup stages in a job is small enough to fit into available physical memory. Each lookup reference requires a contiguous block of physical memory. The Lookup stage requires all but the first input (the primary input) to fit into physical memory. If the reference to a lookup is directly from a DB2 or Oracle table and the number of input rows is significantly smaller than the reference rows, 1:100 or more, a Sparse Lookup may be appropriate. If performance issues arise while using Lookup, consider using the Join stage. The Join stage must be used if the data sets are larger than available memory resources.
Sorting data
Look at job designs and try to reorder the job flow to combine operations around the same sort keys if possible, and coordinate your sorting strategy with your hashing strategy. It is sometimes possible to rearrange the order of business logic within a job flow to leverage the same sort order, partitioning, and groupings. If data has already been partitioned and sorted on a set of key columns, specify the dont sort, previously sorted option for the key columns in the Sort stage. This reduces the cost of sorting and takes greater advantage of pipeline parallelism. When writing to parallel data sets, sort order and partitioning are preserved. When reading from these data sets, try to maintain this sorting if possible by using Same partitioning method. The stable sort option is much more expensive than non-stable sorts, and should only be used if there is a need to maintain row order other than as needed to perform the sort. The performance of individual sorts can be improved by increasing the memory usage per partition using the Restrict Memory Usage (MB) option of the Sort stage. The default setting is 20 MB per partition. Note that sort memory usage can only be specified for standalone Sort stages, it cannot be changed for inline (on a link) sorts.
Destination Field Source Field int8 int32 uint32 int64 uint64 sfloat dfloat decimal string ustring raw date time time stamp dm d dm d dm dm dm dm dm m m m m m uint8 d d d d d d d d d int16 d d d d d d d dm dm uint16 d d d d d d d d d d d d d d dm d d m m m m m m m d d d d d dm dm d d d dm d d d d dm d d d d d d dm dm dm int32 uint32 d int64 d d uint64 d d d sfloat d d d d dfloat d d d d d
Source Field decimal int8 uint8 int16 uint16 int32 uint32 int64 uint64 sfloat dfloat decimal string ustring raw date time timestamp m m m m m m m m m dm dm dm d d d d d d d d d d dm string dm d dm dm dm m d d d dm dm ustring dm d dm dm dm m d d d dm dm d m m m m m m m m m m raw date m time m timestamp m
d = default conversion; m = modify operator conversion; blank = no conversion needed or provided You should also note the following points about type conversion: v When converting from variable-length to fixed-length strings using default conversions, parallel jobs pad the remaining length with NULL (ASCII zero) characters.
v 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). v 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.
The default value is 2. Setting this too low on a large system can result in so many players that the job fails due to insufficient resources. v requestedsessions. This is a number between 1 and the number of vprocs in the database. The default is the maximum number of available sessions.
10
Understanding a flow
In order to resolve any performance issues it is essential to have an understanding of the flow of WebSphere DataStage jobs.
Score dumps
To help understand a job flow we suggest you take a score dump. Do this by setting the APT_DUMP_SCORE environment variable true and running the job (APT _DUMP_SCORE can be set in the Administrator client, under the Parallel Reporting ranch). This causes a report to be produced which shows the operators, processes and data sets in the job. The report includes information about: v Where and how data is repartitioned. v Whether WebSphere DataStage had inserted extra operators in the flow. v The degree of parallelism each operator runs with, and on which nodes. v Information about where data is buffered. The dump score information is included in the job log when you run a job. The score dump is particularly useful in showing you where WebSphere DataStage is inserting additional components in the job flow. In particular WebSphere DataStage will add partition and sort operators where the logic of the job demands it. Sorts in particular can be detrimental to performance and a score dump can help you to detect superfluous operators and amend the job design to remove them.
11
Performance monitoring
There are various tools you can you use to aid performance monitoring, some provided with WebSphere DataStage and some general UNIX tools.
Job monitor
You access the WebSphere DataStage job monitor through the WebSphere DataStage Director (see WebSphere DataStage Director Client Guide). You can also use certain dsjob commands from the command line to access monitoring functions (see Retrieving Information for details). The job monitor provides a useful snapshot of a jobs performance at a moment of execution, but does not provide thorough performance metrics. That is, a job monitor snapshot should not be used in place of a full run of the job, or a run with a sample set of data. Due to buffering and to some job semantics, a snapshot image of the flow may not be a representative sample of the performance over the course of the entire job. The CPU summary information provided by the job monitor is useful as a first approximation of where time is being spent in the flow. However, it does not include any sorts or similar that may be inserted automatically in a parallel job. For these components, the score dump can be of assistance. See Score Dumps. A worst-case scenario occurs when a job flow reads from a data set, and passes immediately to a sort on a link. The job will appear to hang, when, in fact, rows are being read from the data set and passed to the sort. The operation of the job monitor is controlled by two environment variables: APT_MONITOR_TIME and APT_MONITOR_SIZE. By default the job monitor takes a snapshot every five seconds. You can alter the time interval by changing the value of APT_MONITOR_TIME, or you can have the monitor generate a new snapshot every so-many rows by following this procedure: 1. Select APT_MONITOR_TIME on the WebSphere DataStage Administrator environment variable dialog box, and press the set to default button. 2. Select APT_MONITOR_SIZE and set the required number of rows as the value for this variable.
12
Iostat
The UNIX tool Iostat is useful for examining the throughput of various disk resources. If one or more disks have high throughput, understanding where that throughput is coming from is vital. If there are spare CPU cycles, IO is often the culprit. The specifics of Iostat output vary slightly from system to system. Here is an example from a Linux machine which slows a relatively light load: (The first set of output is cumulative data since the machine was booted)
Device: tps dev8-0 13.50 ... Device: tps dev8-0 4.00 Blk_read/s 144.09 Blk_read/s 0.00 Blk_wrtn/s 122.33 Blk_read 346233038 Blk_wrtn 293951288
Load average
Ideally, a performant job flow should be consuming as much CPU as is available. The load average on the machine should be two to three times the value as the number of processors on the machine (for example, an 8-way SMP should have a load average of roughly 16-24). Some operating systems, such as HPUX, show per-processor load average. In this case, load average should be 2-3, regardless of number of CPUs on the machine. If the machine is not CPU-saturated, it indicates a bottleneck may exist elsewhere in the flow. A useful strategy in this case is to over-partition your data, as more partitions cause extra processes to be started, utilizing more of the available CPU power. If the flow cause the machine to be fully loaded (all CPUs at 100%), then the flow is likely to be CPU limited, and some determination needs to be made as to where the CPU time is being spent (setting the APT_PM_PLAYER _TIMING environment variable can be helpful here - see the following section). The commands top or uptime can provide the load average.
Runtime information
When you set the APT_PM_PLAYER_TIMING environment variable, information is provided for each operator in a job flow. This information is written to the job log when the job is run. An example output is:
##I TFPM 000324 08:59:32(004) ##I TFPM 000325 08:59:32(005) user: 0.00 sys: 0.00 suser: ##I TFPM 000324 08:59:32(006) ##I TFPM 000325 08:59:32(012) 0.00 sys: 0.00 suser: 0.09 ##I TFPM 000324 08:59:32(013) ##I TFPM 000325 08:59:32(019) 0.00 sys: 0.00 suser: 0.09 <generator,0> Calling runLocally: step=1, node=rh73dev04, op=0, ptn=0 <generator,0> Operator completed. status: APT_StatusOk elapsed: 0.04 0.09 ssys: 0.02 (total CPU: 0.11) <peek,0> Calling runLocally: step=1, node=rh73dev04, op=1, ptn=0 <peek,0> Operator completed. status: APT_StatusOk elapsed: 0.01 user: ssys: 0.02 (total CPU: 0.11) <peek,1> Calling runLocally: step=1, node=rh73dev04a, op=1, ptn=1 <peek,1> Operator completed. status: APT_StatusOk elapsed: 0.00 user: ssys: 0.02 (total CPU: 0.11)}
This output shows us that each partition of each operator has consumed about one tenth of a second of CPU time during its runtime portion. In a real world flow, wed see many operators, and many partitions. It is often useful to see how much CPU each operator (and each partition of each component) is using. If one partition of an operator is using significantly more CPU than others, it may mean the data is partitioned in an unbalanced way, and that repartitioning, or choosing different partitioning keys might be a useful strategy.
13
If one operator is using a much larger portion of the CPU than others, it may be an indication that youve discovered a problem in your flow. Common sense is generally required here; a sort is going to use dramatically more CPU time than a copy. This will, however, give you a sense of which operators are the CPU hogs, and when combined with other metrics presented in this document can be very enlightening. Setting the environment variable APT_DISABLE_COMBINATION may be useful in some situations to get finer-grained information as to which operators are using up CPU cycles. Be aware, however, that setting this flag will change the performance behavior of your flow, so this should be done with care. Unlike the job monitor cpu percentages, setting APT_PM_PLAYER_TIMING will provide timings on every operator within the flow.
Performance data
New in this release, you can record performance data about job objects and computer resource utilization in parallel job runs. You can record performance data in these ways: v At design time, with the Designer client v At run time, with either the Designer client or the Director client Performance data is written to an XML file that is in the default directory C:\IBM\InformationServer\ Server\Performance. You can override the default location by setting the environment variable APT_PERFORMANCE_DATA. Use the Administrator client to set a value for this variable at the project level, or use the Parameters page of the Job Properties window to specify a value at the job level. A job can take up to 5% longer when you record performance data. You can run jobs from the command line by using the dsjob command, but you must view performance data in the Designer client or the Director client.
Performance data is recorded each time that the job runs successfully.
14
Performance analysis
Once you have carried out some performance monitoring, you can analyze your results.
Chapter 3. Improving performance
15
Bear in mind that, in a parallel job flow, certain operators may complete before the entire flow has finished, but the job isnt successful until the slowest operator has finished all its processing.
16
You can diagnose a buffering tuning issue when a flow runs slowly when it is one massive flow, but each component runs quickly when broken up. For example, replacing an Oracle write stage with a copy stage vastly improves performance, and writing that same data to a data set, then loading via an Oracle stage, also goes quickly. When the two are put together, performance is poor. Buffering details specific, common buffering configurations aimed at resolving various bottlenecks.
Resource estimation
New in this release, you can estimate and predict the resource utilization of parallel job runs by creating models and making projections in the Resource Estimation window. A model estimates the system resources for a job, including the amount of scratch space, disk space, and CPU time that is needed for each stage to run on each partition. A model also estimates the data set throughput in a job. You can generate these types of models: v Static models estimate disk space and scratch space only. These models are based on a data sample that is automatically generated from the record schema. Use static models at compilation time. v Dynamic models predict disk space, scratch space, and CPU time. These models are based on a sampling of actual input data. Use dynamic models at run time. An input projection estimates the size of all of the data sources in a job. You can project the size in megabytes or in number of records. A default projection is created when you generate a model. The resource utilization results from a completed job run are treated as an actual model. A job can have only one actual model. In the Resource Estimation window, the actual model is the first model in the Models list. Similarly, the total size of the data sources in a completed job run are treated as an actual projection. You must select the actual projection in the Input Projections list to view the resource utilization statistics in the actual model. You can compare the actual model to your generated models to calibrate your modeling techniques.
Creating a model
You can create a static or dynamic model to estimate the resource utilization of a parallel job run. You can create models in the Designer client or the Director client. You must compile a job before you create a model. To create a model: 1. Open a job in the Designer client, or select a job in the Director client. 2. Open the Resource Estimation window by using one of the following methods: v In the Designer, click File Estimate Resource. v In the Director, click Job Estimate Resource. v Click the Resource Estimation toolbar button. The first time that you open the Resource Estimation window for a job, a static model is generated by default. Click the Model toolbar button to display the Create Resource Model options. Type a name in the Model Name field. The specified name must not already exist. Select a type in the Model Type field. If you want to specify a data sampling range for a dynamic model, use one of the following methods: v Click the Copy Previous button to copy the sampling specifications from previous models, if any exist. v Clear the Auto check box for a data source, and type values in the From and To fields to specify a record range.
Chapter 3. Improving performance
3. 4. 5. 6.
17
7. Click Generate. After the model is created, the Resource Estimation window displays an overview of the model that includes the model type, the number of data segments in the model, the input data size, and the data sampling description for each input data source. Use the controls in the left pane of the Resource Estimation window to view statistics about partition utilization, data set throughput, and operator utilization in the model. You can also compare the model to other models that you generate.
Requires automatic data sampling. Accepts automatic data sampling or a Uses the actual size of the input data data range: if the size can be determined. v Automatic data sampling Otherwise, the sample size is set to a determines the sample size default value of 1000 records on each dynamically according to the stage output link from each source stage. type: For a database source stage, the sample size is set to 1000 records on each output link from the stage. For all other source stage types, the sample size is set to the minimum number of input records among all sources on all partitions. v A data range specifies the number of records to include in the sample for each data source. If the size of the sample data exceeds the actual size of the input data, the model uses the entire input data set.
Estimates are based on a worst-case scenario. Estimates are based on a worst-case scenario. Not estimated. Estimates are based on a best-case scenario. No record is dropped. Input data is propagated from the source stages to all other stages in the job. Solely determined by the record schema. Estimates are based on a worst-case scenario.
Estimates are based on linear regression. Estimates are based on linear regression. Estimates are based on linear regression. Dynamically determined. Best-case scenario does not apply. Input data is processed, not propagated. Records can be dropped. Estimates are based on linear regression. Dynamically determined by the actual record at run time. Estimates are based on linear regression.
Record size
18
When a model is based on a worst-case scenario, the model uses maximum values. For example, if a variable can hold up to 100 characters, the model assumes that the variable always holds 100 characters. When a model is based on a best-case scenario, the model assumes that no single input record is dropped anywhere in the data flow. The accuracy of a model depends on these factors: Schema definition The size of records with variable-length fields cannot be determined until the records are processed. Use fixed-length or bounded-length schemas as much as possible to improve accuracy. Input data When the input data contains more records with one type of key field than another, the records might be unevenly distributed across partitions. Specify a data sampling range that is representative of the input data. Parallel processing environment The availability of system resources when you run a job can affect the degree to which buffering occurs. Generate models in an environment that is similar to your production environment in terms of operating system, processor type, and number of processors.
Custom stages that need disk space and scratch space must call two additional functions within the dynamic scope of APT_Operator::runLocally(): v For disk space, call APT_Operator::setDiskSpace() to describe actual disk space usage. v For scratch space, call APT_Operator::setScratchSpace() to describe actual scratch space usage. Both functions accept values of APT_Int64.
Making a projection
You can make a projection to predict the resource utilization of a job by specifying the size of the data sources.
19
You must generate at least one model before you make a projection. Projections are applied to all existing models, except the actual model. To make a projection: 1. Open a job in the Designer client, or select a job in the Director client. 2. Open the Resource Estimation window by using one of the following methods: v In the Designer, click File Estimate Resource. v In the Director, click Job Estimate Resource. v Click the Resource Estimation toolbar button. Click the Projection toolbar button to display the Make Resource Projection options. Type a name in the Projection Name field. The specified name must not already exist. Select the unit of measurement for the projection in the Input Units field. Specify the input size upon which to base the projection by using one of the following methods:
3. 4. 5. 6.
v Click the Copy Previous button to copy the specifications from previous projections, if any exist. v If the Input Units field is set to Size in Megabytes, type a value in the Megabytes (MB) field for each data source. v If the Input Units field is set to Number of Records, type a value in the Records field for each data source. 7. Click Generate. The projection applies the input data information to the existing models, excluding the actual model, to predict the resource utilization for the given input data.
20
v Updates records in the fourth data source with the current date v Saves the merged records to two different data sets based on the value of a specific field In this example, each data source has 5 million records. You can use resource estimation models and projections to answer questions such as these: v Which stage merges data most efficiently? v When should data be sorted? v Are there any performance bottlenecks? v What are the disk and scratch space requirements if the size of the input data increases?
By comparing the models, you see that Job 1 does not require any scratch space, but is the slowest of the three jobs. The Lookup stage also requires memory to build a lookup table for a large amount of reference data. Therefore, the optimal job design uses either a Merge stage or a Join stage to merge data.
21
v Job 4 sorts the data first: 1. Each data source is linked to a separate Sort stage. 2. The sorted data is sent to a single Funnel stage for consolidation. 3. The Funnel stage sends the data to the Merge or Join stage, where it is merged with the data from the fourth data source. v Job 5 consolidates the data first: 1. The three source stages are linked to a single Funnel stage that consolidates the data. 2. The consolidated data is sent to a single Sort stage for sorting. 3. The Sort stage sends the data to the Merge or Join stage, where it is merged with the data from the fourth data source. Use the same processing configuration as in the first example to generate an automatic dynamic model for each job. The resource utilization statistics for each job are shown in the table:
Job Job 4 (Sort before Funnel) Job 5 (Sort after Funnel) CPU (seconds) 74.6812 64.1079 Disk (MB) 515.125 515.125 Scratch (MB) 801.086 743.866
You can see that sorting data after consolidation is a better design because Job 5 uses approximately 15% less CPU time and 8% less scratch space than Job 4.
Job 6 (Merge stage with job 109.065 parameter in Transformer stage) Job 7 (Join stage with job parameter in Transformer stage) 106.5
801.125
915.527
22
Job performance is significantly improved after you remove the bottleneck in the Transformer stage. Total CPU time for Jobs 6 and 7 is about half of the total CPU time for Jobs 2 and 3. CPU time for the Transformer stage is a small portion of total CPU time: v In Job 6, the Transformer stage uses 13.8987 seconds out of the 109.065 seconds of total CPU time for the job. v In Job 7, the Transformer stage uses 13.1489 seconds out of the 106.5 seconds of total CPU time for the job. These models also show that job performance improves by approximately 2.4% when you merge data by using a Join stage rather than a Merge stage.
23
Combinable Operators
Combined operators generally improve performance at least slightly (in some cases the difference is dramatic). There may also be situations where combining operators actually hurts performance, however. Identifying such operators can be difficult without trial and error. The most common situation arises when multiple operators are performing disk I/O (for example, the various file stages and sort). In these sorts of situations, turning off combination for those specific stages may result in a performance increase if the flow is I/O bound. Combinable operators often provide a dramatic performance increase when a large number of variable length fields are used in a flow.
Disk I/O
Total disk throughput is often a fixed quantity that WebSphere DataStage has no control over. It can, however, be beneficial to follow some rules. v If data is going to be read back in, in parallel, it should never be written as a sequential file. A data set or file set stage is a much more appropriate format. v When importing fixed-length data, the Number of Readers per Node property on the Sequential File stage can often provide a noticeable performance boost as compared with a single process reading the data. v Some disk arrays have read ahead caches that are only effective when data is read repeatedly in like-sized chunks. Setting the environment variable APT_CONSISTENT_BUFFERIO_SIZE=N will force stages to read data in chunks which are size N or a multiple of N. v Memory mapped I/O, in many cases, contributes to improved performance. In certain situations, however, such as a remote disk mounted via NFS, memory mapped I/O may cause significant performance problems. Setting the environment variables APT_IO_NOMAP and APT_BUFFERIO_NOMAP true will turn off this feature and sometimes affect performance. (AIX and HP-UX default to NOMAP. Setting APT_IO_MAP and APT_BUFFERIO_MAP true can be used to turn memory mapped I/O on for these platforms.)
24
Buffering
Buffering is intended to slow down input to match the consumption rate of the output. When the downstream operator reads very slowly, or not at all, for a length of time, upstream operators begin to slow down. This can cause a noticeable performance loss if the buffers optimal behavior is something other than rate matching. By default, each link has a 3 MB in-memory buffer. Once that buffer reaches half full, the operator begins to push back on the upstream operators rate. Once the 3 MB buffer is filled, data is written to disk in 1 MB chunks. In most cases, the easiest way to tune buffering is to eliminate the pushback and allow it to buffer the data to disk as necessary. Setting APT_BUFFER_FREE_RUN=N or setting Buffer Free Run in the Output page Advanced tab on a particular stage will do this. A buffer will read N * max_memory (3 MB by default) bytes before beginning to push back on the upstream. If there is enough disk space to buffer large amounts of data, this will usually fix any egregious slowdown issues cause by the buffer operator. If there is a significant amount of memory available on the machine, increasing the maximum in-memory buffer size is likely to be very useful if buffering is causing any disk I/O. Setting the APT_BUFFER_MAXIMUM_MEMORY environment variable or Maximum memory buffer size on the Output page Advanced tab on a particular stage will do this. It defaults to 3145728 (3 MB). For systems where small to medium bursts of I/O are not desirable, the 1 MB write to disk size chunk size may be too small. The environment variable APT_BUFFER_DISK_WRITE_INCREMENT or Disk write increment on the Output page Advanced tab on a particular stage controls this and defaults to 1048576 (1 MB). This setting may not exceed max_memory * 2/3. Finally, in a situation where a large, fixed buffer is needed within the flow, setting Queue upper bound on the Output page Advanced tab (no environment variable exists) can be set equal to max_memory to force a buffer of exactly max_memory bytes. Such a buffer will block an upstream operator (until data is read by the downstream operator) once its buffer has been filled, so this setting should be used with extreme caution. This setting is rarely, if ever, necessary to achieve good performance, but may be useful in an attempt to squeeze every last byte of performance out of the system where it is desirable to eliminate buffering to disk entirely. No environment variable is available for this flag, and therefore this can only be set at the individual stage level.
25
Some environments have experienced better memory management when the vm_swap_eager kernel is set. This swaps out idle processes more quickly, allowing more physical memory for parallel jobs. A higher degree of parallelism may be available as a result of this setting, but system interactivity may suffer as a result. We recommend that you set the environment variable APT_PM_NO_SHARED memory for Tru64 version 51A (only).
HP-UX
HP-UX has a limitation when running in 32-bit mode, which limits memory mapped I/O to 2 GB per machine. This can be an issue when dealing with large lookups. The Memory Windows options can provide a work around for this memory limitation. Product Support can provide this document on request.
AIX
If you are running WebSphere DataStage Enterprise Edition on an RS/6000 SP or a network of workstations, verify your setting of the network parameter thewall .
26
Buffering assumptions
This section describes buffering in more detail, and in particular the design assumptions underlying its default behavior. Buffering in WebSphere DataStage is designed around the following assumptions: v Buffering is primarily intended to remove the potential for deadlock in flows with fork-join structure. v Throughput is preferable to overhead. The goal of the WebSphere DataStage buffering mechanism is to keep the flow moving with as little memory and disk usage as possible. Ideally, data should simply stream through the data flow and rarely land to disk. Upstream operators should tend to wait for downstream operators to consume their input before producing new data records. v Stages in general are designed so that on each link between stages data is being read and written whenever possible. While buffering is designed to tolerate occasional backlog on specific links due to one operator getting ahead of another, it is assumed that operators are at least occasionally attempting to read and write data on each link. Buffering is implemented by the automatic insertion of a hidden buffer operator on links between stages. The buffer operator attempts to match the rates of its input and output. When no data is being read from the buffer operator by the downstream stage, the buffer operator tries to throttle back incoming data from the upstream stage to avoid letting the buffer grow so large that it must be written out to disk. The goal is to avoid situations where data will be have to be moved to and from disk needlessly, especially in situations where the consumer cannot process data at the same rate as the producer (for example, due to a more complex calculation). Because the buffer operator wants to keep the flow moving with low overhead, it is assumed in general that it is better to cause the producing stage to wait before writing new records, rather than allow the buffer operator to consume resources.
27
Controlling buffering
WebSphere DataStage offers two ways of controlling the operation of buffering: you can use environment variables to control buffering on all links of all stages in all jobs, or you can make individual settings on the links of particular stages via the stage editors.
Buffering policy
You can set this via the APT_BUFFERING_POLICY environment variable, or via the Buffering mode field on the Inputs or Outputs page Advanced tab for individual stage editors. The environment variable has the following possible values: v AUTOMATIC_BUFFERING. Buffer a data set only if necessary to prevent a dataflow deadlock. This setting is the default if you do not define the environment variable. v FORCE_BUFFERING. Unconditionally buffer all links. v NO_BUFFERING. Do not buffer links. This setting can cause deadlock if used inappropriately. The possible settings for the Buffering mode field are: v (Default). This will take whatever the default settings are as specified by the environment variables (this will be Auto buffer unless you have explicitly changed the value of the APT_BUFFERING _POLICY environment variable). v Auto buffer. Buffer data only if necessary to prevent a dataflow deadlock situation. v Buffer. This will unconditionally buffer all data output from/input to this stage. v No buffer. Do not buffer data under any circumstances. This could potentially lead to deadlock situations if not used carefully.
28
disk access, but may decrease performance when data is being read/written in smaller units. Decreasing the block size increases throughput, but may increase the amount of disk access. v APT_BUFFER_FREE_RUN. Specifies how much of the available in-memory buffer to consume before the buffer offers resistance to any new data being written to it, as a percentage of Maximum memory buffer size. When the amount of buffered data is less than the Buffer free run percentage, input data is accepted immediately by the buffer. After that point, the buffer does not immediately accept incoming data; it offers resistance to the incoming data by first trying to output data already in the buffer before accepting any new input. In this way, the buffering mechanism avoids buffering excessive amounts of data and can also avoid unnecessary disk I/O. The default percentage is 0.5 (50% of Maximum memory buffer size or by default 1.5 MB). You must set Buffer free run greater than 0.0. Typical values are between 0.0 and 1.0. You can set Buffer free run to a value greater than 1.0. In this case, the buffer continues to store data up to the indicated multiple of Maximum memory buffer size before writing data to disk. The available settings in the Input or Outputs pageAdvanced tab of stage editors are: v Maximum memory buffer size (bytes). Specifies the maximum amount of virtual memory, in bytes, used per buffer. The default size is 3145728 (3 MB). v Buffer free run (percent). Specifies how much of the available in-memory buffer to consume before the buffer resists. This is expressed as a percentage of Maximum memory buffer size. When the amount of data in the buffer is less than this value, new data is accepted automatically. When the data exceeds it, the buffer first tries to write some of the data it contains before accepting more. The default value is 50% of the Maximum memory buffer size. You can set it to greater than 100%, in which case the buffer continues to store data up to the indicated multiple of Maximum memory buffer size before writing to disk. v Queue upper bound size (bytes). Specifies the maximum amount of data buffered at any time using both memory and disk. The default value is zero, meaning that the buffer size is limited only by the available disk space as specified in the configuration file (resource scratchdisk). If you set Queue upper bound size (bytes) to a non-zero value, the amount of data stored in the buffer will not exceed this value (in bytes) plus one block (where the data stored in a block cannot exceed 32 KB). If you set Queue upper bound size to a value equal to or slightly less than Maximum memory buffer size, and set Buffer free run to 1.0, you will create a finite capacity buffer that will not write to disk. However, the size of the buffer is limited by the virtual memory of your system and you can create deadlock if the buffer becomes full. (Note that there is no environment variable for Queue upper bound size). v Disk write increment (bytes). Sets the size, in bytes, of blocks of data being moved to/from disk by the buffering operator. The default is 1048576 (1 MB). Adjusting this value trades amount of disk access against throughput for small amounts of data. Increasing the block size reduces disk access, but may decrease performance when data is being read/written in smaller units. Decreasing the block size increases throughput, but may increase the amount of disk access.
29
The default setting for Buffer free run is 0.5 for the environment variable, (50% for Buffer free run on the Advanced tab), which means that half of the internal memory buffer can be consumed before pushback occurs. This biases the buffer operator to avoid allowing buffered data to be written to disk. If your stage needs to buffer large data sets, we recommend that you initially set Buffer free run to a very large value such as 1000, and then adjust according to the needs of your application. This will allow the buffer operator to freely use both memory and disk space in order to accept incoming data without pushback. We recommend that you set the Buffer free run property only for those links between stages that require a non-default value; this means altering the setting on the Inputs page or Outputs page Advanced tab of the stage editors, not the environment variable.
30
31
v Partitioning. Choose the default partitioning method for the stage. This is the method that will appear in the Inputs page Partitioning tab of the stage editor. You can override this method for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the partitioning methods. v Collecting. Choose the default collection method for the stage. This is the method that will appear in the Inputs page Partitioning tab of the stage editor. You can override this method for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the collection methods. v Operator. Enter the name of the Orchestrate operator that you want the stage to invoke. v Short Description. Optionally enter a short description of the stage. v Long Description. Optionally enter a long description of the stage. 3. Go to the Links page and specify information about the links allowed to and from the stage you are defining. Use this to specify the minimum and maximum number of input and output links that your custom stage can have, and to enable the ViewData feature for target data (you cannot enable target ViewData if your stage has any output links). When the stage is used in a job design, a ViewData button appears on the Input page, which allows you to view the data on the actual data target (provided some has been written there). In order to use the target ViewData feature, you have to specify an Orchestrate operator to read the data back from the target. This will usually be different to the operator that the stage has used to write the data (i.e., the operator defined in the Operator field of the General page). Specify the reading operator and associated arguments in the Operator and Options fields. If you enable target ViewData, a further field appears in the Properties grid, called ViewData. 4. Go to the Creator page and optionally specify information about the stage you are creating. We recommend that you assign a version number to the stage so you can keep track of any subsequent changes. You can specify that the actual stage will use a custom GUI by entering the ProgID for a custom GUI in the Custom GUI Prog ID field. You can also specify that the stage has its own icon. You need to supply a 16 x 16 bit bitmap and a 32 x 32 bit bitmap to be displayed in various places in the WebSphere DataStage user interface. Click the 16 x 16 Bitmap button and browse for the smaller bitmap file. Click the 32 x 32 Bitmap button and browse for the large bitmap file. Note that bitmaps with 32-bit color are not supported. Click the Reset Bitmap Info button to revert to using the default WebSphere DataStage icon for this stage. 5. Go to the Properties page. This allows you to specify the options that the Orchestrate operator requires as properties that appear in the Stage Properties tab. For custom stages the Properties tab always appears under the Stage page. 6. Fill in the fields as follows: v Property name. The name of the property. v Data type. The data type of the property. Choose from: Boolean Float Integer String Pathname List Input Column Output Column If you choose Input Column or Output Column, when the stage is included in a job a drop-down list will offer a choice of the defined input or output columns.
32
If you choose list you should open the Extended Properties dialog box from the grid shortcut menu to specify what appears in the list. v Prompt. The name of the property that will be displayed on the Properties tab of the stage editor. v Default Value. The value the option will take if no other is specified. v Required. Set this to True if the property is mandatory. v Repeats. Set this true if the property repeats (i.e., you can have multiple instances of it). v Use Quoting. Specify whether the property will haves quotes added when it is passed to the Orchestrate operator. v Conversion. Specifies the type of property as follows: -Name. The name of the property will be passed to the operator as the option value. This will normally be a hidden property, i.e., not visible in the stage editor. -Name Value. The name of the property will be passed to the operator as the option name, and any value specified in the stage editor is passed as the value. -Value. The value for the property specified in the stage editor is passed to the operator as the option name. Typically used to group operator options that are mutually exclusive. Value only. The value for the property specified in the stage editor is passed as it is. Input Schema. Specifies that the property will contain a schema string whose contents are populated from the Input page Columns tab. Output Schema. Specifies that the property will contain a schema string whose contents are populated from the Output page Columns tab. None. This allows the creation of properties that do not generate any osh, but can be used for conditions on other properties (for example, for use in a situation where you have mutually exclusive properties, but at least one of them must be specified). Schema properties require format options. Select this check box to specify that the stage being specified will have a Format tab. If you have enabled target ViewData on the Links page, the following property is also displayed: ViewData. Select Yes to indicate that the value of this property should be used when viewing data. For example, if this property specifies a file to write to when the stage is used in a job design, the value of this property will be used to read the data back if ViewData is used in the stage. If you select a conversion type of Input Schema or Output Schema, you should note the following: Data Type is set to String. Required is set to Yes. The property is marked as hidden and will not appear on the Properties page when the custom stage is used in a job design. If your stage can have multiple input or output links there would be a Input Schema property or Output Schema property per-link. When the stage is used in a job design, the property will contain the following OSH for each input and/or output link:
-property_name record {format_properties} ( column_definition {format_properties}; ...)
v v v
Where: v property_name is the name of the property (usually `schema) v format_properties are formatting information supplied on the Format page (if the stage has one). v there is one column_definition for each column defined in the Columns tab for that link. The format_props in this case refers to per-column format information specified in the Edit Column Meta Data dialog box.
33
Schema properties are mutually exclusive with schema file properties. If your custom stage supports both, you should use the Extended Properties dialog box to specify a condition of schemafile= for the schema property. The schema property is then only valid provided the schema file property is blank (or does not exist). 7. If you want to specify a list property, or otherwise control how properties are handled by your stage, choose Extended Properties from the Properties grid shortcut menu to open the Extended Properties dialog box. The settings you use depend on the type of property you are specifying: v Specify a category to have the property appear under this category in the stage editor. By default all properties appear in the Options category. v Specify that the property will be hidden and not appear in the stage editor. This is primarily intended to support the case where the underlying operator needs to know the JobName. This can be passed using a mandatory String property with a default value that uses a DS Macro. However, to prevent the user from changing the value, the property needs to be hidden. v If you are specifying a List category, specify the possible values for list members in the List Value field. v If the property is to be a dependent of another property, select the parent property in the Parents field. v Specify an expression in the Template field to have the actual value of the property generated at compile time. It is usually based on values in other properties and columns. v Specify an expression in the Conditions field to indicate that the property is only valid if the conditions are met. The specification of this property is a bar | separated list of conditions that are ANDed together. For example, if the specification was a=b|c!=d, then this property would only be valid (and therefore only available in the GUI) when property a is equal to b, and property c is not equal to d. 8. If your custom stage will create columns, go to the Mapping Additions page. It contains a grid that allows for the specification of columns created by the stage. You can also specify that column details are filled in from properties supplied when the stage is used in a job design, allowing for dynamic specification of columns. The grid contains the following fields: v Column name. The name of the column created by the stage. You can specify the name of a property you specified on the Property page of the dialog box to dynamically allocate the column name. Specify this in the form #property_name#, the created column will then take the value of this property, as specified at design time, as the name of the created column. v Parallel type. The type of the column (this is the underlying data type, not the SQL data type). Again you can specify the name of a property you specified on the Property page of the dialog box to dynamically allocate the column type. Specify this in the form #property_name#, the created column will then take the value of this property, as specified at design time, as the type of the created column. (Note that you cannot use a repeatable property to dynamically allocate a column type in this way.) v Nullable. Choose Yes or No to indicate whether the created column can contain a null. v Conditions. Allows you to enter an expression specifying the conditions under which the column will be created. This could, for example, depend on the setting of one of the properties specified in the Property page. You can propagate the values of the Conditions fields to other columns if required. Do this by selecting the columns you want to propagate to, then right-clicking in the source Conditions field and choosing Propagate from the shortcut menu. A dialog box asks you to confirm that you want to propagate the conditions to all columns. 9. Click OK when you are happy with your custom stage definition. The Save As dialog box appears. 10. Select the folder in the repository tree where you want to store the stage type and click OK.
34
35
If you enable target ViewData, a further field appears in the Properties grid, called ViewData. 4. Go to the Creator page and optionally specify information about the stage you are creating. We recommend that you assign a version number to the stage so you can keep track of any subsequent changes. You can specify that the actual stage will use a custom GUI by entering the ProgID for a custom GUI in the Custom GUI Prog ID field. You can also specify that the stage has its own icon. You need to supply a 16 x 16 bit bitmap and a 32 x 32 bit bitmap to be displayed in various places in the WebSphere DataStage user interface. Click the 16 x 16 Bitmap button and browse for the smaller bitmap file. Click the 32 x 32 Bitmap button and browse for the large bitmap file. Note that bitmaps with 32-bit color are not supported. Click the Reset Bitmap Info button to revert to using the default WebSphere DataStage icon for this stage. 5. Go to the Properties page. This allows you to specify the options that the Orchestrate operator requires as properties that appear in the Stage Properties tab. For custom stages the Properties tab always appears under the Stage page. 6. Fill in the fields as follows: v Property name. The name of the property. v Data type. The data type of the property. Choose from: Boolean Float Integer String Pathname List Input Column Output Column If you choose Input Column or Output Column, when the stage is included in a job a drop-down list will offer a choice of the defined input or output columns. If you choose list you should open the Extended Properties dialog box from the grid shortcut menu to specify what appears in the list. Prompt. The name of the property that will be displayed on the Properties tab of the stage editor. Default Value. The value the option will take if no other is specified. Required. Set this to True if the property is mandatory. Repeats. Set this true if the property repeats (i.e., you can have multiple instances of it). Use Quoting. Specify whether the property will haves quotes added when it is passed to the Orchestrate operator. Conversion. Specifies the type of property as follows: -Name. The name of the property will be passed to the operator as the option value. This will normally be a hidden property, i.e., not visible in the stage editor. -Name Value. The name of the property will be passed to the operator as the option name, and any value specified in the stage editor is passed as the value. -Value. The value for the property specified in the stage editor is passed to the operator as the option name. Typically used to group operator options that are mutually exclusive. Value only. The value for the property specified in the stage editor is passed as it is. Input Schema. Specifies that the property will contain a schema string whose contents are populated from the Input page Columns tab. Output Schema. Specifies that the property will contain a schema string whose contents are populated from the Output page Columns tab.
v v v v v v
36
None. This allows the creation of properties that do not generate any osh, but can be used for conditions on other properties (for example, for use in a situation where you have mutually exclusive properties, but at least one of them must be specified). v Schema properties require format options. Select this check box to specify that the stage being specified will have a Format tab. If you have enabled target ViewData on the Links page, the following property is also displayed: v ViewData. Select Yes to indicate that the value of this property should be used when viewing data. For example, if this property specifies a file to write to when the stage is used in a job design, the value of this property will be used to read the data back if ViewData is used in the stage. If you select a conversion type of Input Schema or Output Schema, you should note the following: v Data Type is set to String. v Required is set to Yes. v The property is marked as hidden and will not appear on the Properties page when the custom stage is used in a job design. If your stage can have multiple input or output links there would be a Input Schema property or Output Schema property per-link. When the stage is used in a job design, the property will contain the following OSH for each input and/or output link:
-property_name record {format_properties} ( column_definition {format_properties}; ...)
Where: v property_name is the name of the property (usually `schema) v format_properties are formatting information supplied on the Format page (if the stage has one). v there is one column_definition for each column defined in the Columns tab for that link. The format_props in this case refers to per-column format information specified in the Edit Column Meta Data dialog box. Schema properties are mutually exclusive with schema file properties. If your custom stage supports both, you should use the Extended Properties dialog box to specify a condition of schemafile= for the schema property. The schema property is then only valid provided the schema file property is blank (or does not exist). 7. If you want to specify a list property, or otherwise control how properties are handled by your stage, choose Extended Properties from the Properties grid shortcut menu to open the Extended Properties dialog box. The settings you use depend on the type of property you are specifying: v Specify a category to have the property appear under this category in the stage editor. By default all properties appear in the Options category. v Specify that the property will be hidden and not appear in the stage editor. This is primarily intended to support the case where the underlying operator needs to know the JobName. This can be passed using a mandatory String property with a default value that uses a DS Macro. However, to prevent the user from changing the value, the property needs to be hidden. v If you are specifying a List category, specify the possible values for list members in the List Value field. v If the property is to be a dependent of another property, select the parent property in the Parents field. v Specify an expression in the Template field to have the actual value of the property generated at compile time. It is usually based on values in other properties and columns. v Specify an expression in the Conditions field to indicate that the property is only valid if the conditions are met. The specification of this property is a bar | separated list of conditions that
37
are ANDed together. For example, if the specification was a=b|c!=d, then this property would only be valid (and therefore only available in the GUI) when property a is equal to b, and property c is not equal to d. 8. If your custom stage will create columns, go to the Mapping Additions page. It contains a grid that allows for the specification of columns created by the stage. You can also specify that column details are filled in from properties supplied when the stage is used in a job design, allowing for dynamic specification of columns. The grid contains the following fields: v Column name. The name of the column created by the stage. You can specify the name of a property you specified on the Property page of the dialog box to dynamically allocate the column name. Specify this in the form #property_name#, the created column will then take the value of this property, as specified at design time, as the name of the created column. v Parallel type. The type of the column (this is the underlying data type, not the SQL data type). Again you can specify the name of a property you specified on the Property page of the dialog box to dynamically allocate the column type. Specify this in the form #property_name#, the created column will then take the value of this property, as specified at design time, as the type of the created column. (Note that you cannot use a repeatable property to dynamically allocate a column type in this way.) v Nullable. Choose Yes or No to indicate whether the created column can contain a null. v Conditions. Allows you to enter an expression specifying the conditions under which the column will be created. This could, for example, depend on the setting of one of the properties specified in the Property page. You can propagate the values of the Conditions fields to other columns if required. Do this by selecting the columns you want to propagate to, then right-clicking in the source Conditions field and choosing Propagate from the shortcut menu. A dialog box asks you to confirm that you want to propagate the conditions to all columns. 9. Click OK when you are happy with your custom stage definition. The Save As dialog box appears. 10. Select the folder in the repository tree where you want to store the stage type and click OK.
38
The Code for the Build stage is specified in C++. There are a number of macros available to make the job of coding simpler (see Build Stage Macros. There are also a number of header files available containing many useful functions, see Appendix A. When you have specified the information, and request that the stage is generated, WebSphere DataStage generates a number of files and then compiles these to build an operator which the stage executes. The generated files include: v Header files (ending in .h) v Source files (ending in .c) v Object files (ending in .so) The following shows a build stage in diagrammatic form: To define a Build stage: 1. Do one of: a. Choose File New from the Designer menu. The New dialog box appears. b. Open the Stage Type folder and select the Parallel Build Stage Type icon. c. Click OK. TheStage Type dialog box appears, with the General page on top. Or: d. Select a folder in the repository tree. e. Choose New Other Parallel Stage Custom from the shortcut menu. The Stage Type dialog box appears, with the General page on top. 2. Fill in the fields on the General page as follows: v Stage type name. This is the name that the stage will be known by to WebSphere DataStage. Avoid using the same name as existing stages. v Class Name. The name of the C++ class. By default this takes the name of the stage type. v Parallel Stage type. This indicates the type of new parallel job stage you are defining (Custom, Build, or Wrapped). You cannot change this setting. v Execution mode. Choose the default execution mode. This is the mode that will appear in the Advanced tab on the stage editor. You can override this mode for individual instances of the stage as required, unless you select Parallel only or Sequential only. See WebSphere DataStage Parallel Job Developer Guide for a description of the execution mode. v Preserve Partitioning. This shows the default setting of the Preserve Partitioning flag, which you cannot change in a Build stage. This is the setting that will appear in the Advanced tab on the stage editor. You can override this setting for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the preserve partitioning flag. v Partitioning. This shows the default partitioning method, which you cannot change in a Build stage. This is the method that will appear in the Inputs Page Partitioning tab of the stage editor. You can override this method for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the partitioning methods. v Collecting. This shows the default collection method, which you cannot change in a Build stage. This is the method that will appear in the Inputs Page Partitioning tab of the stage editor. You can override this method for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the collection methods. v Operator. The name of the operator that your code is defining and which will be executed by the WebSphere DataStage stage. By default this takes the name of the stage type. v Short Description. Optionally enter a short description of the stage. v Long Description. Optionally enter a long description of the stage.
39
3. Go to the Creator page and optionally specify information about the stage you are creating. We recommend that you assign a release number to the stage so you can keep track of any subsequent changes. You can specify that the actual stage will use a custom GUI by entering the ProgID for a custom GUI in the Custom GUI Prog ID field. You can also specify that the stage has its own icon. You need to supply a 16 x 16 bit bitmap and a 32 x 32 bit bitmap to be displayed in various places in the WebSphere DataStage user interface. Click the 16 x 16 Bitmap button and browse for the smaller bitmap file. Click the 32 x 32 Bitmap button and browse for the large bitmap file. Note that bitmaps with 32-bit color are not supported. Click the Reset Bitmap Info button to revert to using the default WebSphere DataStage icon for this stage. 4. Go to the Properties page. This allows you to specify the options that the Build stage requires as properties that appear in the Stage Properties tab. For custom stages the Properties tab always appears under the Stage page. Fill in the fields as follows: v Property name. The name of the property. This will be passed to the operator you are defining as an option, prefixed with `- and followed by the value selected in the Properties tab of the stage editor. v Data type. The data type of the property. Choose from: Boolean Float Integer String Pathname List Input Column Output Column If you choose Input Column or Output Column, when the stage is included in a job a drop-down list will offer a choice of the defined input or output columns. If you choose list you should open the Extended Properties dialog box from the grid shortcut menu to specify what appears in the list. v Prompt. The name of the property that will be displayed on the Properties tab of the stage editor. v Default Value. The value the option will take if no other is specified. v Required. Set this to True if the property is mandatory. v Conversion. Specifies the type of property as follows: -Name. The name of the property will be passed to the operator as the option value. This will normally be a hidden property, i.e., not visible in the stage editor. -Name Value. The name of the property will be passed to the operator as the option name, and any value specified in the stage editor is passed as the value. -Value. The value for the property specified in the stage editor is passed to the operator as the option name. Typically used to group operator options that are mutually exclusive. Value only. The value for the property specified in the stage editor is passed as it is. 5. If you want to specify a list property, or otherwise control how properties are handled by your stage, choose Extended Properties from the Properties grid shortcut menu to open the Extended Properties dialog box. The settings you use depend on the type of property you are specifying: v Specify a category to have the property appear under this category in the stage editor. By default all properties appear in the Options category. v If you are specifying a List category, specify the possible values for list members in the List Value field.
40
v If the property is to be a dependent of another property, select the parent property in the Parents field. v Specify an expression in the Template field to have the actual value of the property generated at compile time. It is usually based on values in other properties and columns. v Specify an expression in the Conditions field to indicate that the property is only valid if the conditions are met. The specification of this property is a bar | separated list of conditions that are ANDed together. For example, if the specification was a=b|c!=d, then this property would only be valid (and therefore only available in the GUI) when property a is equal to b, and property c is not equal to d. Click OK when you are happy with the extended properties. 6. Click on the Build page. The tabs here allow you to define the actual operation that the stage will perform. The Interfaces tab enable you to specify details about inputs to and outputs from the stage, and about automatic transfer of records from input to output. You specify port details, a port being where a link connects to the stage. You need a port for each possible input link to the stage, and a port for each possible output link from the stage. You provide the following information on the Input sub-tab: v Port Name. Optional name for the port. The default names for the ports are in0, in1, in2 ... . You can refer to them in the code using either the default name or the name you have specified. v Alias. Where the port name contains non-ascii characters, you can give it an alias in this column (this is only available where NLS is enabled). v AutoRead. This defaults to True which means the stage will automatically read records from the port. Otherwise you explicitly control read operations in the code. v Table Name. Specify a table definition in the WebSphere DataStage Repository which describes the meta data for the port. You can browse for a table definition by choosing Select Table from the menu that appears when you click the browse button. You can also view the schema corresponding to this table definition by choosing View Schema from the same menu. You do not have to supply a Table Name. If any of the columns in your table definition have names that contain non-ascii characters, you should choose Column Aliases from the menu. The Build Column Aliases dialog box appears. This lists the columns that require an alias and let you specify one. v RCP. Choose True if runtime column propagation is allowed for inputs to this port. Defaults to False. You do not need to set this if you are using the automatic transfer facility. You provide the following information on the Output sub-tab: v Port Name. Optional name for the port. The default names for the links are out0, out1, out2 ... . You can refer to them in the code using either the default name or the name you have specified. v Alias. Where the port name contains non-ascii characters, you can give it an alias in this column. v AutoWrite. This defaults to True which means the stage will automatically write records to the port. Otherwise you explicitly control write operations in the code. Once records are written, the code can no longer access them. v Table Name. Specify a table definition in the WebSphere DataStage Repository which describes the meta data for the port. You can browse for a table definition. You do not have to supply a Table Name. A shortcut menu accessed from the browse button offers a choice of Clear Table Name, Select Table, Create Table,View Schema, and Column Aliases. The use of these is as described for the Input sub-tab. v RCP. Choose True if runtime column propagation is allowed for outputs from this port. Defaults to False. You do not need to set this if you are using the automatic transfer facility. The Transfer sub-tab allows you to connect an input buffer to an output buffer such that records will be automatically transferred from input to output. You can also disable automatic transfer, in which case you have to explicitly transfer data in the code. Transferred data sits in an output buffer and can still be accessed and altered by the code until it is actually written to the port. You provide the following information on the Transfer tab:
Chapter 5. Specifying your own parallel stages
41
v Input. Select the input port to connect to the buffer from the drop-down list. If you have specified an alias, this will be displayed here. v Output. Select the output port to transfer input records from the output buffer to from the drop-down list. If you have specified an alias, this will be displayed here. v Auto Transfer. This defaults to False, which means that you have to include code which manages the transfer. Set to True to have the transfer carried out automatically. v Separate. This is False by default, which means this transfer will be combined with other transfers to the same port. Set to True to specify that the transfer should be separate from other transfers. The Logic tab is where you specify the actual code that the stage executes. The Definitions sub-tab allows you to specify variables, include header files, and otherwise initialize the stage before processing any records. The Pre-Loop sub-tab allows you to specify code which is executed at the beginning of the stage, before any records are processed. The Per-Record sub-tab allows you to specify the code which is executed once for every record processed. The Post-Loop sub-tab allows you to specify code that is executed after all the records have been processed. You can type straight into these pages or cut and paste from another editor. The shortcut menu on the Pre-Loop, Per-Record, and Post-Loop pages gives access to the macros that are available for use in the code. The Advanced tab allows you to specify details about how the stage is compiled and built. Fill in the page as follows: v Compile and Link Flags. Allows you to specify flags that are passed to the C++ compiler. v Verbose. Select this check box to specify that the compile and build is done in verbose mode. v Debug. Select this check box to specify that the compile and build is done in debug mode. Otherwise, it is done in optimize mode. v Suppress Compile. Select this check box to generate files without compiling, and without deleting the generated files. This option is useful for fault finding. v Base File Name. The base filename for generated files. All generated files will have this name followed by the appropriate suffix. This defaults to the name specified under Operator on the General page. v Source Directory. The directory where generated .c files are placed. This defaults to the buildop folder in the current project directory. You can also set it using the DS_OPERATOR_BUILDOP_DIR environment variable in the WebSphere DataStage Administrator (see WebSphere DataStage Administrator Client Guide). v Header Directory. The directory where generated .h files are placed. This defaults to the buildop folder in the current project directory. You can also set it using the DS_OPERATOR_BUILDOP_DIR environment variable in the WebSphere DataStage Administrator (see WebSphere DataStage Administrator Client Guide). v Object Directory. The directory where generated .so files are placed. This defaults to the buildop folder in the current project directory. You can also set it using the DS_OPERATOR_BUILDOP_DIR environment variable in the WebSphere DataStage Administrator (see WebSphere DataStage Administrator Client Guide). v Wrapper directory. The directory where generated .op files are placed. This defaults to the buildop folder in the current project directory. You can also set it using the DS_OPERATOR_BUILDOP_DIR environment variable in the WebSphere DataStage Administrator (see WebSphere DataStage Administrator Client Guide). 7. When you have filled in the details in all the pages, click Generate to generate the stage. A window appears showing you the result of the build.
42
Informational macros
Use these macros in your code to determine the number of inputs, outputs, and transfers as follows: v inputs(). Returns the number of inputs to the stage. v outputs(). Returns the number of outputs from the stage. v transfers(). Returns the number of transfers in the stage.
Flow-control macros
Use these macros to override the default behavior of the Per-Record loop in your stage definition: v endLoop(). Causes the operator to stop looping, following completion of the current loop and after writing any auto outputs for this loop. v nextLoop() Causes the operator to immediately skip to the start of next loop, without writing any outputs. v failStep() Causes the operator to return a failed status and terminate the job.
43
Transfer Macros
These macros allow you to explicitly control the transfer of individual records. Each of the macros takes an argument as follows: v input is the index of the input (0 to n). If you have defined a name for the input port you can use this in place of the index in the form portname.portid_. v output is the index of the output (0 to n). If you have defined a name for the output port you can use this in place of the index in the form portname.portid_. v index is the index of the transfer (0 to n). The following macros are available: v doTransfer(index). Performs the transfer specified by index. v doTransfersFrom(input). Performs all transfers from input. v doTransfersTo(output). Performs all transfers to output. v transferAndWriteRecord(output). Performs all transfers and writes a record for the specified output. Calling this macro is equivalent to calling the macros doTransfersTo() and writeRecord().
44
When you specify details about the input and output ports for your Build stage, you need to define the meta data for the ports. You do this by loading a table definition from the WebSphere DataStage Repository. When you actually use your stage in a job, you have to specify meta data for the links that attach to these ports. For the job to run successfully the meta data specified for the port and that specified for the link should match. An exception to this is where you have runtime column propagation enabled for the job. In this case the input link meta data can be a super-set of the port meta data and the extra columns will be automatically propagated.
Using inputs with auto read enabled for some and disabled for others
You define one (or possibly more) inputs as Auto Read, and the rest with Auto Read disabled. You code the stage in such a way as the processing of records from the Auto Read input drives the processing of the other inputs. Each time round the loop, your code should call inputDone() on the Auto Read input and call exitLoop() to complete the actions of the stage. This method is fine where you process a record from the Auto Read input every time around the loop, and then process records from one or more of the other inputs depending on the results of processing the Auto Read record.
45
46
v v v v
Details of the UNIX command that the stage will execute. Description of the data that will be input to the stage. Description of the data that will be output from the stage. Definition of the environment in which the command will execute.
The UNIX command that you wrap can be a built-in command, such as grep, a utility, such as SyncSort, or your own UNIX application. The only limitation is that the command must be `pipe-safe (to be pipe-safe a UNIX command reads its input sequentially, from beginning to end). You need to define meta data for the data being input to and output from the stage. You also need to define the way in which the data will be input or output. UNIX commands can take their inputs from standard in, or another stream, a file, or from the output of another command via a pipe. Similarly data is output to standard out, or another stream, to a file, or to a pipe to be input to another command. You specify what the command expects. WebSphere DataStage handles data being input to the Wrapped stage and will present it in the specified form. If you specify a command that expects input on standard in, or another stream, WebSphere DataStage will present the input data from the jobs data flow as if it was on standard in. Similarly it will intercept data output on standard out, or another stream, and integrate it into the jobs data flow. You also specify the environment in which the UNIX command will be executed when you define the wrapped stage. To define a Wrapped stage: 1. Do one of: a. Choose File New from the Designer menu. The New dialog box appears. b. Open the Stage Type folder and select the Parallel Wrapped Stage Type icon. c. Click OK. TheStage Type dialog box appears, with the General page on top. Or: d. Select a folder in the repository tree. e. Choose New Other Parallel Stage Wrapped from the shortcut menu. The Stage Type dialog box appears, with the General page on top. 2. Fill in the fields on the General page as follows: v Stage type name. This is the name that the stage will be known by to WebSphere DataStage. Avoid using the same name as existing stages or the name of the actual UNIX command you are wrapping. v Category. The category that the new stage will be stored in under the stage types branch. Type in or browse for an existing category or type in the name of a new one. The category also determines what group in the palette the stage will be added to. Choose an existing category to add to an existing group, or specify a new category to create a new palette group. v Parallel Stage type. This indicates the type of new Parallel job stage you are defining (Custom, Build, or Wrapped). You cannot change this setting. v Wrapper Name. The name of the wrapper file WebSphere DataStage will generate to call the command. By default this will take the same name as the Stage type name. v Execution mode. Choose the default execution mode. This is the mode that will appear in the Advanced tab on the stage editor. You can override this mode for individual instances of the stage as required, unless you select Parallel only or Sequential only. See WebSphere DataStage Parallel Job Developer Guide for a description of the execution mode. v Preserve Partitioning. This shows the default setting of the Preserve Partitioning flag, which you cannot change in a Wrapped stage. This is the setting that will appear in the Advanced tab on the stage editor. You can override this setting for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the preserve partitioning flag.
Chapter 5. Specifying your own parallel stages
47
v Partitioning. This shows the default partitioning method, which you cannot change in a Wrapped stage. This is the method that will appear in the Inputs Page Partitioning tab of the stage editor. You can override this method for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the partitioning methods. v Collecting. This shows the default collection method, which you cannot change in a Wrapped stage. This is the method that will appear in the Inputs Page Partitioning tab of the stage editor. You can override this method for individual instances of the stage as required. See WebSphere DataStage Parallel Job Developer Guide for a description of the collection methods. v Command. The name of the UNIX command to be wrapped, plus any required arguments. The arguments that you enter here are ones that do not change with different invocations of the command. Arguments that need to be specified when the Wrapped stage is included in a job are defined as properties for the stage. v Short Description. Optionally enter a short description of the stage. v Long Description. Optionally enter a long description of the stage. 3. Go to the Creator page and optionally specify information about the stage you are creating. We recommend that you assign a release number to the stage so you can keep track of any subsequent changes. You can specify that the actual stage will use a custom GUI by entering the ProgID for a custom GUI in the Custom GUI Prog ID field. You can also specify that the stage has its own icon. You need to supply a 16 x 16 bit bitmap and a 32 x 32 bit bitmap to be displayed in various places in the WebSphere DataStage user interface. Click the 16 x 16 Bitmap button and browse for the smaller bitmap file. Click the 32 x 32 Bitmap button and browse for the large bitmap file. Note that bitmaps with 32-bit color are not supported. Click the Reset Bitmap Info button to revert to using the default WebSphere DataStage icon for this stage. 4. Go to the Properties page. This allows you to specify the arguments that the UNIX command requires as properties that appear in the stage Properties tab. For wrapped stages the Properties tab always appears under the Stage page. Fill in the fields as follows: v Property name. The name of the property that will be displayed on the Properties tab of the stage editor. v Data type. The data type of the property. Choose from: Boolean Float Integer String Pathname List Input Column Output Column If you choose Input Column or Output Column, when the stage is included in a job a drop-down list will offer a choice of the defined input or output columns. If you choose list you should open the Extended Properties dialog box from the grid shortcut menu to specify what appears in the list. v Prompt. The name of the property that will be displayed on the Properties tab of the stage editor. v Default Value. The value the option will take if no other is specified. v Required. Set this to True if the property is mandatory. v Repeats. Set this true if the property repeats (i.e. you can have multiple instances of it). v Conversion. Specifies the type of property as follows:
48
-Name. The name of the property will be passed to the command as the argument value. This will normally be a hidden property, i.e., not visible in the stage editor. -Name Value. The name of the property will be passed to the command as the argument name, and any value specified in the stage editor is passed as the value. -Value. The value for the property specified in the stage editor is passed to the command as the argument name. Typically used to group operator options that are mutually exclusive. Value only. The value for the property specified in the stage editor is passed as it is. 5. If you want to specify a list property, or otherwise control how properties are handled by your stage, choose Extended Properties from the Properties grid shortcut menu to open the Extended Properties dialog box. The settings you use depend on the type of property you are specifying: v Specify a category to have the property appear under this category in the stage editor. By default all properties appear in the Options category. v If you are specifying a List category, specify the possible values for list members in the List Value field. v If the property is to be a dependent of another property, select the parent property in the Parents field. v Specify an expression in the Template field to have the actual value of the property generated at compile time. It is usually based on values in other properties and columns. v Specify an expression in the Conditions field to indicate that the property is only valid if the conditions are met. The specification of this property is a bar | separated list of conditions that are ANDed together. For example, if the specification was a=b|c!=d, then this property would only be valid (and therefore only available in the GUI) when property a is equal to b, and property c is not equal to d. Click OK when you are happy with the extended properties. 6. Go to the Wrapped page. This allows you to specify information about the command to be executed by the stage and how it will be handled. The Interfaces tab is used to describe the inputs to and outputs from the stage, specifying the interfaces that the stage will need to function. Details about inputs to the stage are defined on the Inputs sub-tab: v Link. The link number, this is assigned for you and is read-only. When you actually use your stage, links will be assigned in the order in which you add them. In our example, the first link will be taken as link 0, the second as link 1 and so on. You can reassign the links using the stage editors Link Ordering tab on the General page. v Table Name. The meta data for the link. You define this by loading a table definition from the Repository. Type in the name, or browse for a table definition. Alternatively, you can specify an argument to the UNIX command which specifies a table definition. In this case, when the wrapped stage is used in a job design, the designer will be prompted for an actual table definition to use. v Stream. Here you can specify whether the UNIX command expects its input on standard in, or another stream, or whether it expects it in a file. Click on the browse button to open the Wrapped Stream dialog box. In the case of a file, you should also specify whether the file to be read is given in a command line argument, or by an environment variable. Details about outputs from the stage are defined on the Outputs sub-tab: v Link. The link number, this is assigned for you and is read-only. When you actually use your stage, links will be assigned in the order in which you add them. In our example, the first link will be taken as link 0, the second as link 1 and so on. You can reassign the links using the stage editors Link Ordering tab on the General page. v Table Name. The meta data for the link. You define this by loading a table definition from the Repository. Type in the name, or browse for a table definition.
Chapter 5. Specifying your own parallel stages
49
v Stream. Here you can specify whether the UNIX command will write its output to standard out, or another stream, or whether it outputs to a file. Click on the browse button to open the Wrapped Stream dialog box. In the case of a file, you should also specify whether the file to be written is specified in a command line argument, or by an environment variable. The Environment tab gives information about the environment in which the command will execute. Set the following on the Environment tab: v All Exit Codes Successful. By default WebSphere DataStage treats an exit code of 0 as successful and all others as errors. Select this check box to specify that all exit codes should be treated as successful other than those specified in the Failure codes grid. v Exit Codes. The use of this depends on the setting of the All Exits Codes Successful check box. If All Exits Codes Successful is not selected, enter the codes in the Success Codes grid which will be taken as indicating successful completion. All others will be taken as indicating failure. If All Exits Codes Successful is selected, enter the exit codes in the Failure Code grid which will be taken as indicating failure. All others will be taken as indicating success. v Environment. Specify environment variables and settings that the UNIX command requires in order to run. 7. When you have filled in the details in all the pages, click Generate to generate the stage.
The following screen shots show how this stage is defined in WebSphere DataStage using the Stage Type dialog box: 1. First general details are supplied in the General tab. The argument defining the second column as the key is included in the command because this does not vary: 2. The reverse order argument (-r) are included as properties because it is optional and may or may not be included when the stage is incorporated into a job. 3. The fact that the sort command expects two files as input is defined on the Input sub-tab on the Interfaces tab of the Wrapper page. 4. The fact that the sort command outputs to a file is defined on the Output sub-tab on the Interfaces tab of the Wrapper page. Note: When you use the stage in a job, make sure that you use table definitions compatible with the tables defined in the input and output sub-tabs. 5. Because all exit codes other than 0 are treated as errors, and because there are no special environment requirements for this command, you do not need to alter anything on the Environment tab of the Wrapped page. All that remains is to click Generate to build the stage.
50
51
Debugging APT_DEBUG_OPERATOR APT_DEBUG_MODULE_NAMES APT_DEBUG_PARTITION APT_DEBUG_SIGNALS APT_DEBUG_STEP APT_DEBUG_SUBPROC APT_EXECUTION_MODE APT_PM_DBX APT_PM_GDB APT_PM_SHOW_PIDS APT_PM_XLDB APT_PM_XTERM APT_SHOW_LIBLOAD Decimal Support APT_DECIMAL_INTERM_PRECISION APT_DECIMAL_INTERM_SCALE APT_DECIMAL_INTERM_ROUND_MODE Disk I/O APT_BUFFER_DISK_WRITE_INCREMENT APT_CONSISTENT_BUFFERIO_SIZE APT_EXPORT_FLUSH_COUNT APT_IO_MAP/APT_IO_NOMAP and APT_BUFFERIO_MAP/APT_BUFFERIO_NOMAP APT_PHYSICAL_DATASET_BLOCK_SIZE General Job Administration APT_CHECKPOINT_DIR APT_CLOBBER_OUTPUT APT_CONFIG_FILE APT_DISABLE_COMBINATION APT_EXECUTION_MODE APT_ORCHHOME APT_STARTUP_SCRIPT APT_NO_STARTUP_SCRIPT APT_STARTUP_STATUS APT_THIN_SCORE Job Monitoring APT_MONITOR_SIZE APT_MONITOR_TIME APT_NO_JOBMON
52
APT_PERFORMANCE_DATA Look Up support APT_LUTCREATE_NO_MMAP Miscellaneous APT_COPY_TRANSFORM_OPERATOR APT_EBCDIC_VERSION on page 65 APT_DATE_CENTURY_BREAK_YEAR APT_IMPEXP_ALLOW_ZERO_LENGTH_FIXED_NULL APT_IMPORT_REJECT_STRING_FIELD_OVERRUNS APT_INSERT_COPY_BEFORE_MODIFY APT_OLD_BOUNDED_LENGTH APT_OPERATOR_REGISTRY_PATH APT_PM_NO_SHARED_MEMORY APT_PM_NO_NAMED_PIPES APT_PM_SOFT_KILL_WAIT APT_PM_STARTUP_CONCURRENCY APT_RECORD_COUNTS APT_SAVE_SCORE APT_SHOW_COMPONENT_CALLS APT_STACK_TRACE APT_WRITE_DS_VERSION OSH_PRELOAD_LIBS Network APT_IO_MAXIMUM_OUTSTANDING APT_IOMGR_CONNECT_ATTEMPTS APT_PM_CONDUCTOR_HOSTNAME APT_PM_NO_TCPIP APT_PM_NODE_TIMEOUT APT_PM_SHOWRSH APT_PM_USE_RSH_LOCALLY APT_RECVBUFSIZE APT_RECVBUFSIZE NLS APT_COLLATION_SEQUENCE APT_COLLATION_STRENGTH APT_ENGLISH_MESSAGES APT_IMPEXP_CHARSET APT_INPUT_CHARSET APT_OS_CHARSET
53
APT_OUTPUT_CHARSET APT_STRING_CHARSET Oracle Support APT_ORACLE_LOAD_DELIMITED APT_ORACLE_LOAD_OPTIONS APT_ORACLE_NO_OPS APT_ORACLE_PRESERVE_BLANKS APT_ORA_IGNORE_CONFIG_FILE_PARALLELISM APT_ORA_WRITE_FILES APT_ORAUPSERT_COMMIT_ROW_INTERVAL APT_ORAUPSERT_COMMIT_TIME_INTERVAL Partitioning APT_NO_PART_INSERTION APT_PARTITION_COUNT APT_PARTITION_NUMBER Reading and Writing Files APT_DELIMITED_READ_SIZE APT_FILE_IMPORT_BUFFER_SIZE APT_FILE_EXPORT_BUFFER_SIZE APT_IMPORT_PATTERN_USES_FILESET APT_MAX_DELIMITED_READ_SIZE APT_PREVIOUS_FINAL_DELIMITER_COMPATIBLE APT_STRING_PADCHAR Reporting APT_DUMP_SCORE APT_ERROR_CONFIGURATION APT_MSG_FILELINE APT_PM_PLAYER_MEMORY APT_PM_PLAYER_TIMING APT_RECORD_COUNTS OSH_DUMP OSH_ECHO OSH_EXPLAIN OSH_PRINT_SCHEMAS SAS Support APT_HASH_TO_SASHASH APT_NO_SASOUT_INSERT APT_NO_SAS_TRANSFORMS APT_SAS_ACCEPT_ERROR APT_SAS_CHARSET
54
APT_SAS_CHARSET_ABORT APT_SAS_COMMAND APT_SASINT_COMMAND APT_SAS_DEBUG APT_SAS_DEBUG_IO APT_SAS_DEBUG_LEVEL APT_SAS_DEBUG_VERBOSE APT_SAS_NO_PSDS_USTRING APT_SAS_S_ARGUMENT APT_SAS_SCHEMASOURCE_DUMP APT_SAS_SHOW_INFO APT_SAS_TRUNCATION Sorting APT_NO_SORT_INSERTION APT_SORT_INSERTION_CHECK_ONLY Teradata Support APT_TERA_64K_BUFFERS APT_TERA_NO_ERR_CLEANUP APT_TERA_NO_PERM_CHECKS APT_TERA_NO_SQL_CONVERSION APT_TERA_SYNC_DATABASE APT_TERA_SYNC_USER Transport Blocks APT_AUTO_TRANSPORT_BLOCK_SIZE APT_LATENCY_COEFFICIENT APT_DEFAULT_TRANSPORT_BLOCK_SIZE APT_MAX_TRANSPORT_BLOCK_SIZE/ APT_MIN_TRANSPORT_BLOCK_SIZE
Buffering
These environment variable are all concerned with the buffering WebSphere DataStage performs on stage links to avoid deadlock situations. These settings can also be made on the Inputs page or Outputs page Advanced tab of the parallel stage editors.
APT_BUFFER_FREE_RUN
This environment variable is available in the WebSphere DataStage Administrator, under the Parallel category. It specifies how much of the available in-memory buffer to consume before the buffer resists. This is expressed as a decimal representing the percentage of Maximum memory buffer size (for example, 0.5 is 50%). When the amount of data in the buffer is less than this value, new data is accepted automatically. When the data exceeds it, the buffer first tries to write some of the data it contains before accepting more.
55
The default value is 50% of the Maximum memory buffer size. You can set it to greater than 100%, in which case the buffer continues to store data up to the indicated multiple of Maximum memory buffer size before writing to disk.
APT_BUFFER_MAXIMUM_MEMORY
Sets the default value of Maximum memory buffer size. The default value is 3145728 (3 MB). Specifies the maximum amount of virtual memory, in bytes, used per buffer.
APT_BUFFER_MAXIMUM_TIMEOUT
WebSphere DataStage buffering is self tuning, which can theoretically lead to long delays between retries. This environment variable specified the maximum wait before a retry in seconds, and is by default set to 1.
APT_BUFFER_DISK_WRITE_INCREMENT
Sets the size, in bytes, of blocks of data being moved to/from disk by the buffering operator. The default is 1048576 (1 MB). Adjusting this value trades amount of disk access against throughput for small amounts of data. Increasing the block size reduces disk access, but may decrease performance when data is being read/written in smaller units. Decreasing the block size increases throughput, but may increase the amount of disk access.
APT_BUFFERING_POLICY
This environment variable is available in the WebSphere DataStage Administrator, under the Parallel category. Controls the buffering policy for all virtual data sets in all steps. The variable has the following settings: v AUTOMATIC_BUFFERING (default). Buffer a data set only if necessary to prevent a data flow deadlock. v FORCE_BUFFERING. Unconditionally buffer all virtual data sets. Note that this can slow down processing considerably. v NO_BUFFERING. Do not buffer data sets. This setting can cause data flow deadlock if used inappropriately.
APT_SHARED_MEMORY_BUFFERS
Typically the number of shared memory buffers between two processes is fixed at 2. Setting this will increase the number used. The likely result of this is POSSIBLY both increased latency and increased performance. This setting can significantly increase memory use.
DS_OPERATOR_BUILDOP_DIR
Identifies the directory in which generated buildops are created. By default this identifies a directory called buildop under the current project directory. If the directory is changed, the corresponding entry in APT_OPERATOR_REGISTRY_PATH needs to change to match the buildop folder.
56
OSH_BUILDOP_CODE
Identifies the directory into which buildop writes the generated .C file and build script. It defaults to the current working directory. The -C option of buildop overrides this setting.
OSH_BUILDOP_HEADER
Identifies the directory into which buildop writes the generated .h file. It defaults to the current working directory. The -H option of buildop overrides this setting.
OSH_BUILDOP_OBJECT
Identifies the directory into which buildop writes the dynamically loadable object file, whose extension is .so on Solaris, .sl on HP-UX, or .o on AIX. Defaults to the current working directory. The -O option of buildop overrides this setting.
OSH_BUILDOP_XLC_BIN
AIX only. Identifies the directory specifying the location of the shared library creation command used by buildop. On older AIX systems this defaults to /usr/lpp/xlC/bin/makeC++SharedLib_r for thread-safe compilation. On newer AIX systems it defaults to /usr/ibmcxx/bin/makeC++SharedLib_r. For non-thread-safe compilation, the default path is the same, but the name of the file is makeC++SharedLib.
OSH_CBUILDOP_XLC_BIN
AIX only. Identifies the directory specifying the location of the shared library creation command used by cbuildop. If this environment variable is not set, cbuildop checks the setting of OSH_BUILDOP_XLC_BIN for the path. On older AIX systems OSH_CBUILDOP_XLC_BIN defaults to /usr/lpp/xlC/bin/ makeC++SharedLib_r for thread-safe compilation. On newer AIX systems it defaults to /usr/ibmcxx/bin/makeC++SharedLib_r. For non-threadsafe compilation, the default path is the same, but the name of the command is makeC++SharedLib.
Compiler
These environment variables specify details about the C++ compiler used by WebSphere DataStage in connection with parallel jobs.
APT_COMPILER
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Compiler branch. Specifies the full path to the C++ compiler.
APT_COMPILEOPT
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Compiler branch. Specifies extra options to be passed to the C++ compiler when it is invoked.
57
APT_LINKER
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Compiler branch. Specifies the full path to the C++ linker.
APT_LINKOPT
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Compiler branch. Specifies extra options to be passed to the C++ linker when it is invoked.
DB2 Support
These environment variables are concerned with setting up access to DB2 databases from WebSphere DataStage.
APT_DB2INSTANCE_HOME
Specifies the DB2 installation directory. This variable is set by WebSphere DataStage to values obtained from the DB2Server table, representing the currently selected DB2 server.
APT_DB2READ_LOCK_TABLE
If this variable is defined and the open option is not specified for the DB2 stage, WebSphere DataStage performs the following open command to lock the table:
lock table table_name in share mode
APT_DBNAME
Specifies the name of the database if you choose to leave out the Database option for DB2 stages. If APT_DBNAME is not defined as well, DB2DBDFT is used to find the database name. These variables are set by WebSphere DataStage to values obtained from the DB2Server table, representing the currently selected DB2 server.
APT_RDBMS_COMMIT_ROWS
Specifies the number of records to insert into a data set between commits. The default value is 2048.
DB2DBDFT
For DB2 operators, you can set the name of the database by using the -dbname option or by setting APT_DBNAME. If you do not use either method, DB2DBDFT is used to find the database name. These variables are set by WebSphere DataStage to values obtained from the DB2Server table, representing the currently selected DB2 server.
Debugging
These environment variables are concerned with the debugging of WebSphere DataStage parallel jobs.
58
APT_DEBUG_OPERATOR
Specifies the operators on which to start debuggers. If not set, no debuggers are started. If set to an operator number (as determined from the output of APT_DUMP_SCORE), debuggers are started for that single operator. If set to -1, debuggers are started for all operators.
APT_DEBUG_MODULE_NAMES
This comprises a list of module names separated by white space that are the modules to debug, i.e., where internal IF_DEBUG statements will be run. The subproc operator module (module name is subproc) is one example of a module that uses this facility.
APT_DEBUG_PARTITION
Specifies the partitions on which to start debuggers. One instance, or partition, of an operator is run on each node running the operator. If set to a single number, debuggers are started on that partition; if not set or set to -1, debuggers are started on all partitions. See the description of APT_DEBUG_OPERATOR for more information on using this environment variable. For example, setting APT_DEBUG_STEP to 0, APT_DEBUG_OPERATOR to 1, and APT_DEBUG_PARTITION to -1 starts debuggers for every partition of the second operator in the first step.
APT_DEBUG_ OPERATOR not set -1 -1 >= 0 >= 0 APT_DEBUG_ PARTITION any value not set or -1 >= 0 -1 >= 0 Effect no debugging debug all partitions of all operators debug a specific partition of all operators debug all partitions of a specific operator debug a specific partition of a specific operator
APT_DEBUG_SIGNALS
You can use the APT_DEBUG_SIGNALS environment variable to specify that signals such as SIGSEGV, SIGBUS, etc., should cause a debugger to start. If any of these signals occurs within an APT_Operator::runLocally() function, a debugger such as dbx is invoked. Note that the UNIX and WebSphere DataStage variables DEBUGGER, DISPLAY, and APT_PM_XTERM, specifying a debugger and how the output should be displayed, must be set correctly.
APT_DEBUG_STEP
Specifies the steps on which to start debuggers. If not set or if set to -1, debuggers are started on the processes specified by APT_DEBUG_OPERATOR and APT_DEBUG_PARTITION in all steps. If set to a step number, debuggers are started for processes in the specified step.
59
APT_DEBUG_SUBPROC
Display debug information about each subprocess operator.
APT_EXECUTION_MODE
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. By default, the execution mode is parallel, with multiple processes. Set this variable to one of the following values to run an application in sequential execution mode: v ONE_PROCESS one-process mode v MANY_PROCESS many-process mode v NO_SERIALIZE many-process mode, without serialization In ONE_PROCESS mode: v The application executes in a single UNIX process. You need only run a single debugger session and can set breakpoints anywhere in your code. v Data is partitioned according to the number of nodes defined in the configuration file. v Each operator is run as a subroutine and is called the number of times appropriate for the number of partitions on which it must operate. In MANY_PROCESS mode the framework forks a new process for each instance of each operator and waits for it to complete rather than calling operators as subroutines. In both cases, the step is run entirely on the Conductor node rather than spread across the configuration. NO_SERIALIZE mode is similar to MANY_PROCESS mode, but the WebSphere DataStage persistence mechanism is not used to load and save objects. Turning off persistence may be useful for tracking errors in derived C++ classes.
APT_PM_DBX
Set this environment variable to the path of your dbx debugger, if a debugger is not already included in your path. This variable sets the location; it does not run the debugger.
APT_PM_GDB
Linux only. Set this environment variable to the path of your xldb debugger, if a debugger is not already included in your path. This variable sets the location; it does not run the debugger.
APT_PM_LADEBUG
Tru64 only. Set this environment variable to the path of your dbx debugger, if a debugger is not already included in your path. This variable sets the location; it does not run the debugger.
APT_PM_SHOW_PIDS
If this variable is set, players will output an informational message upon startup, displaying their process id.
60
APT_PM_XLDB
Set this environment variable to the path of your xldb debugger, if a debugger is not already included in your path. This variable sets the location; it does not run the debugger.
APT_PM_XTERM
If WebSphere DataStage invokes dbx, the debugger starts in an xterm window; this means WebSphere DataStage must know where to find the xterm program. The default location is /usr/bin/X11/xterm. You can override this default by setting the APT_PM_XTERM environment variable to the appropriate path. APT_PM_XTERM is ignored if you are using xldb.
APT_SHOW_LIBLOAD
If set, dumps a message to stdout every time a library is loaded. This can be useful for testing/verifying the right library is being loaded. Note that the message is output to stdout, NOT to the error log.
APT_DECIMAL_INTERM_SCALE
Specifies the default scale value for any decimal intermediate variables required in calculations. Default value is 10.
APT_DECIMAL_INTERM_ROUND_MODE
Specifies the default rounding mode for any decimal intermediate variables required in calculations. The default is round_inf.
Disk I/O
These environment variables are all concerned with when and how WebSphere DataStage parallel jobs write information to disk.
APT_BUFFER_DISK_WRITE_INCREMENT
For systems where small to medium bursts of I/O are not desirable, the default 1MB write to disk size chunk size may be too small. APT_BUFFER_DISK_WRITE_INCREMENT controls this and can be set larger than 1048576 (1 MB). The setting may not exceed max_memory * 2/3.
APT_CONSISTENT_BUFFERIO_SIZE
Some disk arrays have read ahead caches that are only effective when data is read repeatedly in like-sized chunks. Setting APT_CONSISTENT_BUFFERIO_SIZE=N will force stages to read data in chunks which are size N or a multiple of N.
61
APT_EXPORT_FLUSH_COUNT
Allows the export operator to flush data to disk more often than it typically does (data is explicitly flushed at the end of a job, although the OS may choose to do so more frequently). Set this variable to an integer which, in number of records, controls how often flushes should occur. Setting this value to a low number (such as 1) is useful for real time applications, but there is a small performance penalty associated with setting this to a low value.
APT_PHYSICAL_DATASET_BLOCK_SIZE
Specify the block size to use for reading and writing to a data set stage. The default is 128 KB.
APT_CHECKPOINT_DIR
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. By default, when running a job, WebSphere DataStage stores state information in the current working directory. Use APT_CHECKPOINT_DIR to specify another directory.
APT_CLOBBER_OUTPUT
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. By default, if an output file or data set already exists, WebSphere DataStage issues an error and stops before overwriting it, notifying you of the name conflict. Setting this variable to any value permits WebSphere DataStage to overwrite existing files or data sets without a warning message.
APT_CONFIG_FILE
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. Sets the path name of the configuration file. (You may want to include this as a job parameter, so that you can specify the configuration file at job run time).
APT_DISABLE_COMBINATION
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. Globally disables operator combining. Operator combining is WebSphere DataStages default behavior, in which two or more (in fact any number of) operators within a step are combined into one process where possible.
62
You may need to disable combining to facilitate debugging. Note that disabling combining generates more UNIX processes, and hence requires more system resources and memory. It also disables internal optimizations for job efficiency and run times.
APT_EXECUTION_MODE
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. By default, the execution mode is parallel, with multiple processes. Set this variable to one of the following values to run an application in sequential execution mode: v ONE_PROCESS one-process mode v MANY_PROCESS many-process mode v NO_SERIALIZE many-process mode, without serialization In ONE_PROCESS mode: v The application executes in a single UNIX process. You need only run a single debugger session and can set breakpoints anywhere in your code. v Data is partitioned according to the number of nodes defined in the configuration file. v Each operator is run as a subroutine and is called the number of times appropriate for the number of partitions on which it must operate. In MANY_PROCESS mode the framework forks a new process for each instance of each operator and waits for it to complete rather than calling operators as subroutines. In both cases, the step is run entirely on the Conductor node rather than spread across the configuration. NO_SERIALIZE mode is similar to MANY_PROCESS mode, but the WebSphere DataStage persistence mechanism is not used to load and save objects. Turning off persistence may be useful for tracking errors in derived C++ classes.
APT_ORCHHOME
Must be set by all WebSphere DataStageusers to point to the top-level directory of the WebSphere DataStage parallel engine installation.
APT_STARTUP_SCRIPT
As part of running an application, WebSphere DataStage creates a remote shell on all WebSphere DataStage processing nodes on which the job runs. By default, the remote shell is given the same environment as the shell from which WebSphere DataStage is invoked. However, you can write an optional startup shell script to modify the shell configuration of one or more processing nodes. If a startup script exists, WebSphere DataStage runs it on remote shells before running your application. APT_STARTUP_SCRIPT specifies the script to be run. If it is not defined, WebSphere DataStage searches ./startup.apt, $APT_ORCHHOME/etc/startup.apt and $APT_ORCHHOME/etc/startup, in that order. APT_NO_STARTUP_SCRIPT disables running the startup script.
APT_NO_STARTUP_SCRIPT
Prevents WebSphere DataStage from executing a startup script. By default, this variable is not set, and WebSphere DataStage runs the startup script. If this variable is set, WebSphere DataStage ignores the startup script. This may be useful when debugging a startup script. See also APT_STARTUP_SCRIPT.
63
APT_STARTUP_STATUS
Set thi sto cause messages to be generated as parallel job startup moves from phase to phase. This can be useful as a diagnostic if parallel job startup is failing.
APT_THIN_SCORE
Setting this variable decreases the memory usage of steps with 100 operator instances or more by a noticable amount. To use this optimization, set APT_THIN_SCORE=1 in your environment. There are no performance benefits in setting this variable unless you are running out of real memory at some point in your flow or the additional memory is useful for sorting or buffering. This variable does not affect any specific operators which consume large amounts of memory, but improves general parallel job memory handling.
Job Monitoring
These environment variables are concerned with the Job Monitor on WebSphere DataStage.
APT_MONITOR_SIZE
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. Determines the minimum number of records the WebSphere DataStage Job Monitor reports. The default is 5000 records.
APT_MONITOR_TIME
This environment variable is available in the WebSphere DataStage Administrator under the Parallel branch. Determines the minimum time interval in seconds for generating monitor information at runtime. The default is 5 seconds. This variable takes precedence over APT_MONITOR_SIZE.
APT_NO_JOBMON
Turn off job monitoring entirely.
APT_PERFORMANCE_DATA
Set this variable to turn on performance data output generation. APT_PERFORMANCE_DATA can be either set with no value, or be set to a valid path which will be used as the default location for performance data output.
64
APT_LUTCREATE_NO_MMAP
Set this to force lookup tables to be created using malloced memory. By default lookup table creation is done using memory mapped files. There may be situations, depending on the OS configuration or file system, where writing to memory mapped files causes poor performance. In these situations this variable can be set so that malloced memory is used, which should boost performance.
Miscellaneous APT_COPY_TRANSFORM_OPERATOR
If set, distributes the shared object file of the sub-level transform operator and the shared object file of user-defined functions (not extern functions) via distribute-component in a non-NFS MPP.
APT_DATE_CENTURY_BREAK_YEAR
Four digit year which marks the century two-digit dates belong to. It is set to 1900 by defult.
APT_EBCDIC_VERSION
Certain operators, including the import and export operators, support the ebcdic property specifying that field data is represented in the EBCDIC character set. The APT_EBCDIC_VERSION variable indicates the specific EBCDIC character set to use. Legal values are: HP IBM ATT USS IBM037 Use the IBM 037 EBCDIC character set. IBM500 Use the IBM 500 EBCDIC character set. If the value of the variable is HP, IBM, ATT, or USS, then EBCDIC data is internally converted to/from 7-bit ASCII. If the value is IBM037 or IBM500, internal conversion is between EBCDIC and ISO-8859-1 (the 8-bit Latin-1 superset of ASCII, with accented character support). use the EBCDIC character set supported by HP terminals (this is the default setting, except on USS installations). Use the EBCDIC character set supported by IBM 3780 terminals Use the EBCDIC character set supported by AT&T terminals. Use the IBM 1047 EBCDIC character set (this is the default setting on USS installations).
APT_IMPEXP_ALLOW_ZERO_LENGTH_FIXED_NULL
When set, allows zero length null_field value with fixed length fields. This should be used with care as poorly formatted data will cause incorrect results. By default a zero length null_field value will cause an error.
APT_IMPORT_REJECT_STRING_FIELD_OVERRUNS
When set, WebSphere DataStage will reject any string or ustring fields read that go over their fixed size. By default these records are truncated.
65
APT_INSERT_COPY_BEFORE_MODIFY
When defined, turns on automatic insertion of a copy operator before any modify operator (WARNING: if this variable is not set and the operator immediately preceding modify in the data flow uses a modify adapter, the modify operator will be removed from the data flow). Only set this if you write your own custom operators AND use modify within those operators.
APT_OLD_BOUNDED_LENGTH
Some parallel datasets generated with WebSphere DataStage 7.0.1 and later releases require more disk space when the columns are of type VarChar when compared to 7.0. This is due to changes added for performance improvements for bounded length VarChars in 7.0.1. Set APT_OLD_BOUNDED_LENGTH to any value to revert to pre-7.0.1 storage behavior when using bounded length varchars. Setting this variable can have adverse performance effects. The preferred and more performant solution is to use unbounded length VarChars (dont set any length) for columns where the maximum length is rarely used, rather than set this environment variable.
APT_OPERATOR_REGISTRY_PATH
Used to locate operator .apt files, which define what operators are available and which libraries they are found in.
APT_PM_NO_SHARED_MEMORY
By default, shared memory is used for local connections. If this variable is set, named pipes rather than shared memory are used for local connections. If both APT_PM_NO_NAMED_PIPES and APT_PM_NO_SHARED_MEMORY are set, then TCP sockets are used for local connections.
APT_PM_NO_NAMED_PIPES
Specifies not to use named pipes for local connections. Named pipes will still be used in other areas of WebSphere DataStage, including subprocs and setting up of the shared memory transport protocol in the process manager.
APT_PM_SOFT_KILL_WAIT
Delay between SIGINT and SIGKILL during abornal job shutdown. Gives time for processes to run cleanups if they catch SIGINT. Defaults to ZERO.
APT_PM_STARTUP_CONCURRENCY
Setting this to a small integer determines the number of simultaneous section leader startups to be allowed. Setting this to 1 forces sequential startup. The default is defined by SOMAXCONN in sys/socket.h (currently 5 for Solaris, 10 for AIX).
APT_RECORD_COUNTS
Causes WebSphere DataStage to print, for each operator Player, the number of records consumed by getRecord() and produced by putRecord(). Abandoned input records are not necessarily accounted for. Buffer operators do not print this information.
66
APT_SAVE_SCORE
Sets the name and path of the file used by the performance monitor to hold temporary score data. The path must be visible from the host machine. The performance monitor creates this file, therefore it need not exist when you set this variable.
APT_SHOW_COMPONENT_CALLS
This forces WebSphere DataStage to display messages at job check time as to which user overloadable functions (such as checkConfig and describeOperator) are being called. This will not produce output at runtime and is not guaranteed to be a complete list of all user-overloadable functions being called, but an effort is made to keep this synchronized with any new virtual functions provided.
APT_STACK_TRACE
This variable controls the number of lines printed for stack traces. The values are: v unset. 10 lines printed v 0. infinite lines printed v N. N lines printed v none. no stack trace The last setting can be used to disable stack traces entirely.
APT_WRITE_DS_VERSION
By default, WebSphere DataStage saves data sets in the Orchestrate Version 4.1 format. APT_WRITE_DS_VERSION lets you save data sets in formats compatible with previous versions of Orchestrate. The values of APT_WRITE_DS_VERSION are: v v3_0. Orchestrate Version 3.0 v v3. Orchestrate Version 3.1.x v v4. Orchestrate Version 4.0 v v4_0_3. Orchestrate Version 4.0.3 and later versions up to but not including Version 4.1 v v4_1. Orchestrate Version 4.1 and later versions through and including Version 4.6
OSH_PRELOAD_LIBS
Specifies a colon-separated list of names of libraries to be loaded before any other processing. Libraries containing custom operators must be assigned to this variable or they must be registered. For example, in Korn shell syntax:
$ export OSH_PRELOAD_LIBS="orchlib1:orchlib2:mylib1"
Network
These environment variables are concerned with the operation of WebSphere DataStage parallel jobs over a network.
67
APT_IO_MAXIMUM_OUTSTANDING
Sets the amount of memory, in bytes, allocated to a WebSphere DataStage job on every physical node for network communications. The default value is 2097152 (2MB). When you are executing many partitions on a single physical node, this number may need to be increased.
APT_IOMGR_CONNECT_ATTEMPTS
Sets the number of attempts for a TCP connect in case of a connection failure. This is necessary only for jobs with a high degree of parallelism in an MPP environment. The default value is 2 attempts (1 retry after an initial failure).
APT_PM_CONDUCTOR_HOSTNAME
The network name of the processing node from which you invoke a job should be included in the configuration file as either a node or a fastname. If the network name is not included in the configuration file, WebSphere DataStage users must set the environment variable APT_PM_CONDUCTOR_HOSTNAME to the name of the node invoking the WebSphere DataStage job.
APT_PM_NO_TCPIP
This turns off use of UNIX sockets to communicate between player processes at runtime. If the job is being run in an MPP (non-shared memory) environment, do not set this variable, as UNIX sockets are your only communications option.
APT_PM_NODE_TIMEOUT
This controls the number of seconds that the conductor will wait for a section leader to start up and load a score before deciding that something has failed. The default for starting a section leader process is 30. The default for loading a score is 120.
APT_PM_SHOWRSH
Displays a trace message for every call to RSH.
APT_PM_USE_RSH_LOCALLY
If set, startup will use rsh even on the conductor node.
NLS Support
These environment variables are concerned with WebSphere DataStages implementation of NLS. Note: You should not change the settings of any of these environment variables other than APT_COLLATION _STRENGTH if NLS is enabled on your server.
APT_COLLATION_SEQUENCE
This variable is used to specify the global collation sequence to be used by sorts, compares, etc. This value can be overridden at the stage level.
68
APT_COLLATION_STRENGTH
Set this to specify the defines the specifics of the collation algorithm. This can be used to ignore accents, punctuation or other details. It is set to one of Identical, Primary, Secondary, Tertiary, or Quartenary. Setting it to Default unsets the environment variable. http://oss.software.ibm.com/icu/userguide/Collate_Concepts.html
APT_ENGLISH_MESSAGES
If set to 1, outputs every message issued with its English equivalent.
APT_IMPEXP_CHARSET
Controls the character encoding of ustring data imported and exported to and from WebSphere DataStage, and the record and field properties applied to ustring fields. Its syntax is:
APT_IMPEXP_CHARSET icu_character_set
APT_INPUT_CHARSET
Controls the character encoding of data input to schema and configuration files. Its syntax is:
APT_INPUT_CHARSET icu_character_set
APT_OS_CHARSET
Controls the character encoding WebSphere DataStage uses for operating system data such as the names of created files and the parameters to system calls. Its syntax is:
APT_OS_CHARSET icu_character_set
APT_OUTPUT_CHARSET
Controls the character encoding of WebSphere DataStage output messages and operators like peek that use the error logging system to output data input to the osh parser. Its syntax is:
APT_OUTPUT_CHARSET icu_character_set
APT_STRING_CHARSET
Controls the character encoding WebSphere DataStage uses when performing automatic conversions between string and ustring fields. Its syntax is:
APT_STRING_CHARSET icu_character_set
Oracle Support
These environment variables are concerned with the interaction between WebSphere DataStage and Oracle databases.
APT_ORACLE_LOAD_DELIMITED
If this is defined, the orawrite operator creates delimited records when loading into Oracle sqlldr. This method preserves leading and trailing blanks within string fields (VARCHARS in the database). The
Chapter 6. Environment Variables
69
value of this variable is used as the delimiter. If this is defined without a value, the default delimiter is a comma. Note that you cannot load a string which has embedded double quotes if you use this.
APT_ORACLE_LOAD_OPTIONS
You can use the environment variable APT_ORACLE_LOAD_OPTIONS to control the options that are included in the Oracle load control file.You can load a table with indexes without using the Index Mode or Disable Constraints properties by setting the APT_ORACLE_LOAD_OPTIONS environment variable appropriately. You need to set the Direct option and/or the PARALLEL option to FALSE, for example:
APT_ORACLE_LOAD_OPTIONS=OPTIONS(DIRECT=FALSE,PARALLEL=TRUE)
In this example the stage would still run in parallel, however, since DIRECT is set to FALSE, the conventional path mode rather than the direct path mode would be used. If loading index organized tables (IOTs), you should not set both DIRECT and PARALLEL to true as direct parallel path load is not allowed for IOTs.
APT_ORACLE_NO_OPS
Set this if you do not have Oracle Parallel server installed on an AIX system. It disables the OPS checking mechanism on the Oracle Enterprise stage.
APT_ORACLE_PRESERVE_BLANKS
Set this to set the PRESERVE BLANKS option in the control file. This preserves leading and trailing spaces. When PRESERVE BLANKS is not set Oracle removes the spaces and considers fields with only spaces to be NULL values.
APT_ORA_IGNORE_CONFIG_FILE_PARALLELISM
By default WebSphere DataStage determines the number of processing nodes available for a parallel write to Oracle from the configuration file. Set APT_ORA_IGNORE_CONFIG_FILE_PARALLELISM to use the number of data files in the destination tables tablespace instead.
APT_ORA_WRITE_FILES
Set this to prevent the invocation of the Oracle loader when write mode is selceted on an Oracle Enterprise destination stage. Instead, the sqlldr commands are written to a file, the name of which is specified by this environment variable. The file can be invoked once the job has finished to run the loaders sequentially. This can be useful in tracking down export and pipe-safety issues related to the loader.
APT_ORAUPSERT_COMMIT_ROW_INTERVAL APT_ORAUPSERT_COMMIT_TIME_INTERVAL
These two environment variables work together to specify how often target rows are committed when using the Upsert method to write to Oracle. Commits are made whenever the time interval period has passed or the row interval is reached, whichever comes first. By default, commits are made every 2 seconds or 5000 rows.
70
Partitioning
The following environment variables are concerned with how WebSphere DataStage automatically partitions data.
APT_NO_PART_INSERTION
WebSphere DataStage automatically inserts partition components in your application to optimize the performance of the stages in your job. Set this variable to prevent this automatic insertion.
APT_PARTITION_COUNT
Read only. WebSphere DataStage sets this environment variable to the number of partitions of a stage. The number is based both on information listed in the configuration file and on any constraints applied to the stage. The number of partitions is the degree of parallelism of a stage. For example, if a stage executes on two processing nodes, APT_PARTITION_COUNT is set to 2. You can access the environment variable APT_PARTITION_COUNT to determine the number of partitions of the stage from within: v an operator wrapper v a shell script called from a wrapper v getenv() in C++ code v sysget() in the SAS language.
APT_PARTITION_NUMBER
Read only. On each partition, WebSphere DataStage sets this environment variable to the index number (0, 1, ...) of this partition within the stage. A subprocess can then examine this variable when determining which partition of an input file it should handle.
APT_DELIMITED_READ_SIZE
By default, the WebSphere DataStage will read ahead 500 bytes to get the next delimiter. For streaming inputs (socket, FIFO, etc.) this is sub-optimal, since the WebSphere DataStage may block (and not output any records). WebSphere DataStage, when reading a delimited record, will read this many bytes (minimum legal value for this is 2) instead of 500. If a delimiter is NOT available within N bytes, N will be incremented by a factor of 2 (when this environment variable is not set, this changes to 4).
APT_FILE_IMPORT_BUFFER_SIZE
The value in kilobytes of the buffer for reading in files. The default is 128 (i.e., 128 KB). It can be set to values from 8 upward, but is clamped to a minimum value of 8. That is, if you set it to a value less than 8, then 8 is used. Tune this upward for long-latency files (typically from heavily loaded file servers).
71
APT_FILE_EXPORT_BUFFER_SIZE
The value in kilobytes of the buffer for writing to files. The default is 128 (i.e., 128 KB). It can be set to values from 8 upward, but is clamped to a minimum value of 8. That is, if you set it to a value less than 8, then 8 is used. Tune this upward for long-latency files (typically from heavily loaded file servers).
APT_IMPORT_PATTERN_USES_FILESET
When this is set, WebSphere DataStage will turn any file pattern into a fileset before processing the files. This allows the files to be processed in parallel as apposed to sequentially. By default file pattern will cat the files together to be used as the input.
APT_MAX_DELIMITED_READ_SIZE
By default, when reading, WebSphere DataStage will read ahead 500 bytes to get the next delimiter. If it is not found, WebSphere DataStage looks ahead 4*500=2000 (1500 more) bytes, and so on (4X) up to 100,000 bytes. This variable controls the upper bound which is by default 100,000 bytes. Note that this variable should be used instead of APT_DELIMITED_READ_SIZE when a larger than 500 bytes read-ahead is desired.
APT_PREVIOUS_FINAL_DELIMITER_COMPATIBLE
Set this to revert to the pre-release 7.5 behavior of the final delimiter whereby, when writing data, a space is inserted after every field in a record including the last one. (The new behavior is that the a space is written after every field except the last one).
APT_STRING_PADCHAR
Overrides the pad character of 0x0 (ASCII null), used by default when WebSphere DataStage extends, or pads, a string field to a fixed length.
Reporting
These environment variables are concerned with various aspects of WebSphere DataStage jobs reporting their progress.
APT_DUMP_SCORE
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting. Configures WebSphere DataStage to print a report showing the operators, processes, and data sets in a running job.
APT_ERROR_CONFIGURATION
Controls the format of WebSphere DataStage output messages. Note: Changing these settings can seriously interfere with WebSphere DataStage logging. This variables value is a comma-separated list of keywords (see table below). Each keyword enables a corresponding portion of the message. To disable that portion of the message, precede it with a !. Default formats of messages displayed by WebSphere DataStage include the keywords severity, moduleId, errorIndex, timestamp, opid, and message.
72
The following table lists keywords, the length (in characters) of the associated components in the message, and the keywords meaning. The characters ## precede all messages. The keyword lengthprefix appears in three locations in the table. This single keyword controls the display of all length prefixes.
Keyword severity vseverity jobid Length 1 7 3 Meaning Severity indication: F, E, W, or I. Verbose description of error severity (Fatal, Error, Warning, Information). The job identifier of the job. This allows you to identify multiple jobrunning at once. The default job identifier is 0. The module identifier. For WebSphere DataStage-defined messages, this value is a four byte string beginning with T. For user-defined messages written to the error log, this string is USER. For all outputs from a subprocess, the string is USBP. The index of the message specified at the time the message was written to the error log. The message time stamp. This component consists of the string HH:MM:SS(SEQ), at the time the message was written to the error log. Messages generated in the same second have ordered sequence numbers. The IP address of the processing node generating the message. This 15-character string is in octet form, with individual octets zero filled, for example, 104.032.007.100. Length in bytes of the following field. The node name of the processing node generating the message. Length in bytes of the following field.
moduleId
errorIndex
timestamp
13
ipaddr
15
2 variable 2
73
Keyword opid
Length variable
Meaning The string <main_program> for error messages originating in your main program (outside of a step or within the APT_Operator::describeOperator() override). The string <node_nodename> representing system error messages originating on a node, where nodename is the name of the node. The operator originator identifier, represented by ident, partition_number, for errors originating within a step. This component identifies the instance of the operator that generated the message. ident is the operator name (with the operator index in parenthesis if there is more than one instance of it). partition_number defines the partition number of the operator issuing the message.
lengthprefix message
5 variable 1
Length, in bytes, of the following field. Maximum length is 15 KB. Error text. Newline character
APT_MSG_FILELINE
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. Set this to have WebSphere DataStage log extra internal information for parallel jobs.
APT_PM_PLAYER_MEMORY
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. Setting this variable causes each player process to report the process heap memory allocation in the job log when returning.
APT_PM_PLAYER_TIMING
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. Setting this variable causes each player process to report its call and return in the job log. The message with the return is annotated with CPU times for the player process.
APT_RECORD_COUNTS
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. Causes WebSphere DataStage to print to the job log, for each operator player, the number of records input and output. Abandoned input records are not necessarily accounted for. Buffer operators do not print this information.
74
OSH_DUMP
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. If set, it causes WebSphere DataStage to put a verbose description of a job in the job log before attempting to execute it.
OSH_ECHO
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. If set, it causes WebSphere DataStage to echo its job specification to the job log after the shell has expanded all arguments.
OSH_EXPLAIN
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. If set, it causes WebSphere DataStage to place a terse description of the job in the job log before attempting to run it.
OSH_PRINT_SCHEMAS
This environment variable is available in the WebSphere DataStage Administrator under the Parallel Reporting branch. If set, it causes WebSphere DataStage to print the record schema of all data sets and the interface schema of all operators in the job log.
SAS Support
These environment variables are concerned with WebSphere DataStage interaction with SAS.
APT_HASH_TO_SASHASH
The WebSphere DataStage hash partitioner contains support for hashing SAS data. In addition, WebSphere DataStage provides the sashash partitioner which uses an alternative non-standard hashing algorithm. Setting the APT_HASH_TO_SASHASH environment variable causes all appropriate instances of hash to be replaced by sashash. If the APT_NO_SAS_TRANSFORMS environment variable is set, APT_HASH_TO_SASHASH has no affect.
APT_NO_SASOUT_INSERT
This variable selectively disables the sasout operator insertions. It maintains the other SAS-specific transformations.
APT_NO_SAS_TRANSFORMS
WebSphere DataStage automatically performs certain types of SAS-specific component transformations, such as inserting an sasout operator and substituting sasRoundRobin for RoundRobin. Setting the APT_NO_SAS_TRANSFORMS variable prevents WebSphere DataStage from making these transformations.
APT_SAS_ACCEPT_ERROR
When a SAS procedure causes SAS to exit with an error, this variable prevents the SAS-interface operator from terminating. The default behavior is for WebSphere DataStage to terminate the operator with an error.
Chapter 6. Environment Variables
75
APT_SAS_CHARSET
When the -sas_cs option of a SAS-interface operator is not set and a SAS-interface operator encounters a ustring, WebSphere DataStage interrogates this variable to determine what character set to use. If this variable is not set, but APT_SAS_CHARSET_ABORT is set, the operator will abort; otherwise the -impexp_charset option or the APT_IMPEXP_CHARSET environment variable is accessed. Its syntax is:
APT_SAS_CHARSET icu_character_set | SAS_DBCSLANG
APT_SAS_CHARSET_ABORT
Causes a SAS-interface operator to abort if WebSphere DataStage encounters a ustring in the schema and neither the -sas_cs option nor the APT_SAS_CHARSET environment variable is set.
APT_SAS_COMMAND
Overrides the $PATH directory for SAS with an absolute path to the basic SAS executable. An example path is:
/usr/local/sas/sas8.2/sas
APT_SASINT_COMMAND
Overrides the $PATH directory for SAS with an absolute path to the International SAS executable. An example path is:
/usr/local/sas/sas8.2int/dbcs/sas
APT_SAS_DEBUG
Set this to set debug in the SAS process coupled to the SAS stage. Messages appear in the SAS log, which may then be copied into the WebSphere DataStage log. Use APT_SAS_DEBUG=1, APT_SAS_DEBUG_IO=1, and APT_SAS_DEBUG_VERBOSE=1 to get all debug messages.
APT_SAS_DEBUG_IO
Set this to set input/output debug in the SAS process coupled to the SAS stage. Messages appear in the SAS log, which may then be copied into the WebSphere DataStage log.
APT_SAS_DEBUG_LEVEL
Its syntax is:
APT_SAS_DEBUG_LEVEL=[0-3]
Specifies the level of debugging messages to output from the SAS driver. The values of 1, 2, and 3 duplicate the output for the -debug option of the SAS operator:
no, yes, and verbose.
APT_SAS_DEBUG_VERBOSE
Set this to set verbose debug in the SAS process coupled to the SAS stage. Messages appear in the SAS log, which may then be copied into the WebSphere DataStage log.
76
APT_SAS_NO_PSDS_USTRING
Set this to prevent WebSphere DataStage from automatically converting SAS char types to ustrings in an SAS parallel data set.
APT_SAS_S_ARGUMENT
By default, WebSphere DataStage executes SAS with -s 0. When this variable is set, its value is be used instead of 0. Consult the SAS documentation for details.
APT_SAS_SCHEMASOURCE_DUMP
When using SAS Schema Source, sauses the command line to be written to the log when executing SAS. You use it to inspect the data contained in a -schemaSource. Set this if you are getting an error when specifying the SAS data set containing the schema source.
APT_SAS_SHOW_INFO
Displays the standard SAS output from an import or export transaction. The SAS output is normally deleted since a transaction is usually successful.
APT_SAS_TRUNCATION
Its syntax is:
APT_SAS_TRUNCATION ABORT | NULL | TRUNCATE
Because a ustring of n characters does not fit into n characters of a SAS char value, the ustring value must be truncated beyond the space pad characters and \0. The sasin and sas operators use this variable to determine how to truncate a ustring value to fit into a SAS char field. TRUNCATE, which is the default, causes the ustring to be truncated; ABORT causes the operator to abort; and NULL exports a null field. For NULL and TRUNCATE, the first five occurrences for each column cause an information message to be issued to the log.
Sorting
The following environment variables are concerned with how WebSphere DataStage automatically sorts data.
APT_NO_SORT_INSERTION
WebSphere DataStage automatically inserts sort components in your job to optimize the performance of the operators in your data flow. Set this variable to prevent this automatic insertion.
APT_SORT_INSERTION_CHECK_ONLY
When sorts are inserted automatically by WebSphere DataStage, if this is set, the sorts will just check that the order is correct, they wont actually sort. This is a better alternative to shutting partitioning and sorting off insertion off using APT_NO_PART_INSERTION and APT_NO_SORT_INSERTION.
77
Teradata Support
The following environment variables are concerned with WebSphere DataStage interaction with Teradata databases.
APT_TERA_64K_BUFFERS
WebSphere DataStage assumes that the terawrite operator writes to buffers whose maximum size is 32 KB. Enable the use of 64 KB buffers by setting this variable. The default is that it is not set.
APT_TERA_NO_ERR_CLEANUP
Setting this variable prevents removal of error tables and the partially written target table of a terawrite operation that has not successfully completed. Set this variable for diagnostic purposes only. In some cases, setting this variable forces completion of an unsuccessful write operation.
APT_TERA_NO_SQL_CONVERSION
Set this to prevent the SQL statements you are generating from being converted to the character set specified for your stage (character sets can be specified at project, job, or stage level). The SQL statements are converted to LATIN1 instead.
APT_TERA_NO_PERM_CHECKS
Set this to bypass permission checking on the several system tables that need to be readable for the load process. This can speed up the start time of the load process slightly.
APT_TERA_SYNC_DATABASE
Specifies the database used for the terasync table. By default, the database used for the terasync table is specified as part of APT_TERA_SYNC_USER. If you want the database to be different, set this variable. You must then give APT_TERA_SYNC_USER read and write permission for this database.
APT_TERA_SYNC_PASSWORD
Specifies the password for the user identified by APT_TERA_SYNC_USER.
APT_TERA_SYNC_USER
Specifies the user that creates and writes to the terasync table.
Transport Blocks
The following environment variables are all concerned with the block size used for the internal transfer of data as jobs run. Some of the settings only apply to fixed length records The following variables are used only for fixed-length records.: v APT_MIN_TRANSPORT_BLOCK_SIZE v APT_MAX_TRANSPORT_BLOCK_SIZE v APT_DEFAULT_TRANSPORT_BLOCK_SIZE v APT_LATENCY_COEFFICIENT v APT_AUTO_TRANSPORT_BLOCK_SIZE
78
APT_AUTO_TRANSPORT_BLOCK_SIZE
This environment variable is available in the WebSphere DataStage Administrator, under the Parallel category. When set, Orchestrate calculates the block size for transferring data internally as jobs run. It uses this algorithm:
if (recordSize * APT_LATENCY_COEFFICIENT < APT_MIN_TRANSPORT_BLOCK_SIZE) blockSize = minAllowedBlockSize else if (recordSize * APT_LATENCY_COEFFICIENT > APT_MAX_TRANSPORT_BLOCK_SIZE) blockSize = maxAllowedBlockSize else blockSize = recordSize * APT_LATENCY_COEFFICIENT
APT_LATENCY_COEFFICIENT
Specifies the number of writes to a block which transfers data between players. This variable allows you to control the latency of data flow through a step. The default value is 5. Specify a value of 0 to have a record transported immediately. This is only used for fixed length records. Note: Many operators have a built-in latency and are not affected by this variable.
APT_DEFAULT_TRANSPORT_BLOCK_SIZE
Specify the default block size for transferring data between players. It defaults to 131072 (128 KB).
APT_MAX_TRANSPORT_BLOCK_SIZE/ APT_MIN_TRANSPORT_BLOCK_SIZE
Specify the minimum and maximum allowable block size for transferring data between players. APT_MIN_TRANSPORT_BLOCK_SIZE cannot be less than 8192 which is its default value. APT_MAX_TRANSPORT_BLOCK_SIZE cannot be greater than 1048576 which is its default value. These variables are only meaningful when used in combination with APT_LATENCY_COEFFICIENT and APT_AUTO_TRANSPORT_BLOCK_SIZE.
79
Performance tuning
v APT_BUFFER_MAXIMUM_MEMORY v APT_BUFFER_FREE_RUN v TMPDIR. This defaults to /tmp. It is used for miscellaneous internal temporary data, including FIFO queues and Transformer temporary storage. As a minor optimization, it can be better to ensure that it is set to a file system separate to the WebSphere DataStage install directory.
80
Chapter 7. Operators
The parallel job stages are built on operators. This chapter describes those operators and is intended for knowledgeable Orchestrate users. The first section describes how WebSphere DataStage stages map to operators. Subsequent sections are an alphabetical listing and description of operators. Some operators are part of a library of related operators, and each of these has its own chapter as follows: v The Import/Export Library v The Partitioning Library v The Collection Library v The Restructure Library v The Sorting Library v The Join Library v The ODBC Interface Library v The SAS Interface Library v The Oracle Interface Library v The DB2 Interface Library v v v v The The The The Informix Interface Library Sybase Interface Library SQL Server Interface Library iWay Interface Library
In these descriptions, when we talk about WebSphere DataStage we mean the parallel engine that WebSphere DataStage uses to execute the operators.
81
Table 1. Stage to Operator Mapping (continued) WebSphere DataStage Stage Operator Options (where applicable) Comment -sourcelist External Target Export Operator -destination -destinationlist Complex Flat File Transformer BASIC Transformer Import Operator Transform Operator Represents server job transformer stage (gives access to BASIC transforms) Group Operator fullouterjoin Operator innerjoin Operator leftouterjoin Operator rightouterjoin Operator Merge Lookup Merge Operator Lookup Operator The oralookup Operator The db2lookup Operator The sybaselookup Operator for direct lookup in Oracle table (`sparse mode) for direct lookup in DB2 table (`sparse mode) for direct lookup in table acessed via iWay (`sparse mode) for direct lookup in Sybase table (`sparse mode)
Aggregator Join
The sybaselookup Operator The sqlsrvrlookup Operator Funnel Funnel Operators Sortfunnel Operator Sequence Operator Sort The psort Operator The tsort Operator Remove Duplicates Compress Expand Copy Modify Filter External Filter Change Capture Change Apply Difference Compare Remdup Operator Pcompress Operator Pcompress Operator Generator Operator Modify Operator Filter Operator Changecapture Operator Changeapply Operator Diff Operator Compare Operator -compress -expand
82
Table 1. Stage to Operator Mapping (continued) WebSphere DataStage Stage Encode Decode Switch Generic Surrogate Key Column Import Column Export Make Subrecord Split Subrecord Combine records Promote subrecord Make vector Split vector Head Tail Sample Peek Row Generator Column generator Write Range Map SAS Parallel Data Set SAS Operator Encode Operator Encode Operator Switch Operator Surrogate key operator The field_import Operator The field_export Operator The makesubrec Operator The splitsubrec Operator The aggtorec Operator The makesubrec Operator The makevect Operator The splitvect Operator Head Operator Tail Operator Sample Operator Peek Operator Generator Operator Generator Operator Writerangemap Operator The sas Operator The sasout Operator The sasin Operator The sascontents Operator DB2/UDB Enterprise The db2read Operator The db2write and db2load Operators The db2upsert Operator The db2lookup Operator Oracle Enterprise The oraread Operator The oraupsert Operator The orawrite Operator The oralookup Operator Informix Enterprise The hplread operator The hplwrite Operator The infxread Operator For in-memory (`normal) lookups For in-memory (`normal) lookups ( Represents Orchestrate parallel SAS data set. Any operator Options (where applicable) Comment -encode -decode
Chapter 7. Operators
83
Table 1. Stage to Operator Mapping (continued) WebSphere DataStage Stage Operator The infxwrite Operator The xpsread Operator The xpswrite Operator Teradata Teraread Operator Terawrite Operator Sybase The sybasereade Operator The sybasewrite Operator The sybaseupsert Operator The sybaselookup Operator SQL Server The sqlsrvrread Operator The sqlsrvrwrite Operator The sqlsrvrupsert Operator The sybaselookup Operator iWay The iwayread Operator The iwaylookup Operator For in-memory (`normal) lookups For in-memory (`normal) lookups Options (where applicable) Comment
Changeapply operator
The changeapply operator takes the change data set output from the changecapture operator and applies the encoded change operations to a before data set to compute an after data set. If the before data set is identical to the before data set that was input to the changecapture operator, then the output after data set for changeapply is identical to the after data set that was input to the changecapture operator. That is:
change := changecapture(before, after) after := changeapply(before, change)
You use the companion operator changecapture to provide a data set that contains the changes in the before and after data sets.
afterRec:*
Properties
Table 2. changeapply Operator Properties Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Input partitioning style Output partitioning style Preserve-partitioning flag in output data set Composite operator Value 2 1 beforeRec:*, changeRec:* afterRec:* changeRec:*->afterRec:*, dropping the change_code field; beforeRec:*->afterRec:* with type conversions keys in same partition keys in same partition propagated no
The before input to changeapply must have the same fields as the before input that was input to changecapture, and an automatic conversion must exist between the types of corresponding fields. In addition, results are only guaranteed if the contents of the before input to changeapply are identical (in value and record order in each partition) to the before input that was fed to changecapture, and if the keys are unique. The change input to changeapply must have been output from changecapture without modification. Because preserve-partitioning is set on the change output of changecapture (under normal circumstances you should not override this), the changeapply operator has the same number of partitions as the changecapture operator. Additionally, both inputs of changeapply are designated as same partitioning by the operator logic. The changeapply operator performs these actions for each change record: v If the before keys come before the change keys in the specified sort order, the before record is consumed and transferred to the output; no change record is consumed. This is a copy. v If the before keys are equal to the change keys, the behavior depends on the code in the change_code field of the change record: Insert: The change record is consumed and transferred to the output; no before record is consumed. If key fields are not unique, and there is more than one consecutive insert with the same key, then changeapply applies all the consecutive inserts before existing records. This record order may be different from the after data set given to changecapture. Delete: The value fields of the before and change records are compared. If they are not the same, the before record is consumed and transferred to the output; no change record is consumed (copy). If the value fields are the same or if ignoreDeleteValues is specified, the change and before records are both consumed; no record is transferred to the output. If key fields are not unique, the value fields ensure that the correct record is deleted. If more than one record with the same keys have matching value fields, the first encountered is deleted. This may cause different record ordering than in the after data set given to the changecapture operator. Edit: The change record is consumed and transferred to the output; the before record is just consumed. If key fields are not unique, then the first before record encountered with matching keys is edited. This may be a different record from the one that was edited in the after data set given to the changecapture operator, unless the -keepCopy option was used. Copy: The change record is consumed. The before record is consumed and transferred to the output.
Chapter 7. Operators
85
v If the before keys come after the change keys, behavior also depends on the change_code field. Insert: The change record is consumed and transferred to the output; no before record is consumed (the same as when the keys are equal). Delete: A warning is issued and the change record is consumed; no record is transferred to the output; no before record is consumed. Edit or Copy: A warning is issued and the change record is consumed and transferred to the output; no before record is consumed. This is an insert. v If the before input of changeapply is identical to the before input of changecapture and either keys are unique or copy records are used, then the output of changeapply is identical to the after input of changecapture. However, if the before input of changeapply is not the same (different record contents or ordering), or keys are not unique and copy records are not used, this fact is not detected and the rules described above are applied anyway, producing a result that might or might not be useful.
Schemas
The changeapply output data set has the same schema as the change data set, with the change_code field removed. The before interface schema is:
record (key:type; ... value:type; ... beforeRec:*;)
Transfer behavior
The change to after transfer uses an internal transfer adapter to drop the change_code field from the transfer. This transfer is declared first, so the schema of the change data set determines the schema of the after data set.
86
[-editCode n] [-ignoreDeleteValues] [-insertCode n] [-value inpt_field_name [-ci | -cs] [param params] ...]
Note: The -checkSort option has been deprecated. By default, partitioner and sort components are now inserted automatically.
Option -key Use -key input_field_name [-cs | ci] [-asc | -desc] [-nulls first | last] [-param params ] [-key input_field_name [-cs | ci] [-asc | -desc] [-nulls first | last] [-param params ] ...] Specify one or more key fields. You must specify at least one key for this option or specify the -allkeys option. These options are mutually exclusive.You cannot use a vector, subrecord, or tagged aggregate field as a value key. The -ci suboption specifies that the comparison of value keys is case insensitive. The -cs suboption specifies a case-sensitive comparison, which is the default. -asc and -desc specify ascending or descending sort order. -nulls first | last specifies the position of nulls. The -params suboption allows you to specify extra parameters for a key. Specify parameters using pr operty = value pairs separated by commas. -allkeys -allkeys [-cs | ci] [-asc | -desc] [-nulls first | last] [-param params] Specify that all fields not explicitly declared are key fields. The suboptions are the same as the suboptions described for the -key option above. You must specify either the -allkeys option or the -key option. They are mutually exclusive. -allvalues -allvalues [-cs | ci] [-param params] Specify that all fields not otherwise explicitly declared are value fields. The -ci suboption specifies that the comparison of value keys is case insensitive. The -cs suboption specifies a case-sensitive comparison, which is the default. The -param suboption allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas. The -allvalues option is mutually exclusive with the -value and -allkeys options. -codeField -codeField field_name The name of the change code field. The default is change_code. This should match the field name used in changecapture.
Chapter 7. Operators
87
Option -collation_sequence
Use -collation_sequence locale | collation_file_pathname | OFF This option determines how your string data is sorted. You can: v Specify a predefined IBM ICU locale. v Write your own collation sequence using ICU syntax, and supply its collation_file_pathname. v Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence. By default, WebSphere DataStage sorts strings using byte-wise comparisons. For more information, reference this IBM ICU site: http://oss.software.ibm.com/icu/userguide/ Collate_Intro.html
-copyCode
-copyCode n Specifies the value for the change_code field in the change record for the copy result. The n value is an int8. The default value is 0. A copy record means that the before record should be copied to the output without modification.
-deleteCode
-deleteCode n Specifies the value for the change_code field in the change record for the delete result. The n value is an int8. The default value is 2. A delete record means that a record in the before data set must be deleted to produce the after data set.
-doStats
-doStats Configures the operator to display result information containing the number of input records and the number of copy, delete, edit, and insert records.
-dropkey
-dropkey input_field_name Optionally specify that the field is not a key field. If you specify this option, you must also specify the -allkeys option. There can be any number of occurrences of this option.
-dropvalue
-dropvalue input_field_name Optionally specify that the field is not a value field. If you specify this option, you must also specify the -allvalues option. There can be any number of occurrences of this option.
88
Option -editCode
Use -editCode n Specifies the value for the change_code field in the change record for the edit result. The n value is an int8. The default value is 3. An edit record means that the value fields in the before data set must be edited to produce the after data set.
-ignoreDeleteValues
-ignoreDeleteValues Do not check value fields on deletes. Normally, changeapply compares the value fields of delete change records to those in the before record to ensure that it is deleting the correct record. The -ignoreDeleteValues option turns off this behavior.
-insertCode
-insertCode n Specifies the value for the change_code field in the output record for the insert result. The n value is an int8. The default value is 1. An insert means that a record must be inserted into the before data set to reproduce the after data set.
-value
-value field [-ci| -cs] [param params] Optionally specifies the name of a value field. The -value option may be repeated if there are multiple value fields. The value fields are modified by edit records, and can be used to ensure that the correct record is deleted when keys are not unique. Note that you cannot use a vector, subrecord, or tagged aggregate field as a value key. The -ci suboption specifies that the comparison of values is case insensitive. The -cs suboption specifies a case-sensitive comparison, which is the default. The -params suboption allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas. The -value and -allvalues options are mutually exclusive.
Example
This example assumes that the input data set records contain customer, month, and balance fields. The operation examines the customer and month fields of each input record for differences. By default, WebSphere DataStage inserts partition and sort components to meet the partitioning and sorting needs of the changeapply operator and other operators. Here is the data flow diagram for the example:
Chapter 7. Operators
89
before
after
hash
hash
tsort
tsort
copy
90
Changecapture operator
The changecapture operator takes two input data sets, denoted before and after, and outputs a single data set whose records represent the changes made to the before data set to obtain the after data set. The operator produces a change data set, whose schema is transferred from the schema of the after data set with the addition of one field: a change code with values encoding the four actions: insert, delete, copy, and edit. The preserve-partitioning flag is set on the change data set. You can use the companion operator changeapply to combine the changes from the changecapture operator with the original before data set to reproduce the after data set. The changecapture operator is very similar to the diff operator described in Diff Operator .
change_code:int8; changeRec:*;
Transfer behavior
In the insert and edit cases, the after input is transferred to output. In the delete case, an internal transfer adapter transfers the before keys and values to output. In the copy case, the after input is optionally transferred to output. Because an internal transfer adapter is used, no user transfer or view adapter can be used with the changecapture operator.
Determining differences
The changecapture output data set has the same schema as the after data set, with the addition of a change_code field. The contents of the output depend on whether the after record represents an insert, delete, edit, or copy to the before data set: v Insert: a record exists in the after data set but not the before data set as indicated by the sorted key fields. The after record is consumed and transferred to the output. No before record is consumed.
Chapter 7. Operators
91
If key fields are not unique, changecapture may fail to identify an inserted record with the same key fields as an existing record. Such an insert may be represented as a series of edits, followed by an insert of an existing record. This has consequences for changeapply. v Delete: a record exists in the before data set but not the after data set as indicated by the sorted key fields. The before record is consumed and the key and value fields are transferred to the output; no after record is consumed. If key fields are not unique, changecapture may fail to identify a deleted record if another record with the same keys exists. Such a delete may be represented as a series of edits, followed by a delete of a different record. This has consequences for changeapply. v Edit: a record exists in both the before and after data sets as indicated by the sorted key fields, but the before and after records differ in one or more value fields. The before record is consumed and discarded; the after record is consumed and transferred to the output. If key fields are not unique, or sort order within a key is not maintained between the before and after data sets, spurious edit records may be generated for those records whose sort order has changed. This has consequences for changeapply v Copy: a record exists in both the before and after data sets as indicated by the sorted key fields, and furthermore the before and after records are identical in value fields as well. The before record is consumed and discarded; the after record is consumed and optionally transferred to the output. If no after record is transferred, no output is generated for the record; this is the default. The operator produces a change data set, whose schema is transferred from the schema of the after data set, with the addition of one field: a change code with values encoding insert, delete, copy, and edit. The preserve-partitioning flag is set on the change data set.
Terms in italic typeface are option strings you supply. When your option string contains a space or a tab character, you must enclose it in single quotes. You must specify either one or more -key fields or the -allkeys option. You can parameterize each key fields comparison operation and specify the expected sort order (the default is ascending). Note: The -checkSort option has been deprecated. By default, partitioner and sort components are now inserted automatically.
92
Option -key
Use -key input_field_name [-cs | ci] [-asc | -desc] [-nulls first | last] [-param params] [-key input_field_name [-cs | ci] [-asc | -desc] [-nulls first | last] [-param params] ...] Specify one or more key fields. You must specify either the -allkeys option or at least one key for the -key option. These options are mutually exclusive.You cannot use a vector, subrecord, or tagged aggregate field as a value key. The -ci option specifies that the comparison of value keys is case insensitive. The -cs option specifies a case-sensitive comparison, which is the default. -asc and -desc specify ascending or descending sort order. -nulls first | last specifies the position of nulls. The -param suboption allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas.
-allkeys
-allkeys [-cs | ci] [-asc | -desc] [-nulls first | last] [-param params] Specify that all fields not explicitly declared are key fields. The suboptions are the same as the suboptions described for the -key option above. You must specify either the -allkeys option or the -key option. They are mutually exclusive.
-allvalues
-allvalues [-cs | ci] [-param params] Specify that all fields not otherwise explicitly declared are value fields. The -ci option specifies that the comparison of value keys is case insensitive. The -cs option specifies a case-sensitive comparison, which is the default. The -param option allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas. The -allvalues option is mutually exclusive with the -value and -allkeys options. You must specify the -allvalues option when you supply the -dropkey option.
-codeField
-codeField field_name Optionally specify the name of the change code field. The default is change_code.
Chapter 7. Operators
93
Option -collation_sequence
Use -collation_sequence locale | collation_file_pathname | OFF This option determines how your string data is sorted. You can: v Specify a predefined IBM ICU locale v Write your own collation sequence using ICU syntax, and supply its collation_file_pathname v Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence. By default, WebSphere DataStage sorts strings using byte-wise comparisons. For more information, reference this IBM ICU site: http://oss.software.ibm.com/icu/userguide/ Collate_Intro.html
-copyCode
-copyCode n Optionally specify the value of the change_code field in the output record for the copy result. The n value is an int8. The default value is 0. A copy result means that all keys and all values in the before data set are equal to those in the after data set.
-deleteCode
-deleteCode n Optionally specify the value for the change_code field in the output record for the delete result. The n value is an int8. The default value is 2. A delete result means that a record exists in the before data set but not in the after data set as defined by the key fields.
-doStats
-doStats Optionally configure the operator to display result information containing the number of input records and the number of copy, delete, edit, and insert records.
-dropkey
-dropkey input_field_name Optionally specify that the field is not a key field. If you specify this option, you must also specify the -allkeys option. There can be any number of occurrences of this option.
-dropvalue
-dropvalue input_field_name Optionally specify that the field is not a value field. If you specify this option, you must also specify the -allvalues option. There can be any number of occurrences of this option.
94
Option -editCode
Use -editCode n Optionally specify the value for the change_code field in the output record for the edit result. The n value is an int8. The default value is 3. An edit result means all key fields are equal but one or more value fields are different.
-insertCode
-insertCode n Optionally specify the value for the change_code field in the output record for the insert result. The n value is an int8. The default value is 1. An insert result means that a record exists in the after data set but not in the before data set as defined by the key fields.
-keepCopy | -dropCopy -keepDelete | -dropDelete -keepEdit | -dropEdit -keepInsert | -dropInsert Optionally specifies whether to keep or drop copy records at output. By default, the operator creates an output record for all differences except copy.
-value
-value field_name [-ci | -cs] [-param params] Optionally specifies one or more value fields. When a before and after record are determined to be copies based on the difference keys (as defined by -key), the value keys can then be used to determine if the after record is an edited version of the before record. Note that you cannot use a vector, subrecord, or tagged aggregate field as a value key. The -ci option specifies that the comparison of values is case insensitive. The -cs option specifies a case-sensitive comparison, which is the default. The -param option allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas. The -value and -allvalues options are mutually exclusive.
Chapter 7. Operators
95
key
value
step
before
after
changecapture
switch
(-key change_code)
You specify these key and value fields to the changecapture operator:
-key month -key customer -value balance
After you run the changecapture operator, you invoke the switch operator to divide the output records into data sets based on the result type. The switch operator in this example creates three output data sets: one for delete results, one for edit results, and one for insert results. It creates only three data sets,
96
because you have explicitly dropped copy results from the changecapture operator by specifying -dropCopy. By creating a separate data set for each of the three remaining result types, you can handle each one differently:
-deleteCode 0 -editCode 1 -insertCode 2
Compare operator
The compare operator performs a field-by-field comparison of records in two presorted input data sets. This operator compares the values of top-level non-vector data types such as strings. All appropriate comparison parameters are supported, for example, case sensitivity and insensitivity for string comparisons. The compare operator does not change the schema, partitioning, or content of the records in either input data set. It transfers both data sets intact to a single output data set generated by the operator. The comparison results are also recorded in the output data set. By default, WebSphere DataStage inserts partition and sort components to meet the partitioning and sorting needs of the changecapture operator and other operators.
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Value 2 1 key0:type0; ... keyN:typeN; inRec:*; result:int8; first:subrec(rec:*;); second:subrec(rec:*;);
Chapter 7. Operators
97
Property Transfer behavior Execution mode Input partitioning style Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator
Value The first input data set is transferred to first.rec, The second input data set is transferred to second.rec parallel (default) or sequential keys in same partition same (parallel mode) any (sequential mode) propagated no
The compare operator: v Compares only scalar data types. See Restrictions . v Takes two presorted data sets as input and outputs one data set. v Has an input interface schema consisting of the key fields and the schema variable inRec, and an output interface schema consisting of the result field of the comparison and a subrecord field containing each input record. Performs a field-by-field comparison of the records of the input data sets. Transfers the two input data sets to the single output data set without altering the input schemas, partitioning, or values. Writes to the output data set signed integers that indicate comparison results.
Restrictions
The compare operator: v Compares only scalar data types, specifically string, integer, float, decimal, raw, date, time, and timestamp; you cannot use the operator to compare data types such as tagged aggregate, subrec, vector, and so on. v Compares only fields explicitly specified as key fields, except when you do not explicitly specify any key field. In that case, the operator compares all fields that occur in both records.
Results field
The operator writes the following default comparison results to the output data set. In each case, you can specify an alternate value:
Description of Comparison Results The record in the first input data set is greater than the corresponding record in the second input data set. The record in the first input data set is equal to the corresponding record in the second input data set. The record in the first input data set is less than the corresponding record in the second input data set. The number of records in the first input data is greater than the number of records in the second input data set. The number of records in the first input data set is less than the number of records in the second input data set. Default Value 1 0 -1 2 -2
When this operator encounters any of the mismatches described in the table shown above, you can force it to take one or both of the following actions:
98
v Terminate the remainder of the current comparison v Output a warning message to the screen
Chapter 7. Operators
99
Use -field fieldname [-ci | -cs] [-param params] | -key fieldname [-ci | -cs] [-param params] -field or -key is a key field to compare in the two input data sets. The maximum number of fields is the number of fields in the input data sets. If no key fields are explicitly specified, all fields shared by the two records being processed are compared. fieldname specifies the name of the field. -ci specifies that the comparison of strings is case-insensitive. -cs specifies case-sensitive string comparison, which is the default. The -param suboption allows you to specify extra parameters for a field. Specify parameters using property=value pairs separated by commas.
-first
-first n Configures the operator to write n (a signed integer between -128 and 127) to the output data set if the number of records in the second input data set exceeds the number of records in the first input data set. The default value is -2.
-gt n | -eq n | -lt n Configures the operator to write n (a signed integer between -128 and 127) to the output data set if the record in the first input data set is: Greater than (-gt) the equivalent record in the second input data set. The default is 1. Equal to (-eq) the equivalent record in the second input data set. The default is 0. Less than (-lt) the equivalent record in the second input data set. The default is -1.
-second
-second n Configures the operator to write n (an integer between -128 and 127) to the output data set if the number of records in the first input data set exceeds the number of records in the second input data set. The default value is 2.
-warnRecordCountMismatch
-warnRecordCountMismatch Forces the operator to output a warning message when a comparison is aborted due to a mismatch in the number of records in the two input data sets.
100
The output record format for a successful comparison of records looks like this, assuming all default values are used:
result:0 first:name; second:age; third:gender;
Copy operator
You can use the modify operator with the copy operator to modify the data set as the operator performs the copy operation. See Modify Operator for more information on modifying data.
Chapter 7. Operators
101
inRec:*;
copy
outRec:*;
outRec:*;
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator Combinable operator Value 1 0 or more (0 - n) set by user inRec:* outRec:* inRec -> outRec without record modification parallel (default) or sequential any (parallel mode) any (sequential mode) propagated no yes
The copy operator: v Takes any single data set as input v Has an input interface schema consisting of a single schema variable inRec and an output interface schema consisting of a single schema variable outRec v Copies the input data set to the output data sets without affecting the record schema or contents
102
Option -checkpoint
Use -checkpoint n Specifies the number of records copied from the input persistent data set to each segment of each partition of the output data set. The value of n must be positive. Its default value is 1. In order for this option to be specified, the input data set to the copy operator must be persistent and the operator must be run in parallel. The step containing the copy operator must be checkpointed, that is, you must have specified the keyword -restartable as part of the step definition.
-force
-force Specifies that WebSphere DataStage cannot attempt to optimize the step by removing the copy operator. In some cases, WebSphere DataStage can remove a copy operator if it determines that the copy operator is unnecessary. However, your job may require the copy operator to execute. In this case, you use the -force option. See Preventing WebSphere DataStage from Removing a copy Operator .
step import
copy
OutDS.ds
Here is the osh command:
$ osh "import -file inFile.dat -schema recordSchema | copy > outDS.ds"
Chapter 7. Operators
103
This occurs: 1. The import operator reads the data file, inFile.data, into a virtual data set. The virtual data set is written to a single partition because it reads a single data file. In addition, the import operator executes only on the processing node containing the file. 2. The copy operator runs on all processing nodes in the default node pool, because no constraints have been applied to the input operator. Thus, it writes one partition of outDS.ds to each processing node in the default node pool. However, if WebSphere DataStage removes the copy operator as part of optimization, the resultant persistent data set, outDS.ds, would be stored only on the processing node executing the import operator. In this example, outDS.ds would be stored as a single partition data set on one node. To prevent removal specify the -force option. The operator explicitly performs the repartitioning operation to spread the data over the system.
step
copy
tsort
Output data set 0 from the copy operator is written to outDS1.ds and output data set 1 is written to the tsort operator. The syntax is as follows:
$ osh "... | copy > outDS1.ds | tsort options ...
104
When run sequentially, the operator uses a collection method of any. However, you can override the collection method of a sequential operator. This can be useful when you want to store a sorted data set to a single partition. Shown below is a osh command data flow example using the ordered collection operator with a sequential copy operator.
$ osh ". . . opt1 | ordered | copy [seq] > outDS.ds"
Diff operator
Note: The diff operator has been superseded by the changecapture operator. While the diff operator has been retained for backwards compatibility, we recommend that you use the changecapture operator for new development. The diff operator performs a record-by-record comparison of two versions of the same data set (the before and after data sets) and outputs a data set whose records represent the difference between them. The operator assumes that the input data sets are hash-partitioned and sorted in ascending order on the key fields you specify for the comparison. The comparison is performed based on a set of difference key fields. Two records are copies of one another if they have the same value for all difference keys. In addition, you can specify a set of value key fields. If two records are copies based on the difference key fields, the value key fields determine if one record is a copy or an edited version of the other. The diff operator is very similar to the changecapture operator described in Changecapture Operator . In most cases, you should use the changecapture operator rather than the diff operator. By default, WebSphere DataStage inserts partition and sort components to meet the partitioning and sorting needs of the diff operator and other operators. The diff operator does not behave like Unix diff.
Properties
Property Number of input data sets Number of output data sets Value 2 1
Chapter 7. Operators
105
Property Input interface schema before data set: after data sets: Output interface schema Transfer behavior before to output: after to output: Execution mode Input partitioning style Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator
Value key0; ... keyn; value0; ... valuen; beforeRec:*; key0; ... keyn; value0; ... valuen; afterRec:*;
diff:int8; beforeRec:*; afterRec:*; beforeRec -> beforeRec without record modification afterRec -> afterRec without record modification
parallel (default) or sequential keys in same partition any (parallel mode) any (sequential mode) propagated no
Transfer behavior
The operator produces a single output data set, whose schema is the catenation of the before and after input schemas. Each record of the output data set has the following format:
diff:int8
The usual name conflict resolution rules apply. The output data set contains a number of records in the range:
num_in_before <= num_in_output <= (num_in_before + num_in_after)
The number of records in the output data set depends on how many records are copies, edits, and deletes. If the before and after data sets are exactly the same, the number of records in the output data set equals the number of records in the before data set. If the before and after data sets are completely different, the output data set contains one record for each before and one record for each after data set record.
Key fields
The before data sets schema determines the difference key type. You can use an upstream modify operator to alter it. The after data sets key field(s) must have the same name as the before key field(s) and be either of the same data type or of a compatible data type. The same rule holds true for the value fields: The after data sets value field(s) must be of the same name and data type as the before value field(s). You can use an upstream modify operator to bring this about. Only top-level, non-vector, non-nullable fields may be used as difference keys. Only top-level, non-vector fields may be used as value fields. Value fields may be nullable.
106
Determining differences
The diff operator reads the current record from the before data set, reads the current record from the after data set, and compares the records of the input data sets using the difference keys. The comparison results are classified as follows: v Insert: A record exists in the after data set but not the before data set. The operator transfers the after record to the output. The operator does not copy the current before record to the output but retains it for the next iteration of the operator. The data types default value is written to each before field in the output. By default the operator writes a 0 to the diff field of the output record. v Delete: A record exists in the before data set but not the after data set. The operator transfers the before record to the output The operator does not copy the current after record to the output but retains it for the next iteration of the operator. The data types default value is written to each after field in the output. By default, the operator writes a 1 to the diff field of the output record. v Copy: The record exists in both the before and after data sets and the specified value field values have not been changed. The before and after records are both transferred to the output. By default, the operator writes a 2 to the diff (first) field of the output record. v Edit: The record exists in both the before and after data sets; however, one or more of the specified value field values have been changed. The before and after records are both transferred to the output. By default, the operator writes a 3 to the diff (first) field of the output record. Options are provided to drop each kind of output record and to change the numerical value written to the diff (first) field of the output record. In addition to the difference key fields, you can optionally define one or more value key fields. If two records are determined to be copies because they have equal values for all the difference key fields, the operator then examines the value key fields. v Records whose difference and value key fields are equal are considered copies of one another. By default, the operator writes a 2 to the diff (first) field of the output record. v Records whose difference key fields are equal but whose value key fields are not equal are considered edited copies of one another. By default, the operator writes a 3 to the diff (first) field of the output record.
107
[-collation_sequence locale |collation_file_pathname | OFF] [-copyCode n] [-deleteCode n] [-dropCopy] [-dropDelete] [-dropEdit] [-dropInsert] [-editCode n] [-insertCode n] [-stats] [-tolerateUnsorted] [-value field [-ci | -cs] [-param params] ...] Option -key Use -key field [-ci | -cs] [-param params] Specifies the name of a difference key field. The -key option may be repeated if there are multiple key fields. Note that you cannot use a nullable, vector, subrecord, or tagged aggregate field as a difference key. The -ci option specifies that the comparison of difference key values is case insensitive. The -csoption specifies a case-sensitive comparison, which is the default. The -params suboption allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas. -allValues -allValues [-ci | -cs] [-param params] Specifies that all fields other than the difference key fields identified by -key are used as value key fields. The operator does not use vector, subrecord, and tagged aggregate fields as value keys and skips fields of these data types. When a before and after record are determined to be copies based on the difference keys, the value keys can then be used to determine if the after record is an edited version of the before record. The -ci option specifies that the comparison of value keys is case insensitive. The -cs option specifies a case-sensitive comparison, which is the default. The -params suboption allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas.
108
Option -collation_sequence
Use -collation_sequence locale |collation_file_pathname | OFF This option determines how your string data is sorted. You can: v Specify a predefined IBM ICU locale v Write your own collation sequence using ICU syntax, and supply its collation_file_pathname v Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence. By default, WebSphere DataStage sorts strings using byte-wise comparisons. For more information, reference this IBM ICU site: http://oss.software.ibm.com/icu/userguide/ Collate_Intro.html
-copyCode
-copyCode n Specifies the value for the diff field in the output record when the before and after records are copies. The n value is an int8. The default value is 2. A copy means all key fields and all optional value fields are equal.
-deleteCode
-deleteCode n Specifies the value for the diff field in the output record for the delete result. The n value is an int8. The default value is 1. A delete result means that a record exists in the before data set but not in the after data set as defined by the difference key fields.
-dropCopy -dropDelete -dropEdit -dropInsert Specifies to drop the output record, meaning not generate it, for any one of the four difference result types. By default, an output record is always created by the operator. You can specify any combination of these four options.
-editCode
-editCode n Specifies the value for the diff field in the output record for the edit result. The n value is an int8. The default value is 3. An edit result means all difference key fields are equal but one or more value key fields are different.
Chapter 7. Operators
109
Option -insertCode
Use -insertCode n Specifies the value for the diff field in the output record for the insert result. The n value is an int8. The default value is 0. An insert result means that a record exists in the after data set but not in the before data set as defined by the difference key fields.
-stats
-stats Configures the operator to display result information containing the number of input records and the number of copy, delete, edit, and insert records.
-tolerateUnsorted
-tolerateUnsorted Specifies that the input data sets are not sorted. By default, the operator generates an error and aborts the step when detecting unsorted inputs. This option allows you to process groups of records that may be arranged by the difference key fields but not sorted. The operator consumes input records in the order in which they appear on its input. If you use this option, no automatic partitioner or sort insertions are made.
-value
-value field [-ci| -cs] Optionally specifies the name of a value key field. The -value option may be repeated if there are multiple value fields. When a before and after record are determined to be copies based on the difference keys (as defined by -key), the value keys can then be used to determine if the after record is an edited version of the before record. Note that you cannot use a vector, subrecord, or tagged aggregate field as a value key. The -ci option specifies that the comparison of value keys is case insensitive. The -cs option specifies a case-sensitive comparison, which is the default. The -params suboption allows you to specify extra parameters for a key. Specify parameters using property=value pairs separated by commas.
110
$ osh " diff -key month -key customer < before.v < after.v > outDS.ds"
before
after
step
diff
switch
(-key diff)
Here is the data flow for this example: You specify these key and value fields to the diff operator:
key=month key=customer value=balance
After you run the diff operator, you invoke the switch operator to divide the output records into data sets based on the result type. The switch operator in this example creates three output data sets: one for
Chapter 7. Operators
111
delete results, one for edit results, and one for insert results. It creates only three data sets, because you have explicitly dropped copy results from the diff operation by specifying -dropCopy. By creating a separate data set for each of the three remaining result types, you can handle each one differently:
deleteCode=0 editCode=1 insertCode=2
Encode operator
The encode operator encodes or decodes a WebSphere DataStage data set using a UNIX encoding command that you supply. The operator can convert a WebSphere DataStage data set from a sequence of records into a stream of raw binary data. The operator can also reconvert the data stream to a WebSphere DataStage data set.
in:*;
encode
(mode = encode)
encode
(mode = decode) out:*; decoded data set
In the figure shown above, the mode argument specifies whether the operator is performing an encoding or decoding operation. Possible values for mode are: v encode: encode the input data set v decode: decode the input data set
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator Combinable operator Value 1 1 mode = encode: in:*; mode = decode: none mode = encode: none mode = decode: out:*; in -> out without record modification for an encode/decode cycle parallel (default) or sequential mode =encode: any mode =decode: same any mode = encode: sets mode = decode: propagates no no
112
Chapter 7. Operators
113
Example
In the following example, the encode operator compresses a data set using the UNIX gzip utility. By default, gzip takes its input from stdin. You specify the -c switch to configure the operator to write its results to stdout as required by the operator: Here is the osh code for this example:
$ osh " ... op1 | encode -command gzip > encodedDS.ds"
The following example decodes the previously compressed data set so that it may be used by other WebSphere DataStage operators. To do so, you use an instance of the encode operator with a mode of decode. In a converse operation to the encoding, you specify the same operator, gzip, with the -cd option to decode its input. Here is the osh command for this example:
$ osh "encode -decode -command gzip -d < inDS.ds | op2 ..."
In this example, the command line uses the -d switch to specify the decompress mode of gzip.
Filter operator
The filter operator transfers the input records in which one or more fields meet the requirements you specify. If you request a reject data set, the filter operator transfers records that do not meet the requirements to the reject data set.
inRec:*;
filter
114
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator Combinable operator Value 1 1 or more, and, optionally, a reject data set inRec:*; outRec:*; inRec -> outRec without record modification parallel by default, or sequential any (parallel mode) any (sequential mode) propagated no yes
Chapter 7. Operators
115
Option -collation_sequence
Use -collation_sequence locale | collation_file_pathname | OFF This option determines how your string data is sorted. You can: Specify a predefined IBM ICU locale Write your own collation sequence using ICU syntax, and supply its collation_file_pathname Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence. By default, WebSphere DataStage sorts strings using byte-wise comparisons. For more information reference this IBM ICU site: http://oss.software.ibm.com/icu/userguide/ Collate_Intro.html
-nulls
-nulls first | last By default, nulls are evaluated first, before other values. To override this default, specify -nulls last.
-reject
-reject By default, records that do not meet specified requirements are dropped. Specify this option to override the default. If you do, attach a reject output data set to the operator.
-target
-target dsNum An optional sub-property of where. Use it to specify the target data set for a where clause. Multiple -where clauses can direct records to the same output data set. If a target data set is not specified for a particular -where clause, the output data set for that clause is implied by the order of all -where properties that do not have the -target sub-property. For example: Property -where -where -where -where -where "field1 "field2 "field3 "field4 "field5 < 4" like bb" like aa" -target > 10" -target like c.*" Data set 0 1 2 0 2
116
The output summary per criterion is included in the summary messages generated by WebSphere DataStage as custom information. It is identified with:
name="CriterionSummary"
The XML tags, criterion, case and where, are used by the filter operator when generating business logic and criterion summary custom information. These tags are used in the example information below.
Expressions
The behavior of the filter operator is governed by expressions that you set. You can use the following elements to specify the expressions: v Fields of the input data set v Requirements involving the contents of the fields v Optional constants to be used in comparisons v The Boolean operators AND and OR to combine requirements When a record meets the requirements, it is written unchanged to an output data set. Which of the output data sets it is written to is either implied by the order of your -where options or explicitly defined by means of the -target suboption. The filter operator supports standard SQL expressions, except when comparing strings.
Chapter 7. Operators
117
Regular expressions
The description of regular expressions in this section has been taken from this publication: Rouge Wave, Tools.h++.
118
Order of association
As in SQL, expressions are associated left to right. AND and OR have the same precedence. You may group fields and expressions in parentheses to affect the order of evaluation.
String comparison
WebSphere DataStage operators sort string values according to these general rules: v Characters are sorted in lexicographic order v Strings are evaluated by their ASCII value v Sorting is case sensitive, that is, uppercase letters appear before lowercase letter in sorted data v Null characters appear before non-null characters in a sorted data set, unless you specify the nulls last option v Byte-for-byte comparison is performed
Chapter 7. Operators
119
OSH syntax
osh " filter -where age >= 21 and income > 50000.00 -where income > 50000.00 -where age >= 21 -target 1 -where age >= 21 < [record@filter_example.schema] all12.txt 0>| AdultAndRich.txt 1>| AdultOrRich.txt 2>| Adult.txt "
120
The first -where option directs all records that have age >= 21 and income > 50000.00 to output 0, which is then directed to the file AdultAndRich.txt. The second -where option directs all records that have income > 50000.00 to output 1, which is then directed to AdultOrRich.txt. The third -where option directs all records that have age >= 21 also to output 1 (because of the expression -target 1) which is then directed to AdultOrRich.txt. The result of the second and third -where options is that records that satisfy either of the two conditions income > 50000.00 or age >= 21 are sent to output 1. A record that satisfies multiple -where options that are directed to the same output are only written to output once, so the effect of these two options is exactly the same as:
-where income > 50000.00 or age >= 21
The fourth -where option causes all records satisfying the condition age >= 21 to be sent to the output 2, because the last -where option without a -target suboption directs records to output 1. This output is then sent to Adult.txt.
Input data
As a test case, the following twelve data records exist in an input file all12.txt.
John Parker M 24 0087228.46 MA Susan Calvin F 24 0091312.42 IL William Mandella M 67 0040676.94 CA Ann Claybourne F 29 0061774.32 FL Frank Chalmers M 19 0004881.94 NY Jane Studdock F 24 0075990.80 TX Seymour Glass M 18 0051531.56 NJ Laura Engels F 57 0015280.31 KY John Boone M 16 0042729.03 CO Jennifer Sarandon F 58 0081319.09 ND William Tell M 73 0021008.45 SD Ann Dillard F 21 0004552.65 MI Jennifer Sarandon F 58 0081319.09 ND
Outputs
The following output comes from running WebSphere DataStage. Because of parallelism, the order of the records may be different for your installation. If order matters, you can apply the psort or tsort operator to the output of the filter operator. After the WebSphere DataStage job is run, the file AdultAndRich.txt contains:
John Parker M 24 0087228.46 MA Susan Calvin F 24 0091312.42 IL Ann Claybourne F 29 0061774.32 FL Jane Studdock F 24 0075990.80 TX Jennifer Sarandon F 58 0081319.09 ND
After the WebSphere DataStage job is run, the file AdultOrRich.txt contains:
John Parker M 24 0087228.46 MA Susan Calvin F 24 0091312.42 IL William Mandella M 67 0040676.94 CA Ann Claybourne F 29 0061774.32 FL Jane Studdock F 24 0075990.80 TX Seymour Glass M 18 0051531.56 NJ Laura Engels F 57 0015280.31 KY Jennifer Sarandon F 58 0081319.09 ND William Tell M 73 0021008.45 SD Ann Dillard F 21 0004552.65 MI
Chapter 7. Operators
121
After the WebSphere DataStage job is run, the file Adult.txt contains:
John Parker M 24 0087228.46 MA Susan Calvin F 24 0091312.42 IL William Mandella M 67 0040676.94 CA Ann Claybourne F 29 0061774.32 FL Jane Studdock F 24 0075990.80 TX Laura Engels F 57 0015280.31 KY Jennifer Sarandon F 58 0081319.09 ND William Tell M 73 0021008.45 SD Ann Dillard F 21 0004552.65 MI
Funnel operators
The funnel operators copy multiple input data sets to a single output data set. This operation is useful for combining separate data sets into a single large data set. WebSphere DataStage provides two funnel operators: v The funnel operator combines the records of the input data in no guaranteed order. v The sortfunnel operator combines the input records in the order defined by the value(s) of one or more key fields and the order of the output records is determined by these sorting keys. By default, WebSphere DataStage inserts partition and sort components to meet the partitioning and sorting needs of the sortfunnel operator and other operators.
funnel or sortfunnel
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Input partitioning style Output partitioning style Value N (set by user) 1 inRec:* outRec:* inRec -> outRec without record modification parallel (default) or sequential sortfunnel operator: keys in same partition sortfunnel operator: distributed keys
122
Value funnel operator: round robin (parallel mode) sortfunnel operator: hash
Funnel operator
input data sets
funnel or sortfunnel
outRec:*;
Syntax
The funnel operator has no options. Its syntax is simply:
funnel
Note: We do not guarantee the output order of records transferred by means of the funnel operator. Use the sortfunnel operator to guarantee transfer order.
123
A parallel sortfunnel operator uses the default partitioning method local keys. See The Partitioning Library for more information on partitioning styles.
data set 0
data set 1
data set 2
Jane
Smith 42
Paul
Smith 34
Mary
Davis 42
current record
If the data set shown above is sortfunneled on the primary key, LastName, and then on the secondary
primary key
Mary
Davis
42
Paul
Smith
34
Jane
Smith
42
secondary key
124
Use -collation_sequence locale |collation_file_pathname | OFF This option determines how your string data is sorted. You can: v Specify a predefined IBM ICU locale v Write your own collation sequence using ICU syntax, and supply its collation_file_pathname v Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence. By default, WebSphere DataStage sorts strings using byte-wise comparisons. For more information, reference this IBM ICU site: http://oss.software.ibm.com/icu/userguide/ Collate_Intro.htm
Chapter 7. Operators
125
Option -key
Use -key field [-cs | -ci] [-asc | -desc] [-nulls first | last] [-ebcdic] [-param params] Specifies a key field of the sorting operation. The first -key defines the primary key field of the sort; lower-priority key fields are supplied on subsequent -key specifications. You must define a single primary key to the sortfunnel operator. You can define as many secondary keys as are required by your job. For each key, select the option and supply the field name. Each record field can be used only once as a key. Therefore, the total number of primary and secondary keys must be less than or equal to the total number of fields in the record. -cs | -ci are optional arguments for specifying case-sensitive or case-insensitive sorting. By default, the operator uses a case-sensitive algorithm for sorting, that is, uppercase strings appear before lowercase strings in the sorted data set. Specify -ci to override this default and perform case-insensitive sorting of string fields. -asc | -desc are optional arguments for specifying ascending or descending sorting By default, the operator uses ascending sorting order, that is, smaller values appear before larger values in the sorted data set. Specify -desc to sort in descending sorting order instead, so that larger values appear before smaller values in the sorted data set. -nulls first | last By default fields containing null values appear first in the sorted data set. To override this default so that fields containing null values appear last in the sorted data set, specify nulls last. -ebcdic By default data is represented in the ASCII character set. To represent data in the EBCDIC character set, specify this option. The -param suboption allows you to specify extra parameters for a field. Specify parameters using property=value pairs separated by commas.
In this osh example, the sortfunnel operator combines two input data sets into one sorted output data set:
$ osh "sortfunnel -key Lastname -key Age < out0.v < out1.v > combined.ds
Generator operator
Often during the development of a WebSphere DataStage job, you will want to test the job using valid data. However, you may not have any data available to run the test, your data may be too large to execute the test in a timely manner, or you may not have data with the characteristics required to test the job.
126
The WebSphere DataStage generator operator lets you create a data set with the record layout that you pass to the operator. In addition, you can control the number of records in the data set, as well as the value of all record fields. You can then use this generated data set while developing, debugging, and testing your WebSphere DataStage job. To generate a data set, you pass to the operator a schema defining the field layout of the data set and any information used to control generated field values. This chapter describes how to use the generator operator, including information on the schema options you use to control the generated field values.
inRec:*;
generator
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Value 0 or 1 1 inRec:* supplied_schema; outRec:* inRec -> outRec without record modification sequential (default) or parallel any (parallel mode) any (sequential mode) propagated
You must use either the -schema or the -schemafile argument to specify a schema to the operator. Terms in italic typeface are option strings you supply. When your option string contains a space or a tab character, you must enclose it in single quotes.
Chapter 7. Operators
127
Table 3. generator Operator Options Option -schema Use -schema schema Specifies the schema for the generated data set. You must specify either -schema or -schemafile to the operator. If you supply an input data set to the operator, new fields with the specified schema are prepended to the beginning of each record. -schemafile -schemafile filename Specifies the name of a file containing the schema for the generated data set. You must specify either -schema or -schemafile to the operator. If you supply an input data set to the operator, new fields with the supplied schema are prepended to the beginning of each record. -records -records num_recs Specifies the number of records to generate. By default the operator generates an output data set with 10 records (in sequential mode) or 10 records per partition (in parallel mode). If you supply an input data set to the operator, any specification for -records is ignored. In this case, the operator generates one record for each record in the input data set. -resetForEachEOW -resetForEachEOW Specifies that the cycle should be repeated for each EOW.
You pass to the generator operator a schema that defines the field layout of the data set. By default, the generator operator initializes record fields using a well-defined generation algorithm. For example, an 8-bit unsigned integer field in the first record of a generated data set is set to 0. The field value in each subsequently generated record is incremented by 1 until the generated field value is 255. The field value then wraps back to 0. However, you can also include information in the schema passed to the operator to control the field values of the generated data set. See Numeric Fields for more information on these options.
128
By default, the operator executes sequentially to generate a data set with a single partition containing 10 records. However, you can configure the operator to generate any number of records. If you configure the operator to execute in parallel, you control the number of records generated in each partition of the output data set. You can also pass an input data set to the operator. In this case, the operator prepends the generated record fields to the beginning of each record of the input data set to create the output.
This figure shows the data flow diagram for this example:
generator
newDS.ds
To use the generator operator, first configure the schema:
Chapter 7. Operators
129
This example defines an environment variable ($rec_schema) to hold the schema passed to the operator. Alternatively you can specify the name of a file containing the schema, as shown below:
$ osh "generator -schemafile s_file.txt -records 1000 > newDS.ds"
Note that the keyword [par] has been added to the example to configure the generator operator to execute in parallel.
The figure below shows the output record of the generator operator:
Generated fields
For example, you can enumerate the records of a data set by appending an int32 field that cycles from 0 upward. The generated fields are prepended to the beginning of each record. This means conflicts caused by duplicate field names in the generator schema and the input data set result in the field from the input data set being dropped. Note that WebSphere DataStage issues a warning message to inform you of the naming conflict. You can use the modify operator to rename the fields in the input data set to avoid the name collision. See Transform Operator for more information.
In the absence of any other specifications in the schema, the operator assigns default values to the fields of the output data set. However, you can also include information in the schema to control the values of the generated fields. This section describes the default values generated for all WebSphere DataStage data types and the use of options in the schema to control field values.
Note that you include the generator options as part of the schema definition for a field. The options must be included within braces and before the trailing semicolon. Use commas to separate options for fields that accept multiple options. This table lists all options for the different WebSphere DataStage data types. Detailed information on these options follows the table.
Data Type numeric (also decimal, date, time, timestamp) date Generator Options for the Schema cycle = {init = init_val, incr = incr_val, limit = limit_val} random = {limit = limit_val, seed = seed_val, signed} epoch = date invalids = percentage function = rundate decimal zeros = percentage invalids = percentage
Chapter 7. Operators
131
Generator Options for the Schema no options available cycle = {value = string_1, value = string_2, ... } alphabet = alpha_numeric_string
ustring
time
timestamp
nullable fields
Numeric fields
By default, the value of an integer or floating point field in the first record created by the operator is 0 (integer) or 0.0 (float). The field in each successive record generated by the operator is incremented by 1 (integer) or 1.0 (float). The generator operator supports the use of the cycle and random options that you can use with integer and floating point fields (as well as with all other fields except raw and string). The cycle option generates a repeating pattern of values for a field. The random option generates random values for a field. These options are mutually exclusive; that is, you can only use one option with a field. v cycle generates a repeating pattern of values for a field. Shown below is the syntax for this option:
cycle = {init = init_val, incr = limit = limit_val} incr_val ,
where: init_val is the initial field value (value of the first output record). The default value is 0. incr_val is the increment value added to produce the field value in the next output record. The default value is 1 (integer) or 1.0 (float). limit_val is the maximum field value. When the generated field value is greater than limit_val, it wraps back to init_val. The default value of limit_val is the maximum allowable value for the fields data type. You can specify the keyword part or partcount for any of these three option values. Specifying part uses the partition number of the operator on each processing node for the option value. The partition number is 0 on the first processing node, 1 on the next, etc. Specifying partcount uses the number of partitions executing the operator for the option value. For example, if the operator executes on four processing nodes, partcount corresponds to a value of 4. v random generates random values for a field. Shown below is the syntax for this option (all arguments to random are optional):
random = {limit = limit_val, seed = seed_val, signed}
where: limit_val is the maximum generated field value. The default value of limit_val is the maximum allowable value for the fields data type.
132
seed_val is the seed value for the random number generator used by the operator for the field. You do not have to specify seed_val. By default, the operator uses the same seed value for all fields containing the random option. signed specifies that signed values are generated for the field (values between -limit_val and +limit_val.) Otherwise, the operator creates values between 0 and +limit_val. You can also specify the keyword part for seed_val and partcount for limit_val. For example, the following schema generates a repeating cycle of values for the AccountType field and a random number for balance:
record ( AccountType:int8 {cycle={init=0, incr=1, limit=24}}; Balance:dfloat {random={limit=100000, seed=34455}}; )
Date fields
By default, a date field in the first record created by the operator is set to January 1, 1960. The field in each successive record generated by the operator is incremented by one day. You can use the cycle and random options for date fields as shown above. When using these options, you specify the option values as a number of days. For example, to set the increment value for a date field to seven days, you use the following syntax:
record ( transDate:date {cycle={incr=7}}; transAmount:dfloat {random={limit=100000,seed=34455}}; )
In addition, you can use the following options: epoch, invalids, and functions. The epoch option sets the earliest generated date value for a field. You can use this option with any other date options. The syntax of epoch is:
epoch = date
where date sets the earliest generated date for the field. The date must be in yyyy-mm-dd format and leading zeros must be supplied for all portions of the date. If an epoch is not specified, the operator uses 1960-01-01. For example, the following schema sets the initial field value of transDate to January 1, 1998:
record ( transDate:date {epoch=1998-01-01}; transAmount:dfloat {random={limit=100000,seed=34455}}; )
You can also specify the invalids option for a date field. This option specifies the percentage of generated fields containing invalid dates:
invalids = percentage
where percentage is a value between 0.0 and 100.0. WebSphere DataStage operators that process date fields can detect an invalid date during processing. The following example causes approximately 10% of transDate fields to be invalid:
record ( transDate:date {epoch=1998-01-01, invalids=10.0}; transAmount:dfloat {random={limit=100000, seed=34455}}; )
You can use the function option to set date fields to the current date:
Chapter 7. Operators
133
function = rundate
There must be no other options specified to a field using function. The following schema causes transDate to have the current date in all generated records:
record ( transDate:date {function=rundate}; transAmount:dfloat {random={limit=100000, seed=34455}}; )
Decimal fields
By default, a decimal field in the first record created by the operator is set to 0. The field in each successive record generated by the operator is incremented by 1. The maximum value of the decimal is determined by the decimals scale and precision. When the maximum value is reached, the decimal field wraps back to 0. You can use the cycle and random options with decimal fields. See Numeric Fields for information on these options. In addition, you can use the zeros and invalids options with decimal fields. These options are described below. The zeros option specifies the percentage of generated decimal fields where all bytes of the decimal are set to binary zero (0x00). Many operations performed on a decimal can detect this condition and either fail or return a flag signifying an invalid decimal value. The syntax for the zeros options is:
zeros = percentage
where percentage is a value between 0.0 and 100.0. The invalids options specifies the percentage of generated decimal fields containing and invalid representation of 0xFF in all bytes of the field. Any operation performed on an invalid decimal detects this condition and either fails or returns a flag signifying an invalid decimal value. The syntax for invalids is:
invalids = percentage
where percentage is a value between 0.0 and 100.0. If you specify both zeros and invalids, the percentage for invalids is applied to the fields that are not first made zero. For example, if you specify zeros=50 and invalids=50, the operator generates approximately 50% of all values to be all zeros and only 25% (50% of the remainder) to be invalid.
Raw fields
You can use the generator operator to create fixed-length raw fields or raw fields with a specified maximum length; you cannot use the operator to generate variable-length raw fields. If the field has a maximum specified length, the length of the string is a random number between 1 and the maximum length. Maximum-length raw fields are variable-length fields with a maximum length defined by the max parameter in the form:
max_r:raw [max=10];
By default, all bytes of a raw field in the first record created by the operator are set to 0x00. The bytes of each successive record generated by the operator are incremented by 1 until a maximum value of 0xFF is reached. The operator then wraps byte values to 0x00 and repeats the cycle. You cannot specify any options to raw fields.
134
String fields
You can use the generator operator to create fixed-length string and ustring fields or string and ustring fields with a specified maximum length; you cannot use the operator to generate variable-length string fields. If the field has a maximum specified length, the length of the string is a random number between 0 and the maximum length. Note that maximum-length string fields are variable-length fields with a maximum length defined by the max parameter in the form:
max_s: string [max=10];
In this example, the field max_s is variable length up to 10 bytes long. By default, the generator operator initializes all bytes of a string field to the same alphanumeric character. When generating a string field, the operators uses the following characters, in the following order:
abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ
After the last character, capital Z, values wrap back to lowercase a and the cycle repeats. Note: The alphabet property for ustring values accepts Unicode characters. You can use the alphabet property to define your own list of alphanumeric characters used for generated string fields:
alphabet = alpha_numeric_string
This option sets all characters in the field to successive characters in the alpha_numeric_string. For example, this field specification:
s: string[3] {alphabet=abc};
Note: The cycle option for usting values accepts Unicode characters. The cycle option specifies the list of string values assigned to generated string field:
cycle = { value = string_1, value = string_2, ... }
The operator assigns string_1 to the string field in the first generated record, string_2 to the field in the second generated record, etc. In addition: v If you specify only a single value, all string fields are set to that value.
Chapter 7. Operators
135
v If the generated string field is fixed length, the value string is truncated or padded with the default pad character 0x00 to the fixed length of the string. v If the string field contains a maximum length setting, the length of the string field is set to the length of the value string. If the length of the value string is longer than the maximum string length, the value string is truncated to the maximum length.
Time fields
By default, a time field in the first record created by the operator is set to 00:00:00 (midnight). The field in each successive record generated by the operator is incremented by one second. After reaching a time of 23:59:59, time fields wrap back to 00:00:00. You can use the cycle and random options with time fields. See Numeric Fields for information on these options. When using these options, you specify the options values in numbers of seconds. For example, to set the value for a time field to a random value between midnight and noon, you use the following syntax:
record ( transTime:time {random={limit=43200, seed=83344}}; )
For a time field, midnight corresponds to an initial value of 0 and noon corresponds to 43,200 seconds (12 hours * 60 minutes * 60 seconds). In addition, you can use the scale and invalids options with time fields. The scale option allows you to specify a multiplier to the increment value for time. The syntax of this options is:
scale = factor
The increment value is multiplied by factor before being added to the field. For example, the following schema generates two time fields:
record ( timeMinutes:time {scale=60}; timeSeconds:time; )
In this example, the first field increments by 60 seconds per record (one minute), and the second field increments by seconds. You use the invalids option to specify the percentage of invalid time fields generated:
invalids = percentage
where percentage is a value between 0.0 and 100.0. The following schema generates two time fields with different percentages of invalid values:
record ( timeMinutes:time {scale=60, invalids=10}; timeSeconds:time {invalids=15}; )
Timestamp fields
A timestamp field consists of both a time and date portion. Timestamp fields support all valid options for both date and time fields. See Date Fields or Time Fields for more information.
136
By default, a timestamp field in the first record created by the operator is set to 00:00:00 (midnight) on January 1, 1960. The time portion of the timestamp is incremented by one second for each successive record. After reaching a time of 23:59:59, the time portion wraps back to 00:00:00 and the date portion increments by one day.
Null fields
By default, schema fields are not nullable. Specifying a field as nullable allows you to use the nulls and nullseed options within the schema passed to the generator operator. Note: If you specify these options fo a non-nullable field, the operator issues a warning and the field is set to its default value. The nulls option specifies the percentage of generated fields that are set to null:
nulls = percentage
where percentage is a value between 0.0 and 100.0. The following example specifies that approximately 15% of all generated records contain a null for field a:
record ( a:nullable int32 {random={limit=100000, seed=34455}, nulls=15.0}; b:int16; )
The nullseed options sets the seed for the random number generator used to decide whether a given field will be null.
nullseed = seed
where seed specifies the seed value and must be an integer larger than 0. In some cases, you may have multiple fields in a schema that support nulls. You can set all nullable fields in a record to null by giving them the same nulls and nullseed values. For example, the following schema defines two fields as nullable:
record ( a:nullable int32 {nulls=10.0, nullseed=5663}; b:int16; c:nullable sfloat {nulls=10.0, nullseed=5663}; d:string[10]; e:dfloat; )
Since both fields a and c have the same settings for nulls and nullseed, whenever one field in a record is null the other is null as well.
Head operator
The head operator selects the first n records from each partition of an input data set and copies the selected records to an output data set. By default, n is 10 records. However, you can determine the following by means of options: v The number of records to copy v The partition from which the records are copied v The location of the records to copy v The number of records to skip before the copying operation begins.
Chapter 7. Operators
137
This control is helpful in testing and debugging jobs with large data sets. For example, the -part option lets you see data from a single partition to ascertain if the data is being partitioned as you want. The -skip option lets you access a portion of a data set. The tail operator performs a similar operation, copying the last n records from each partition. See Tail Operator .
inRec:*;
head
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Value 1 1 inRec:* outRec:* inRec -> outRec without record modification
138
-part
-part partition_number Copy records only from the indicated partition, partition_number. By default, the operator copies records from all partitions. You can specify -part multiple times to specify multiple partition numbers. Each time you do, specify the option followed by the number of the partition.
-period
-period P Copy every Pth record in a partition, where P is the period. You can start the copy operation after records have been skipped (as defined by -skip). P must equal or be greater than 1. The default value of P is 1.
-skip
-skip recs Ignore the first recs records of each partition of the input data set, where recs is the number of records to skip. The default skip count is 0.
139
For example, if in.ds is a data set of one megabyte, with 2500 K records, out0.ds is a data set of15.6 kilobytes with 4K records.
Lookup operator
With the lookup operator, you can create and use lookup tables to modify your input data set. For example, you could map a field that should contain a two letter U. S. state postal code to the name of the state, adding a FullStateName field to the output schema. The operator performs in two modes: lookup mode and create-only mode: v In lookup mode, the operator takes as input a single source data set, one or more lookup tables represented as WebSphere DataStage data sets, and one or more file sets. A file set is a lookup table that contains key-field information. There most be at least one lookup table or file set. For each input record of the source data set, the operator performs a table lookup on each of the input lookup tables. The table lookup is based on the values of a set of lookup key fields, one set for each table. A source record and lookup record correspond when all of the specified lookup key fields have matching values. Each record of the output data set contains all of the fields from a source record. Concatenated to the end of the output records are the fields from all the corresponding lookup records where corresponding source and lookup records have the same value for the lookup key fields. The reject data set is an optional second output of the operator. This data set contains source records that do not have a corresponding entry in every input lookup table. v In create-only mode, you use the -createOnly option to create lookup tables without doing the lookup processing step. This allows you to make and save lookup tables that you expect to need at a later time, making for faster start-up of subsequent lookup operations. The lookup operator is similar in function to the merge operator and the join operators. To understand the similarities and differences see Comparison with Other Operators .
lookup
140
Lookup mode
look ups
source.ds
fileset0.ds
filesetn.ds
table0.ds
tableN.ds
lookup
rejectRec:*;
output.ds
reject.ds
fileset0.ds
filesetn.ds
Properties
Property Number of input data sets Number of output data sets Input interface schema input data set: lookup data sets: Output interface schema output data set: reject data sets: Transfer behavior source to output: lookup to output: source to reject: table to file set Normal mode T+1 1 or 2 (output and optional reject) key0:data_type; ... keyN:data_type; inRec:*; key0:data_type; ... keyM:data_type; tableRec:*; outRec:*; with lookup fields missing from the input data set concatenated rejectRec;* inRec -> outRec without record modification tableRecN -> tableRecN, minus lookup keys and other duplicate fields inRec -> rejectRec without record modification (optional) key-field information is added to the table Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator any (parallel mode); the default for table inputs is entire any (sequential mode) propagated yes any (default is entire) any n/a yes
Chapter 7. Operators
141
or
lookup [-fileset fileset_descriptor] [-collation_sequence locale |collation_file_pathname | OFF] [-table key_specifications [-allow_dups] -save fileset_descriptor [-diskpool pool]...] [-ifNotFound continue | drop | fail | reject]
where a fileset, or a table, or both, must be specified, and key_specifications is a list of one or more strings of this form:
-key field [-cs | -ci] Option -collation_sequence Use -collation_sequence locale | collation_file_pathname | OFF This option determines how your string data is sorted. You can: v Specify a predefined IBM ICU locale v Write your own collation sequence using ICU syntax, and supply its collation_file_pathname v Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence. By default, WebSphere DataStage sorts strings using byte-wise comparisons. http://oss.software.ibm.com/icu/userguide/ Collate_Intro.html -createOnly -createOnly Specifies the creation of one or more lookup tables; no lookup processing is to be done.
142
Option -fileset
Use [-fileset fileset_descriptor ...] Specify the name of a fileset containing one or more lookup tables to be matched. These are tables that have been created and saved by an earlier execution of the lookup operator using the -createOnly option. In lookup mode, you must specify either the -fileset option, or a table specification, or both, in order to designate the lookup table(s) to be matched against. There can be zero or more occurrences of the -fileset option. It cannot be specified in create-only mode. Warning: The fileset already contains key specifications. When you follow -fileset fileset_descriptor by key_specifications, the keys specified do not apply to the fileset; rather, they apply to the first lookup table. For example, lookup -fileset file -key field, is the same as: lookup -fileset file1 -table -key field
-ifNotFound
-ifNotFound continue | drop | fail | reject Specifies the operator action when a record of an input data set does not have a corresponding record in every input lookup table. The default action of the operator is to fail and terminate the step. continue tells the operator to continue execution when a record of an input data set does not have a corresponding record in every input lookup table. The input record is transferred to the output data set along with the corresponding records from the lookup tables that matched. The fields in the output record corresponding to the lookup table(s) with no corresponding record are set to their default value or null if the field supports nulls. drop tells the operator to drop the input record (refrain from creating an output record). fail sets the operator to abort. This is the default. reject tells the operator to copy the input record to the reject data set. In this case, a reject output data set must be specified.
Chapter 7. Operators
143
Option -table
Use -table -key field [-ci | -cs] [-param parameters] [-key field [-ci | cs] [-param parameters] ...] [-allow_dups] -save fileset_descriptor [-diskpool pool]] ...] Specifies the beginning of a list of key fields and other specifications for a lookup table. The first occurrence of -table marks the beginning of the key field list for lookup table1; the next occurrence of -table marks the beginning of the key fields for lookup table2, etc. For example: lookup -table -key field -table -key field The -key option specifies the name of a lookup key field. The -key option must be repeated if there are multiple key fields. You must specify at least one key for each table. You cannot use a vector, subrecord, or tagged aggregate field as a lookup key. The -ci suboption specifies that the string comparison of lookup key values is to be case insensitive; the -cs option specifies case-sensitive comparison, which is the default. The -params suboption provides extra parameters for the lookup key. Specify property=value pairs, without curly braces. In create-only mode, the -allow_dups option causes the operator to save multiple copies of duplicate records in the lookup table without issuing a warning. Two lookup records are duplicates when all lookup key fields have the same value in the two records. If you do not specify this option, WebSphere DataStage issues a warning message when it encounters duplicate records and discards all but the first of the matching records. In normal lookup mode, only one lookup table (specified by either -table or -fileset) can have been created with -allow_dups set. The -save option lets you specify the name of a fileset to write this lookup table to; if -save is omitted, tables are written as scratch files and deleted at the end of the lookup. In create-only mode, -save is, of course, required. The -diskpool option lets you specify a disk pool in which to create lookup tables. By default, the operator looks first for a lookup disk pool, then uses the default pool (). Use this option to specify a different disk pool to use.
144
rather than having a private copy of the table for each process. This reduces memory consumption to that of a single sequential lookup process. This is why partitioning the data, which in a non-shared-memory environment saves memory by creating smaller tables, also has the effect of disabling this memory sharing, so that there is no benefit to partitioning lookup tables on an SMP or cluster.
Partitioning
Normally (and by default), lookup tables are partitioned using the entire partitioning method so that each processing node receives a complete copy of the lookup table. You can partition lookup tables using another partitioning method, such as hash, as long as you ensure that all records with the same lookup keys are partitioned identically. Otherwise, source records may be directed to a partition that doesnt have the proper table entry. For example, if you are doing a lookup on keys a, b, and c, having both the source data set and the lookup table hash partitioned on the same keys would permit the lookup tables to be broken up rather than copied in their entirety to each partition. This explicit partitioning disables memory sharing, but the lookup operation consumes less memory, since the entire table is not duplicated. Note, though, that on a single SMP, hash partitioning does not actually save memory. On MPPs, or where shared memory can be used only in a limited way, or not at all, it can be beneficial.
Create-only mode
In its normal mode of operation, the lookup operator takes in a source data set and one or more data sets from which the lookup tables are built. The lookup tables are actually represented as file sets, which can be saved if you wish but which are normally deleted as soon as the lookup operation is finished. There is also a mode, selected by the -createOnly option, in which there is no source data set; only the data sets from which the lookup tables are to be built are used as input. The resulting file sets, containing lookup tables, are saved to persistent storage. This create-only mode of operation allows you to build lookup tables when it is convenient, and use them for doing lookups at a later time. In addition, initialization time for the lookup processing phase is considerably shorter when lookup tables already exist. For example, suppose you have data sets data1.ds and data2.ds and you want to create persistent lookup tables from them using the name and ID fields as lookup keys in one table and the name and accountType fields in the other. For this use of the lookup operator, you specify the -createOnly option and two -table options. In this case, two suboptions for the -table options are specified: -key and -save. In osh, use the following command:
$ osh " lookup -createOnly -table -key name -key ID -save fs1.fs -table -key name -key accountType -save fs2.fs < data1.ds < data2.ds"
Chapter 7. Operators
145
source record
key field 1 key field 2 key field 1
lookup record
key field 2
name ID
John 27 other_source_fields
name
John 27
ID
payload_fields
name
John
ID
27 other_source_fields other payload fields not including fields already in the source record
output record
This figure shows the source and lookup record and the resultant output record. A source record and lookup record are matched if they have the same values for the key field(s). In this example, both records have John as the name and 27 as the ID number. In this example, the lookup keys are the first fields in the record. You can use any field in the record as a lookup key. Note that fields in a lookup table that match fields in the source record are dropped. That is, the output record contains all of the fields from the source record plus any fields from the lookup record that were not in the source record. Whenever any field in the lookup record has the same name as a field in the source record, the data comes from the source record and the lookup record field is ignored. Here is the command for this example:
$ osh "lookup -table -key Name -key ID < inSrc.ds < inLU1.ds > outDS.ds"
146
source record
key field 1 key field 2
lookup record 1
key field 1 key field 2
lookup record 2
key field 1 key field 2
name ID
John 27 other_source_fields
name ID
John 27
name ID
payload_fields_1 John 27 payload_fields_2
name ID
John payload_fields_1 (not 27 other_source_fields including fields already in the source record) payload_fields_2 (not including fields already in the source record or payload1/payload2 collision)
output record
The osh command for this example is:
$ osh " lookup -table -key name -key ID -table -key name -key ID < inSrc.ds < inLU1.ds < inLU2.ds > outDS.ds"
Note that in this example you specify the same key fields for both lookup tables. Alternatively, you can specify a different set of lookup keys for each lookup table. For example, you could use name and ID for the first lookup table and the fields accountType and minBalance (not shown in the figure) for the second lookup table. Each of the resulting output records would contain those four fields, where the values matched appropriately, and the remaining fields from each of the three input records. Here is the osh command for this example:
$ osh " lookup -table -key name -key ID -table -key accountType -key minBalance < inSrc.ds < inLU1.ds < inLU2.ds > outDS.ds"
Chapter 7. Operators
147
step
lookup key
(entire)
lookup
OutDS.ds
Since the interest rate is not represented in the source data set record schema, the interestRate field from the lookup record has been concatenated to the source record. Here is the osh code for this example:
$ osh " lookup -table -key accountType < customers.ds < interest.ds > outDS.ds"
To make the lookup tables interestRate field the one that is retained in the output, use a modify operator to drop interestRate from the source record. The interestRate field from the lookup table record is propagated to the output data set, because it is now the only field of that name. The following figure shows how to use a modify operator to drop the interestRate field:
source
lookup
modify
(entire)
lookup
step
output
The osh command for this example is:
$ osh " modify -spec drop interestRate; < customer.ds | lookup -table -key accountType < interest.ds > outDS.ds"
Note that this is unrelated to using the -allow_dups option on a table, which deals with the case where two records in a lookup table are identical in all the key fields.
Merge operator
The merge operator combines a sorted master data set with one or more sorted update data sets. The fields from the records in the master and update data sets are merged so that the output record contains all the fields from the master record plus any additional fields from matching update record. A master record and an update record are merged only if both of them have the same values for the merge key field(s) that you specify. Merge key fields are one or more fields that exist in both the master and update records. By default, WebSphere DataStage inserts partition and sort components to meet the partitioning and sorting needs of the merge operator and other operators. As part of preprocessing your data for the merge operator, you must remove duplicate records from the master data set. If you have more than one update data set, you must remove duplicate records from the update data sets as well. This section describes how to use the merge operator. Included in this chapter are examples using the remdup operator to preprocess your data. The merge operator is similar in function to the lookup operator and the join operators. To understand the similarities and differences see Comparison with Other Operators .
Chapter 7. Operators
149
updaten
merge
rejectRec1:*; rejectRec1:*;
merged output
reject1
rejectn
Properties
Property Number of input data sets Number of output data sets Input interface schema master data set: update data sets: Output interface schema output data set: reject data sets: Transfer behavior master to output: update to output: update to reject: Input paritioning style Output partitioning style Execution mode Preserve-partitioning flag in output data set masterRec -> masterRec without record modification updateRecn-> outputRecrejectRecn -> updateRecn ->rejectRecn without record modification (optional) keys in same partition distributed keys parallel (default) or sequential propagated Value 1 master; 1-n update 1 output; 1-n reject (optional) mKey0:data_type; ... mKeyk:data_type; masterRec:*; mKey0:data_type; ... mKeyk:data_type; updateRecr:*; rejectRecr:*; masterRec:*; updateRec1:*; updateRec2:*; ... updateRecn:*; rejectRecn;*
150
Option -key
Use -key field [-ci | -cs] [-asc | -desc] [-ebcdic] [-nulls first | last] [param params] [-key field [-ci | -cs] [-asc | -desc] [-ebcdic] [-nulls first | last] [param params] ...] Specifies the name of a merge key field. The -key option may be repeated if there are multiple merge key fields. The -ci option specifies that the comparison of merge key values is case insensitive. The -cs option specifies a case-sensitive comparison, which is the default. -asc | -desc are optional arguments for specifying ascending or descending sorting By default, the operator uses ascending sorting order, that is, smaller values appear before larger values in the sorted data set. Specify -desc to sort in descending sorting order instead, so that larger values appear before smaller values in the sorted data set. -nulls first | last. By default fields containing null values appear first in the sorted data set. To override this default so that fields containing null values appear last in the sorted data set, specify nulls last. -ebcdic. By default data is represented in the ASCII character set. To represent data in the EBCDIC character set, specify this option. The -param suboption allows you to specify extra parameters for a field. Specify parameters using property=value pairs separated by commas.
-collation_sequence
-collation_sequence locale |collation_file_pathname | OFF This option determines how your string data is sorted. You can: v v v Specify a predefined IBM ICU locale Write your own collation sequence using ICU syntax, and supply its collation_file_pathname Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence.
By default, WebSphere DataStage sorts strings using byte-wise comparisons. For more information, reference this IBM ICU site: http://oss.software.ibm.com/icu/userguide/ Collate_Intro.htm -dropBadMasters -dropBadMasters Rejected masters are not output to the merged data set. -keepBadMasters -keepBadMasters Rejected masters are output to the merged data set. This is the default.
Chapter 7. Operators
151
Option -nowarnBadMasters
-nowarnBadUpdates
-warnBadMasters
-warnBadUpdates
Merging records
The merge operator combines a master and one or more update data sets into a single, merged data set based upon the values of a set of merge key fields. Each record of the output data set contains all of the fields from a master record. Concatenated to the end of the output records are any fields from the corresponding update records that are not already in the master record. Corresponding master and update records have the same value for the specified merge key fields. The action of the merge operator depends on whether you specify multiple update data sets or a single update data set. When merging a master data set with multiple update data sets, each update data set may contain only one record for each master record. When merging with a single update data set, the update data set may contain multiple records for a single master record. The following sections describe merging a master data set with a single update data set and with multiple update data sets.
master record
key field 1 key field 2 key field 1
update record
key field 2
name ID
John 27 other_update_fields
name ID
John 27 other_update_fields
name
John
ID
27 other_master_fields other_update_fields not including fields already in the master record
output record
152
Parallel Job Advanced Developer Guide
The figure shows the master and update records and the resultant merged record. A master record and an update record are merged only if they have the same values for the key field(s). In this example, both records have John as the Name and 27 as the ID value. Note that in this example the merge keys are the first fields in the record. You can use any field in the record as a merge key, regardless of its location. The schema of the master data set determines the data types of the merge key fields. The schemas of the update data sets may be dissimilar but they must contain all merge key fields (either directly or through adapters). The merged record contains all of the fields from the master record plus any fields from the update record which were not in the master record. Thus, if a field in the update record has the same name as a field in the master record, the data comes from the master record and the update field is ignored. The master data set of a merge must not contain duplicate records where duplicates are based on the merge keys. That is, no two master records can have the same values for all merge keys. For a merge using a single update data set, you can have multiple update records, as defined by the merge keys, for the same master record. In this case, you get one output record for each master/update record pair. In the figure above, if you had two update records with John as the Name and 27 as the value of ID, you would get two output records.
Chapter 7. Operators
153
master record
key field 1 key field 2
update record 1
key field 1 key field 2
update record 2
key field 1 key field 2
name ID
John 27 other_master_ fields
name ID
John 27 other_update_ fields1
name ID
John 27 other_update_ fields2
name ID
John other_update_fields1 (not 27 other_master_fields including fields already in the master record) other_update_fields2 (not including fields already in the master record or update_record1)
output record
Any fields in the first update record not in the master record are concatenated to the output record. Then, any fields in the second update record not in the master record or the first update record are concatenated to the output record. For each additional update data set, any fields not already in the output record are concatenated to the end of the output record.
master
update
remdup
remdup
optional
merge
step
output
154
This diagram shows the overall process as one step. Note that the remdup operator is required only if you have multiple update data sets. If you have only a single update data set, the data set may contain more than one update record for each master record. Another method is to save the output of the remdup operator to a data set and then pass that data set to the merge operator, as shown in the following figure:
master
update
remdup master
step
remdup update
step
optional
preprocessed master
preprocessed update
merge
step
output
This method has the disadvantage that you need the disk space to store the pre-processed master and update data sets and the merge must be in a separate step from the remove duplicates operator. However, the intermediate files can be checked for accuracy before merging them, or used by other processing steps that require records without duplicates.
Chapter 7. Operators
155
step merge
This data-flow diagram shows the record schema of the master and update data sets. The record schema of the master data set has five fields and all five of these appear in the record schema of the output data set. The update data set also has five fields, but only two of these (f and g) are copied to the output data set because the remaining fields (a, b, and c) already exist in the master data set. If the example above is extended to include a second update data set with a record schema containing the following fields: abdhi Then the fields in the merged output record are now: abcedfghi because the last two fields (h and i) occur only in the second update data set and not in the master or first update data set. The unique fields from each additional update data set are concatenated to the end of the merged output. If there is a third update data set with a schema that contains the fields: abdh it adds nothing to the merged output since none of the fields is unique. Thus if master and five update data sets are represented as: M U1 U2 U3 U4 U5 where M represents the master data set and Un represent update data set n, and if the records in all six data sets contain a field named b, the output record has a value for b taken from the master data set. If a field named e occurs in the U2, U3, and U5 update data sets, the value in the output comes from the U2 data set since it is the first one encountered.
156
Therefore, the record schema of the merged output record is the sequential concatenation of the master and update schema(s) with overlapping fields having values taken from the master data set or from the first update record containing the field. The values for the merge key fields are taken from the master record, but are identical values to those in the update record(s).
National.ds schema
customer:int16; month:string[3]; name;string[21]; balance;sfloat; salesman:string[8]; accountType:int8;
California.ds schema
customer:int16; month:string[3]; name;string[21]; calBalance:sfloat; status:string[8];
step merge
combined.ds schema
customer:int16; month:string[3]; name;string[21]; balance;sfloat; salesman:string[8]; accountType:int8; calBalance:sfloat; status:string[8];
Chapter 7. Operators
157
National.ds schema
customer:int16; month:string[3]; name;string[21]; balance;sfloat; salesman:string[8]; accountType:int8;
86111
JUN
Jones, Bob
345.98
Steve
12
California.ds schema
customer:int16; month:string[3]; name;string[21]; CalBalance;sfloat; status:string[8];
86111
JUN
Jones, Bob
637.04
Normal
158
master
NationalRaw.ds
update
CaliforniaRaw.ds
remdup
National.ds
remdup
California.ds
merge
step
output
For the remdup operators and for the merge operator you specify the same key two fields: v Option: key Value: Month v Option: key Value: Customer The steps for this example have been written separately so that you can check the output after each step. Because each step is separate, it is easier to understand the entire process. Later all of the steps are combined together into one step. The separate steps, shown as osh commands, are:
# $ # $ # $ Produce National.ds osh "remdup -key Month -key Customer < NationalRaw.ds > National.ds" Produce California.ds osh "remdup -key Month -key Customer < CaliforniaRaw.ds > California.ds" Perform the merge osh "merge -key Month -key Customer < National.ds < California.ds > Combined.ds"
This example takes NationalRaw.ds and CaliforniaRaw.ds and produces Combined.ds without creating the intermediate files. When combining these three steps into one, you use a named virtual data sets to connect the operators.
$ osh "remdup -key Month -key Customer < CaliforniaRaw.ds > California.v; remdup -key Month -key Customer < NationalRaw.ds | merge -key Month -key Customer < California.v > Combined.ds"
In this example, California.v is a named virtual data set used as input to merge.
159
The following figure shows record schemas for the NationalRaw.ds and CaliforniaRaw.ds in which both schemas have a field named Balance:
Master data set NationalRaw.ds schema: customer:int16; month:string[3]; balance:sfloat; salesman:string[8]; accountType:int8;
Update data set CaliforniaRaw.ds schema: customer:int16; month:string[3]; balance:sfloat; CalBalance:sfloat; status:string[8];
If you want the Balance field from the update data set to be output by the merge operator, you have two alternatives, both using the modify operator. v Rename the Balance field in the master data set. v Drop the Balance field from the master record. In either case, the Balance field from the update data set propagates to the output record because it is the only Balance field. The following figure shows the data flow for both methods.
master
National.ds
update
CaliforniaRaw.ds
remdup
remdup
California.v
modify
merge
step
output
160
modify OldBalance = Balance | merge -key Month -key Customer < California.v > Combined.ds"
The name of the Balance field has been changed to OldBalance. The Balance field from the update data set no longer conflicts with a field in the master data set and is added to records by the merge.
161
# import the order file; store as a virtual data set. import -schema $ORDER_SCHEMA -file orders.txt -readers 4 | peek -name -nrecs 1 >orders.v; # import the product lookup table; store as a virtual data set. import -schema $LOOKUP_SCHEMA -file lookup_product_id.txt | entire | # entire partitioning only necessary in MPP environments peek -name -nrecs 1 >lookup_product_id.v; # merge customer data with order data; lookup product descriptions; # store as a persistent data set. merge -key cust_id -dropBadMasters # customer did not place an order this period < customers.v < orders.v 1>| orders_without_customers.ds | # if not empty, we have a problem lookup -key product_id -ifNotFound continue # allow products that dont have a description < lookup_product_id.v | peek -name -nrecs 10 >| customer_orders.ds;
162
Missing records
The merge operator expects that for each master record there exists a corresponding update record, based on the merge key fields, and vice versa. If the merge operator takes a single update data set as input, the update data set may contain multiple update records for a single master record. By using command-line options to the operator, you can specify the action of the operator when a master record has no corresponding update record (a bad master record) or when an update record has no corresponding master record (a bad update record).
86111
JUN
Lee, Mary
345.98
Steve
12
Chapter 7. Operators
163
In order to collect bad update records from an update data set, you attach one output data set, called a reject data set, for each update data set. The presence of a reject data set configures the merge operator to write bad update records to the reject data set. In the case of a merge operator taking as input multiple update data sets, you must attach a reject data set for each update data set if you want to save bad update records. You cannot selectively collect bad update records from a subset of the update data sets. By default, the merge operator issues a warning message when it encounters a bad update record. You can use the -nowarnBadMasters option to the operatorcto suppress this warning. For example, suppose you have a data set named National.ds that has one record per the key field Customer. You also have an update data set named California.ds, which also has one record per Customer. If you now merge these two data sets, and include a reject data set, bad update records are written to the reject data set for all customer records from California.ds that are not already in National.ds. If the reject data set is empty after the completion of the operator, it means that all of the California.ds customers already have National.ds records. The following diagram shows an example using a reject data set.
step
merge
combined.ds
CalReject.ds
After this step executes, CalReject.ds contains all records from update data set that did not have a corresponding record in the master data set. The following diagram shows the merge operator with multiple update sets (U1 and U2) and reject data sets (R1 and R2). In the figure, M indicates the master data set and O indicates the merged output data set.
164
merge
R1
R2
Modify operator
The modify operator takes a single data set as input and alters (modifies) the record schema of the input data set to create the output data set. The modify operator changes the representation of data before or after it is processed by another operator, or both. Use it to modify: v Elements of the record schema of an input data set to the interface required by the by the operator to which it is input v Elements of an operators output to those required by the data set that receive the results The operator performs the following modifications: v Keeping and dropping fields v Renaming fields v Changing a fields data type v Changing the null attribute of a field The modify operator has no usage string.
modify
165
Properties
Property Number of input data sets Number of output data sets Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator Value 1 1 any (parallel mode) any (sequential mode) propagated no
where each modify_spec specifies a conversion you want to perform. Performing Conversions describes the conversions that the modify operator can perform. v Enclose the list of modifications in single quotation marks. v Separate the modifications with a semi-colon. v If modify_spec takes more than one argument, separate the arguments with a comma and terminate the argument list with a semi-colon, as in the following example:
modify keep field1,field2, ... fieldn;
Multi-byte Unicode character data is supported for fieldnames in the modify specifications below. The modify_spec can be one of the following: v DROP v KEEP v replacement_spec v NOWARN To drop a field:
DROP fieldname [, fieldname ...]
To keep a field:
KEEP fieldname [, fieldname ...]
To change the name or data type of a field, or both, specify a replacement-spec, which takes the form:
new-fieldname [:new-type] = [explicit-conversion-spec] old-fieldname
Replace the old field name with the new one. The default type of the new field is the same as that if the old field unless it is specified by the output type of the conversion-spec if provided. Multiple new fields can be instantiated based on the same old field.
166
When there is an attempt to put a null in a field that has not been defined as nullable, WebSphere DataStage issues an error message and terminates the job. However, a warning is issued at step-check time. To disable the warning, specify the NOWARNF option.
Transfer behavior
Fields of the input data set that are not acted on by the modify operator are transferred to the output data set unchanged. In addition, changes made to fields are permanent. Thus: v If you drop a field from processing by means of the modify operator, it does not appear in the output of the operation for which you have dropped it. v If you use an upstream modify operator to change the name, type, or both of an input field, the change is permanent in the output unless you restore the field name, type, or both by invoking the modify operator downstream of the operation for whose sake the field name was changed. In the following example, the modify operator changes field names upstream of an operation and restores them downstream of the operation, as indicated in the following table.
Source Field Name Upstream of Operator aField bField cField field1 field2 field3 Destination Field Name field1 field2 field3 aField bField cField
Downstream of Operator
Performing conversions
The section Allowed Conversions provides a complete list of conversions you can effect using the modify operator. This section discusses these topics: v Performing Conversions v v v v v Keeping and Dropping Fields Renaming Fields Duplicating a Field and Giving It a New Name Changing a Fields Data Type Default Data Type Conversion
Chapter 7. Operators
167
v v v v v v v v v v v
Date Field Conversions Decimal Field Conversions Raw Field Length Extraction String and Ustring Field Conversions String Conversions and Lookup Tables Time Field Conversions Timestamp Field Conversions The The The The modify modify modify modify Operator Operator Operator Operator and Nulls and Partial Schemas and Vectors and Aggregate Schema Components
Renaming fields
To rename a field specify the attribution operator (=) , as follows:
modify newField1=oldField1; newField2=oldField2; ...newFieldn=oldFieldn;
where: v a and c are the original field names; a_1, a_2 are the duplicated field names; c_1, and c_2 are the duplicated and converted field names v conversionSpec is the data type conversion specification, discussed in the next section
168
field1:int32;field2:int16;field3:sfloat;
modify
field1:int32;field2:int16;field3:sfloat;
Chapter 7. Operators
169
Destination Field Source Field int8 int16 uint16 int32 uint32 int64 uint64 sfloat dfloat decimal string ustring raw date time time stamp dm d dm d dm d dm dm dm dm dm m m m m m uint8 d d d d d d d d d d d d d d d d d d d dm dm d d d d d d d d d d d d d d dm d d m m m m m m m d d d d d dm dm d d d dm d d d d dm d d d d d d dm dm dm int16 uint16 d int32 d d uint32 d d d int64 d d d d uint64 d d d d d sfloat d d d d d d dfloat d d d d d d d
Source Field decimal int8 uint8 int16 uint16 int32 uint32 int64 uint64 sfloat dfloat decimal string ustring raw date time timestamp m m m m m m m m m dm dm dm d d d d d d d d d d dm string dm d dm dm dm m d d d dm dm ustring dm d dm dm dm m d d d dm dm d m m m m m m m m m m raw date m time m timestamp m
170
where: v destField is the field in the output data set v dataType optionally specifies the data type of the output field. This option is allowed only when the output data set does not already have a record schema, which is typically the case. v sourceField specifies the field in the input data set v conversionSpec specifies the data type conversion specification; you need not specify it if a default conversion exists (see Default Data Type Conversion ). A conversion specification can be double quoted, single quoted, or not quoted, but it cannot be a variable. Note that once you have used a conversion specification to perform a conversion, WebSphere DataStage performs the necessary modifications to translate a conversion result to the numeric data type of the destination. For example, you can use the conversion hours_from_time to convert a time to an int8, or to an int16, int32, dfloat, and so on.
Chapter 7. Operators
171
Conversion Specification dateField = date_from_string [date_format | date_uformat] (stringField) dateField = date_from_ustring [date_format | date_uformat] (ustringField)
Description date from string or ustring Converts the string or ustring field to a date representation using the specified date_format. By default, the string format is yyyy-mm-dd. date_format and date_uformat are described in date Formats . date from timestamp Converts the timestamp to a date representation.
dateField = date_from_timestamp(tsField)
day of month from date day of week from date originDay is a string specifying the day considered to be day zero of the week. You can specify the day using either the first three characters of the day name or the full day name. If omitted, Sunday is defined as day zero. The originDay can be either single- or double-quoted or the quotes can be omitted.
day of year from date (returned value 1-366) days since date Returns a value corresponding to the number of days from source_date to the contents of dateField. source_date must be in the form yyyy-mm-dd and can be quoted or unquoted.
Julian day from date month from date next weekday from date The destination contains the date of the specified day of the week soonest after the source date (including the source date). day is a string specifying a day of the week. You can specify day by either the first three characters of the day name or the full day name. The day can be quoted in either single or double quotes or quotes can be omitted.
previous weekday from date The destination contains the closest date for the specified day of the week earlier than the source date (including the source date) The day is a string specifying a day of the week. You can specify day using either the first three characters of the day name or the full day name. The day can be either single- or double- quoted or the quotes can be omitted.
172
Conversion Specification stringField = string_from_date[date_format | uformat] (dateField) ustringField = ustring_from_date [date_format | date_uformat] (dateField)
Description strings and ustrings from date Converts the date to a string or ustring representation using the specified date_format. By default, the string format is yyyy-mm-dd. date_format and date_uformat are described in date Formats . timestamp from date The time argument optionally specifies the time to be used in building the timestamp result and must be in the form hh:nn:ss. If omitted, the time defaults to midnight.
tsField = timestamp_from_date[time](dateField)
A date conversion to or from a numeric field can be specified with any WebSphere DataStage numeric data type. WebSphere DataStage performs the necessary modifications and either translates a numeric field to the source data type shown above or translates a conversion result to the numeric data type of the destination. For example, you can use the conversion month_day_from_date to convert a date to an int8, or to an int16, int32, dfloat, etc.
date formats
Four conversions, string_from_date, ustring_from_date, date_from_string, and ustring_from_date, take as a parameter of the conversion a date format or a date uformat. These formats are described below. The default format of the date contained in the string is yyyy-mm-dd. The format string requires that you provide enough information for WebSphere DataStage to determine a complete date (either day, month, and year, or year and day of year).
date uformat
The date uformat provides support for international components in date fields. Its syntax is:
String%macroString%macroString%macroString
where %macro is a date formatting macro such as %mmm for a 3-character English month. See 177 for a description of the date format macros. Only the String components of date uformat can include multi-byte Unicode characters.
date format
The format string requires that you provide enough information for WebSphere DataStage to determine a complete date (either day, month, and year, or year and day of year). The format_string can contain one or a combination of the following elements:
Table 4. Date format tags Tag %d Variable width availability import Description Day of month, variable width Value range 1...31 Options s
Chapter 7. Operators
173
Table 4. Date format tags (continued) Tag %dd %ddd %m %mm %mmm %mmmm %yy %yyyy %NNNNyy %e %E %eee %eeee %W %WW import/export import import/export with v option import Variable width availability Description Day of month, fixed width Day of year Month of year, variable width Month of year, fixed width Month of year, short name, locale specific Month of year, full name, locale specific Year of century Four digit year Cutoff year plus year of century Day of week, Sunday = day 1 Day of week, Monday = day 1 Value range 01...31 1...366 1...12 01...12 Jan, Feb ... January, February ... 00...99 0001 ...9999 yy = 00...99 1...7 1...7 t, u, w t, u, w, -N, +N s s s Options s s, v s s t, u, w t, u, w, -N, +N s
Weekday short name, Sun, Mon ... locale specific Weekday long name, locale specific Week of year (ISO 8601, Mon) Week of year (ISO 8601, Mon) Sunday, Monday ... 1...53 01...53
When you specify a date format string, prefix each component with the percent symbol (%) and separate the strings components with a suitable literal character. The default date_format is %yyyy-%mm-%dd. Where indicated the tags can represent variable-width data elements. Variable-width date elements can omit leading zeroes without causing errors. The following options can be used in the format string where indicated in the table: s Specify this option to allow leading spaces in date formats. The s option is specified in the form: %(tag,s) Where tag is the format string. For example: %(m,s) indicates a numeric month of year field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property: %(d,s)/%(m,s)/%yyyy
174
Then the following dates would all be valid: 8/ 8/1958 08/08/1958 8/8/1958 v Use this option in conjunction with the %ddd tag to represent day of year in variable-width format. So the following date property: %(ddd,v) represents values in the range 1 to 366. (If you omit the v option then the range of values would be 001 to 366.) u w t Use this option to render uppercase text on output. Use this option to render lowercase text on output. Use this option to render titlecase text (initial capitals) on output.
The u, w, and t options are mutually exclusive. They affect how text is formatted for output. Input dates will still be correctly interpreted regardless of case. -N +N Specify this option to left justify long day or month names so that the other elements in the date will be aligned. Specify this option to right justify long day or month names so that the other elements in the date will be aligned.
Names are left justified or right justified within a fixed width field of N characters (where N is between 1 and 99). Names will be truncated if necessary. The following are examples of justification in use: %dd-%(mmmm,-5)-%yyyyy
21-Augus-2006
%dd-%(mmmm,-10)-%yyyyy
21-August -2005
%dd-%(mmmm,+10)-%yyyyy
21August-2005
The locale for determining the setting of the day and month names can be controlled through the locale tag. This has the format:
%(L,locale)
Where locale specifies the locale to be set using the language_COUNTRY.variant naming convention supported by ICU. See NLS Guide for a list of locales. The default locale for month names and weekday names markers is English unless overridden by a %L tag or the APT_IMPEXP_LOCALE environment variable (the tag takes precedence over the environment variable if both are set). Use the locale tag in conjunction with your time format, for example the format string: %(L,es)%eeee, %dd %mmmm %yyyy Specifies the Spanish locale and would result in a date withe the following format: mircoles, 21 septembre 2005
Chapter 7. Operators
175
The format string is subject to the restrictions laid out in the following table. A format string can contain at most one tag from each row. In addition some rows are mutually incompatible, as indicated in the incompatible with column. When some tags are used the format string requires that other tags are present too, as indicated in the requires column.
Table 5. Format tag restrictions Element year month Numeric format tags %yyyy, %yy, %[nnnn]yy %mm, %m Text format tags %mmm, %mmmm Requires year month year %eee, %eeee month, week of year year Incompatible with week of year day of week, week of year day of month, day of week, week of year day of year month, day of month, day of year
day of month %dd, %d day of year day of week week of year %ddd %e, %E %WW
When a numeric variable-width input tag such as %d or %m is used, the field to the immediate right of the tag (if any) in the format string cannot be either a numeric tag, or a literal substring that starts with a digit. For example, all of the following format strings are invalid because of this restriction: %d%m-%yyyy %d%mm-%yyyy %(d)%(mm)-%yyyy %h00 hours The year_cutoff is the year defining the beginning of the century in which all two-digit years fall. By default, the year cutoff is 1900; therefore, a two-digit year of 97 represents 1997. You can specify any four-digit year as the year cutoff. All two-digit years then specify the next possible year ending in the specified two digits that is the same or greater than the cutoff. For example, if you set the year cutoff to 1930, the two-digit year 30 corresponds to 1930, and the two-digit year 29 corresponds to 2029. On import and export, the year_cutoff is the base year. This property is mutually exclusive with days_since, text, and julian. You can include literal text in your date format. Any Unicode character other than null, backslash, or the percent sign can be used (although it is better to avoid control codes and other non-graphic characters). The following table lists special tags and escape sequences:
Tag %% \% \n \t \\ Escape sequence literal percent sign literal percent sign newline horizontal tab single backslash
Parallel Job Advanced Developer Guide
176
For example, the format string %mm/%dd/%yyyy specifies that slashes separate the strings date components; the format %ddd-%yy specifies that the string stores the date as a value from 1 to 366, derives the year from the current year cutoff of 1900, and separates the two components with a dash (-). The diagram shows the modification of a date field to three integers. The modify operator takes: v The day of the month portion of a date field and writes it to an 8-bit integer v The month portion of a date field and writes it to an 8-bit integer v The year portion of a date field and writes it to a 16-bit integer
modify
177
Conversion decimal from string decimal from ustring scaled decimal from int64 dfloat from decimal dfloat from decimal dfloat from dfloat int32 from decimal int64 from decimal string from decimal ustring from decimal uint64 from decimal
Conversion Specification decimalField = decimal_from_string[r_type](stringField) decimalField = decimal_from_ustring[r_type](ustringField) target_field:decimal[p,s] = scaled_decimal_from_int64 [no_warn] (int64field) dfloatField = dfloat_from_decimal[fix_zero](decimalField) dfloatField = mantissa_from_decimal(decimalField) dfloatField = mantissa_from_dfloat(dfloatField) int32Field = int32_from_decimal[r_type, fix_zero](decimalField) int64Field = int64_from_decimal[r_type, fix_zero](decimalField) stringField = string_from_decimal [fix_zero] [suppress_zero](decimalField) ustringField = ustring_from_decimal [fix_zero] [suppress_zero](decimalField) uint64Field = uint64_from_decimal[r_type, fix_zero](decimalField)
A decimal conversion to or from a numeric field can be specified with any WebSphere DataStage numeric data type. WebSphere DataStage performs the necessary modification. For example, int32_from_decimal converts a decimal either to an int32 or to any numeric data type, such as int16, or uint32. The scaled decimal from int64 conversion takes an integer field and converts the field to a decimal of the specified precision (p) and scale (s) by dividing the field by 102. For example, the conversion:
Decfield:decimal[8,2]=scaled_decimal_from_int64(intfield)
where intfield = 12345678 would set the value of Decfield to 123456.78. The fix_zero specification causes a decimal field containing all zeros (normally illegal) to be treated as a valid zero. Omitting fix_zero causes WebSphere DataStage to issue a conversion error when it encounters a decimal field containing all zeros. Data Type Conversion Errors discusses conversion errors. The suppress_zero argument specifies that the returned string value will have no leading or trailing zeros. Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
rounding type
You can optionally specify a value for the rounding type (r_type) of many conversions. The values of r_typeare: v ceil: Round the source field toward positive infinity. This mode corresponds to the IEEE 754 Round Up mode. v Examples: 1.4 -> 2, -1.6 -> -1 v floor: Round the source field toward negative infinity. This mode corresponds to the IEEE 754 Round Down mode. v Examples: 1.6 -> 1, -1.4 -> -2
178
v 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. This mode corresponds to the COBOL ROUNDED mode. v Examples: 1.4 -> 1, 1.5 -> 2, -1.4 -> -1, -1.5 -> -2 v trunc_zero (default): Discard any fractional digits to the right of the right-most 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. This mode corresponds to the COBOL INTEGER-PART function. v Examples: 1.6 -> 1, -1.6 -> -1 The diagram shows the conversion of a decimal field to a 32-bit integer with a rounding mode of ceil rather than the default mode of truncate to zero:
field1 = int32_from_decimal[ceil](dField);
modify
where fix_zero ensures that a source decimal containing all zeros is treated as a valid representation.
Chapter 7. Operators
179
modify
Use the following osh commands to specify the raw_length conversion of a field:
$ modifySpec="field1 = raw_length(aField); field2 = aField;" $ osh " ... | modify $modifySpec |... "
Notice that a shell variable (modifySpec) has been defined containing the specifications passed to the operator.
Conversion Specification rawField = raw_from_string(string) rawField = u_raw_from_string(ustring) int32Field = raw_length(raw) Description Returns string in raw representation. Returns ustring in raw representation. Returns the length of the raw field.
180
Description You can use this function to remove the characters used to pad variable-length strings when they are converted to fixed-length strings of greater length. By default, these characters are retained when the fixed-length string is then converted back to a variable-length string. The character argument is the character to remove. It defaults to NULL. The value of the direction and justify arguments can be either begin or end; direction defaults to end, and justify defaults to begin. justify has no affect when the target string has variable length. Examples: name:string = string_trim[NULL, begin](name) removes all leading ASCII NULL characters from the beginning of name and places the remaining characters in an output variable-length string with the same name. hue:string[10] = string_trim[Z, end, begin](color) removes all trailing Z characters from color, and left justifies the resulting hue fixed-length string.
Copies parts of strings and ustrings to shorter strings by string extraction. The starting_position specifies the starting location of the substring; length specifies the substring length. The arguments starting_position and length are uint16 types and must be positive (>= 0).
stringField=lookup_string_from_int16 [tableDefinition](int16Field) ustringField=lookup_ustring_from_int16 [tableDefinition](int16Field) int16Field=lookup_int16_from_string [tableDefinition](stringField) int16Field=lookup_int16_from_ustring [tableDefinition](ustringField) uint32 = lookup_uint32_from_string [tableDefinition](stringField) uint32 =lookup_uint32_from_ustring [tableDefinition](ustringField) stringField= lookup_string_from_uint32 [tableDefinition](uint32Field) ustringField=lookup_ustring_from_uint32 [tableDefinition](uint32Field) stringField = string_from_ustring(ustring) ustringField = ustring_from_string(string) decimalField = decimal_from_string(stringField) decimalField = decimal_from_ustring(ustringField)
Converts ustrings to strings. Converts strings to ustrings. Converts strings to decimals. Converts ustrings to decimals.
Chapter 7. Operators
181
Description Converts decimals to strings. fix_zero causes a decimal field containing all zeros to be treated as a valid zero. suppress_zero specifies that the returned ustring value will have no leading or trailing zeros. Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
Converts decimals to ustrings. See string_from_decimal above for a description of the fix_zero and suppress_zero arguments. date from string or ustring Converts the string or ustring field to a date representation using the specified date_format or date_uformat. By default, the string format is yyyy-mm-dd. date_format and date_uformat are described in date Formats.
dateField = date_from_string [date_format | date_uformat] (stringField) dateField = date_from_ustring [date_format | date_uformat] (ustringField)
stringField = string_from_date [date_format | date_uformat] strings and ustrings from date (dateField) Converts the date to a string or ustring representation ustringField = ustring_from_date [date_format | using the specified date_format or date_uformat. date_uformat] (dateField) By default, the string format is yyyy-mm-dd. date_format and date_uformat are described in date Formats . int32Field=string_length(stringField) int32Field=ustring_length(ustringField) stringField=substring [startPosition,len] (stringField) ustringField=substring [startPosition,len] (ustringField) Returns an int32 containing the length of a string or ustring. Converts long strings/ustrings to shorter strings/ ustrings by string extraction. The startPosition specifies the starting location of the substring; len specifies the substring length. If startPosition is positive, it specifies the byte offset into the string from the beginning of the string. If startPosition is negative, it specifies the byte offset from the end of the string. stringField=uppercase_string (stringField) ustringField=uppercase_ustring (ustringField) stringField=lowercase_string (stringField) ustringField=lowercase_ustring (ustringField) Convert strings and ustrings to all upper case. Non-alphabetic characters are ignored in the conversion. Convert stringsand ustrings to all lower case. Non-alphabetic characters are ignored in the conversion.
stringField = string_from_time [time_format | time_uformat string and ustring from time ] (timeField) Converts the time to a string or ustring representation ustringField = ustring_from_time [time_format | using the specified time_format or time_uformat. The time_uformat] (timeField) time_format options are described below.
182
Conversion Specification stringField = string_from_timestamp [timestamp_format | timestamp_uformat] (tsField) ustringField = ustring_from_timestamp [timestamp_format | timestamp_uformat] (tsField)
Description strings and ustrings from timestamp Converts the timestamp to a string or ustring representation using the specified timestamp_format or timestamp_uformat. By default, the string format is %yyyy-%mm-%dd hh:mm:ss. The timestamp_format and timestamp_uformat options are described in timestamp Formats .
tsField = timestamp_from_string [timestamp_format | timestamp_uformat] (stringField) tsField = timestamp_from_ustring [timestamp_format | timestamp_uformat] (usringField)
timestamp from strings and ustrings Converts the string or ustring to a timestamp representation using the specified timestamp_format or timestamp_uformat. By default, the string format is yyyy-mm-dd hh:mm:ss. The timestamp_format and timestamp_uformat options are described timestamp Formats .
Converts the time to a string or ustring representation timeField = time_from_ustring [time_format | time_uformat] using the specified time_format. The time_uformat options (ustringField) are described below.
The diagram shows a modification that converts the name of aField to field1 and produces field2 from bField by extracting the first eight bytes of bField:
modify
The diagram shows the extraction of the string_length of aField. The length is included in the output as field1.
Chapter 7. Operators
183
modify
The following osh commands extract the length of the string in aField and place it in field1 of the output:
$ modifyspec="field1 = string_length(aField); field2 = aField;" $ osh " ... | modify $modifySpec |... "
Notice that a shell variable (modifySpec) has been defined containing the specifications passed to the operator.
Each row of the lookup table specifies an association between a 16-bit integer or unsigned 32-bit integer value and a string or ustring. WebSphere DataStage scans the Numeric Value or the String or Ustring column until it encounters the value or string to be translated. The output is the corresponding entry in the row. The numeric value to be converted may be of the int16 or the uint32 data type. WebSphere DataStage converts strings to values of the int16 or uint32 data type using the same table. If the input contains a numeric value or string that is not listed in the table, WebSphere DataStage operates as follows: v If a numeric value is unknown, an empty string is returned by default. However, you can set a default string value to be returned by the string lookup table. v If a string has no corresponding value, 0 is returned by default. However, you can set a default numeric value to be returned by the string lookup table. Here are the options and arguments passed to the modify operator to create a lookup table:
184
OR:
intField = lookup_uint32_from_string[tableDefinition] (source_stringField); | intField = lookup_uint32_from_ustring[tableDefinition] (source_ustringField); stringField = lookup_string_from_int16[tableDefinition](source_intField); | ustringField = lookup_ustring_from_int16[tableDefinition](source_intField);
OR:
stringField = lookup_string_from_uint32[tableDefinition] ( source_intField ); ustringField = lookup_ustring_from_uint32[tableDefinition] (source_intField);
where: tableDefinition defines the rows of a string or ustring lookup table and has the following form:
{propertyList} (string | ustring = value; string | ustring= value; ... )
where: v propertyList is one or more of the following options; the entire list is enclosed in braces and properties are separated by commas if there are more than one: case_sensitive: perform a case-sensitive search for matching strings; the default is case-insensitive. default_value = defVal: the default numeric value returned for a string that does not match any of the strings in the table. default_string = defString: the default string returned for numeric values that do not match any numeric value in the table. v string or ustring specifies a comma-separated list of strings or ustrings associated with value; enclose each string or ustring in quotes. v value specifies a comma-separated list of 16-bit integer values associated with string or ustring. The diagram shows an operator and data set requiring type conversion:
Chapter 7. Operators
185
schema:
modify
sample
Whereas gender is defined as a string in the input data set, the SampleOperator defines the field as an 8:-bit integer. The default conversion operation cannot work in this case, because by default WebSphere DataStage converts a string to a numeric representation and gender does not contain the character representation of a number. Instead the gender field contains the string values male, female, m, or f. You must therefore specify a string lookup table to perform the modification. The gender lookup table required by the example shown above is shown in the following table:
Numeric Value 0 0 1 1 String f female m male
The value f or female is translated to a numeric value of 0; the value m or male is translated to a numeric value of 1. The following osh code performs the conversion:
modify gender = lookup_int16_from_string[{default_value = 2} (f = 0; female = 0; m = 1; male = 1;)] (gender);
In this example, gender is the name of both the source and the destination fields of the translation. In addition, the string lookup table defines a default value of 2; if gender contains a string that is not one of f, female, m, or male, the lookup table returns a value of 2.
186
Converts the string or ustring to a time representation timeField = time_from_ustring [time_format | time_uformat] using the specified time_format or time_uformat. (ustringField) The time format options are described below. timeField = time_from_timestamp(tsField) tsField = timestamp_from_time [date](timeField) time from timestamp timestamp from time The date argument is required. It specifies the date portion of the timestamp and must be in the form yyyy-mm-dd.
Time conversion to a numeric field can be used with any WebSphere DataStage numeric data type. WebSphere DataStage performs the necessary modifications to translate a conversion result to the numeric data type of the destination. For example, you can use the conversion hours_from_time to convert a time to an int8, or to an int16, int32, dfloat, and so on.
time Formats
Four conversions, string_from_time, ustring_from_time, time_from_string, and ustring_from_time, take as a parameter of the conversion a time format or a time uformat. These formats are described below. The default format of the time contained in the string is hh:mm:ss.
time Uformat
The time uformat date format provides support for international components in time fields. Its syntax is:
String % macroString % macroString % macroString
where %macro is a time formatting macro such as %hh for a two-digit hour. See time Format on page 188 below for a description of the time format macros. Only the String components of time uformat can include multi-byte Unicode characters.
Chapter 7. Operators
187
time Format
The string_from_time and time_from_string conversions take a format as a parameter of the conversion. The default format of the time in the string is hh:mm:ss. However, you can specify an optional format string defining the time format of the string field. The format string must contain a specification for hours, minutes, and seconds. The possible components of the time_format string are given in the following table:
Table 6. Time format tags Tag %h %hh %H %HH %n %nn %s %ss %s.N %ss.N %SSS %SSSSSS %aa with v option with v option German import import import import Variable width availability import Description Hour (24), variable width Hour (24), fixed width Hour (12), variable width Hour (12), fixed width Minutes, variable width Minutes, fixed width Seconds, variable width Seconds, fixed width Value range 0...23 0...23 1...12 01...12 0...59 0...59 0...59 0...59 Options s s s s s s s s s, c, C s, c, C s, v s, v u, w
Seconds + fraction (N = 0...6) Seconds + fraction (N = 0...6) Milliseconds Microseconds am/pm marker, locale specific 0...999 0...999999 am, pm
By default, the format of the time contained in the string is %hh:%nn:%ss. However, you can specify a format string defining the format of the string field. You must prefix each component of the format string with the percent symbol. Separate the strings components with any character except the percent sign (%). Where indicated the tags can represent variable-fields on import, export, or both. Variable-width date elements can omit leading zeroes without causing errors. The following options can be used in the format string where indicated: s Specify this option to allow leading spaces in time formats. The s option is specified in the form: %(tag,s) Where tag is the format string. For example: %(n,s)
188
indicates a minute field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property: %(h,s):$(n,s):$(s,s) Then the following times would all be valid: 20: 6:58 20:06:58 20:6:58 v Use this option in conjunction with the %SSS or %SSSSSS tags to represent milliseconds or microseconds in variable-width format. So the time property: %(SSS,v) represents values in the range 0 to 999. (If you omit the v option then the range of values would be 000 to 999.) u w c C Use this option to render the am/pm text in uppercase on output. Use this option to render the am/pm text in lowercase on output. Specify this option to use a comma as the decimal separator in the %ss.N tag. Specify this option to use a period as the decimal separator in the %ss.N tag.
The c and C options override the default setting of the locale. The locale for determining the setting of the am/pm string and the default decimal separator can be controlled through the locale tag. This has the format:
%(L,locale)
Where locale specifies the locale to be set using the language_COUNTRY.variant naming convention supported by ICU. See NLS Guide for a list of locales. The default locale for am/pm string and separators markers is English unless overridden by a %L tag or the APT_IMPEXP_LOCALE environment variable (the tag takes precedence over the environment variable if both are set). Use the locale tag in conjunction with your time format, for example: %L(es)%HH:%nn %aa Specifies the Spanish locale. The format string is subject to the restrictions laid out in the following table. A format string can contain at most one tag from each row. In addition some rows are mutually incompatible, as indicated in the incompatible with column. When some tags are used the format string requires that other tags are present too, as indicated in the requires column.
Table 7. Format tag restrictions Element hour am/pm marker minute second fraction of a second Numeric format tags %hh, %h, %HH, %H %nn, %n %ss, %s %ss.N, %s.N, %SSS, %SSSSSS Text format tags %aa Requires hour (%HH) Incompatible with hour (%hh) -
Chapter 7. Operators
189
You can include literal text in your date format. Any Unicode character other than null, backslash, or the percent sign can be used (although it is better to avoid control codes and other non-graphic characters). The following table lists special tags and escape sequences:
Tag %% \% \n \t \\ Escape sequence literal percent sign literal percent sign newline horizontal tab single backslash
modify
The following osh code converts the hours portion of tField to the int8 hoursField and the minutes portion to the int8 minField:
modify hoursField = hours_from_time(tField); minField = minutes_from_time(tField);
190
Conversion Specification tsField = timestamp_from_seconds_since [ timestamp ]( dfloatField ) stringField = string_from_timestamp [ timestamp_format | timestamp_uformat] ( tsField ) ustringField = ustring_from_timestamp [ timestamp_format | timestamp_uformat] ( tsField )
Description timestamp from seconds_since strings and ustrings from timestamp Converts the timestamp to a string or ustring representation using the specified timestamp_format or timestamp_uformat . By default, the string format is %yyyy-%mm-%dd hh:mm:ss. The timestamp_format and timestamp_uformat options are described in timestamp Formats .
tsField = timestamp_from_string [ timestamp_format | timestamp_uformat] ( stringField ) tsField = timestamp_from_ustring [ timestamp_format | timestamp_uformat] ( usringField )
timestamp from strings and ustrings Converts the string or ustring to a timestamp representation using the specified timestamp_format . By default, the string format is yyyy-mm-dd hh:mm:ss. The timestamp_format and timestamp_uformat options are described in timestamp Formats . timestamp from time_t int32Field must contain a timestamp as defined by the UNIX time_t representation.
timestamp from date The time argument optionally specifies the time to be used in building the timestamp result and must be in the form hh:mm:ss. If omitted, the time defaults to midnight.
timestamp from time The date argument is required. It specifies the date portion of the timestamp and must be in the form yyyy-mm-dd.
Returns a timestamp from date and time. The date specifies the date portion (yyyy-nn-dd) of the timestamp. The time argument specifies the time to be used when building the timestamp. The time argument must be in the hh:nn:ss format. time from timestamp
Timestamp conversion of a numeric field can be used with any WebSphere DataStage numeric data type. WebSphere DataStage performs the necessary conversions to translate a conversion result to the numeric data type of the destination. For example, you can use the conversion timet_from_timestamp to convert a timestamp to an int32, dfloat, and so on.
Chapter 7. Operators
191
timestamp formats
The string_from_timestamp, ustring_from_timestamp, timestamp_from_string, and timestamp_from_ustring conversions take a timestamp format or timestamp uformat argument. The default format of the timestamp contained in the string is yyyy-mm-dd hh:mm:ss. However, you can specify an optional format string defining the data format of the string field.
timestamp format
The format options of timestamp combine the formats of the date and time data types. The default timestamp format is as follows:
%yyyy-%mm-%dd %hh:%mm:%ss
timestamp uformat
For timestamp uformat, concantenate the date uformat with the time uformat. The two formats can be in any order, and their components can be mixed. These formats are described in date Uformat under Date Field Conversions and time Uformat under Time Field Conversions.. The following diagram shows the conversion of a date field to a timestamp field. As part of the conversion, the operator sets the time portion of the timestamp to 10:00:00.
tsField = timestamp_from_time[10:00:00](dField);
modify
To specify the timestamp_from_date conversion and set the time to 10:00:00, use the following osh command:
modify tsField=timestamp_from_date[10:00:00](dField);
192
The modify operator can change a null representation from an out-of-band null to an in-band null and from an in-band null to an out-of-band null. The record schema of an operators input or output data set can contain fields defined to support out-of-band nulls. In addition, fields of an operators interface may also be defined to support out-of-band nulls. The next table lists the rules for handling nullable fields when an operator takes a data set as input or writes to a data set as output.
Source Field not_nullable not_nullable nullable Destination Field not_nullable nullable not_nullable Result Source value propagates to destination. Source value propagates; destination value is never null. If the source value is not null, the source value propagates. If the source value is null, a fatal error occurs, unless you apply the modify operator, as in Out-of-Band to Normal Representation . nullable nullable Source value or null propagates.
where: v destField is the destination fields name. v dataType is its optional data type; use it if you are also converting types. v sourceField is the source fields name v value is the value you wish to represent a null in the output. The destField is converted from an WebSphere DataStage out-of-band null to a value of the fields data type. For a numeric field value can be a numeric value, for decimal, string, time, date, and timestamp fields, value can be a string. Conversion specifications are described in: Date Field Conversions Decimal Field Conversions String and Ustring Field Conversions Time Field Conversions Timestamp Field Conversions For example, the diagram shows the modify operator converting the WebSphere DataStage out-of-band null representation in the input to an output value that is written when a null is encountered:
Chapter 7. Operators
193
modify
While in the input fields a null takes the WebSphere DataStage out-of-band representation, in the output a null in aField is represented by -128 and a null in bField is represented by ASCII XXXX (0x59 in all bytes). To make the output aField contain a value of -128 whenever the input contains an out-of-band null, and the output bField contain a value of XXXX whenever the input contains an out-of-band null, use the following osh code:
$ modifySpec = "aField = handle_null(aField, -128); bField = handle_null(bField, XXXX); " $ osh " ... | modify $modifySpec | ... "
Notice that a shell variable (modifySpec) has been defined containing the specifications passed to the operator.
Where: v destField is the destination fields name. v dataType is its optional data type; use it if you are also converting types. v sourceField is the source fields name. v value is the value of the source field when it is null. A conversion result of value is converted from a WebSphere DataStage out-of-band null to a value of the fields data type. For a numeric field value can be a numeric value, for decimal, string, time, date, and timestamp fields, value can be a string. For example, the diagram shows a modify operator converting the value representing a null in an input field (-128 or XXXX) to the WebSphere DataStage single-bit null representation in the corresponding field of the output data set:
194
modify
In the input a null value in aField is represented by -128 and a null value in bField is represented by ASCII XXXX, but in both output fields a null value if represented by WebSphere DataStages single bit. The following osh syntax causes the aField of the output data set to be set to the WebSphere DataStage single-bit null representation if the corresponding input field contains -128 (in-band-null), and the bField of the output to be set to WebSphere DataStages single-bit null representation if the corresponding input field contains XXXX (in-band-null).
$modifySpec = "aField = make_null(aField, -128); bField = make_null(bField, XXXX); " $ osh " ... | modify $modifySpec | ... "
Notice that a shell variable (modifySpec) has been defined containing the specifications passed to the operator.
By default, the data type of the destination field is int8. Specify a different destination data type to override this default. WebSphere DataStage issues a warning if the source field is not nullable or the destination field is nullable.
Chapter 7. Operators
195
modify
schema: fName:string; lName:string; subField:subrec( subF1:int32; subF2:sfloat;) tagField:tagged( tagF1:int32; tagF2:string;)
In this example, purchase contains an item number and a price for a purchased item; date contains the date of purchase represented as either an integer or a string. You must translate the aggregate purchase to the interface component subField and the tagged component date to tagField. To translate aggregates: 1. Translate the aggregate of an input data set to an aggregate of the output. To translate purchase, the corresponding output component must be a compatible aggregate type. The type is subrecord and the component is subField. The same principle applies to the elements of the subrecord. 2. Translate the individual fields of the data sets aggregate to the individual fields of the operators aggregate.
196
If multiple elements of a tagged aggregate in the input are translated, they must all be bound to members of a single tagged component of the outputs record schema. That is, all elements of tagField must be bound to a single aggregate in the input. Here is the osh code to rename purchase.price to subField.subF2.
$ modifySpec = "subField = purchase; subField.subF1 = purchase.itemNum; subField.subF2 = purchase.price; tagField = date; tagField.tagF1 = date.intDate; tagField.tagF2 = date.stringDate; ); " $ osh " ... | modify $ modifySpec | ... " # translate aggregate # translate field # translate field
Notice that a shell variable (modifySpec) has been defined containing the specifications passed to the operator. Aggregates may contain nested aggregates. When you translate nested aggregates, all components at one nesting level in an input aggregate must be bound to all components at one level in an output aggregate. The table shows sample input and output data sets containing nested aggregates. In the input data set, the record purchase contains a subrecord description containing a description of the item:
Level 0 1 1 1 2 2 Schema 1 (for input data set) purchase: subrec ( itemNum: int32; price: sfloat; description: subrec; ( color: int32; size:int8; ); ); n n+1 n+1 Level Schema 2 (for output data set) ... subField ( subF1; subF2: ); ...
Note that: v itemNum and price are at the same nesting level in purchase. v color and size are at the same nesting level in purchase. v subF1 and subF2 are at the same nesting level in subField. You can bind: v purchase.itemNum and purchase.price (both level 1) to subField.subF1 and subField.subF2, respectively v purchase.description.color and purchase.description.size (both level 2) to subField.subF1 and subField.subF2, respectively You cannot bind two elements of purchase at different nesting levels to subF1 and subF2. Therefore, you cannot bind itemNum (level 1) to subF1 and size (level2) to subF2. Note: WebSphere DataStage features several operators that modify the record schema of the input data set and the level of fields within records. Two of them act on tagged subrecords. See the chapter on the restructure operators.
Chapter 7. Operators
197
Allowed conversions
The table lists all allowed data type conversions arranged alphabetically. The form of each listing is:
conversion_name (source_type ,destination_type) Conversion Specification date_from_days_since ( int32 , date ) date_from_julian_day ( int32 , date ) date_from_string ( string , date ) date_from_timestamp ( timestamp , date ) date_from_ustring ( ustring , date ) days_since_from_date ( date , int32 ) decimal_from_decimal ( decimal , decimal ) decimal_from_dfloat ( dfloat , decimal ) decimal_from_string ( string , decimal ) decimal_from_ustring ( ustring , decimal ) dfloat_from_decimal ( decimal , dfloat ) hours_from_time ( time , int8 ) int32_from_decimal ( decimal , int32 ) int64_from_decimal ( decimal , int64 ) julian_day_from_date ( date , uint32 ) lookup_int16_from_string ( string , int16 ) lookup_int16_from_ustring ( ustring , int16 ) lookup_string_from_int16 ( int16 , string ) lookup_string_from_uint32 ( uint32 , string ) lookup_uint32_from_string ( string , uint32 ) lookup_uint32_from_ustring ( ustring , uint32 ) lookup_ustring_from_int16 ( int16 , ustring ) lookup_ustring_from_int32 ( uint32 , ustring ) lowercase_string ( string , string ) lowercase_ustring ( ustring , ustring ) mantissa_from_dfloat ( dfloat , dfloat ) mantissa_from_decimal ( decimal , dfloat ) microseconds_from_time ( time , int32 ) midnight_seconds_from_time ( time , dfloat) minutes_from_time ( time , int8 ) month_day_from_date ( date , int8 ) month_from_date ( date , int8 ) next_weekday_from_date ( date , date ) notnull ( any , int8 ) null ( any , int8 ) previous_weekday_from_date ( date , date ) raw_from_string ( string , raw )
198
Conversion Specification raw_length ( raw , int32 ) seconds_from_time ( time , dfloat ) seconds_since_from_timestamp ( timestamp , dfloat ) string_from_date ( date , string ) string_from_decimal ( decimal , string ) string_from_time ( time , string ) string_from_timestamp ( timestamp , string ) string_from_ustring ( ustring , string ) string_length ( string , int32 ) substring ( string , string ) time_from_midnight_seconds ( dfloat , time ) time_from_string ( string , time ) time_from_timestamp ( timestamp , time ) time_from_ustring ( ustring , time ) timestamp_from_date ( date , timestamp ) timestamp_from_seconds_since ( dfloat , timestamp ) timestamp_from_string ( string , timestamp ) timestamp_from_time ( time , timestamp ) timestamp_from_timet ( int32 , timestamp ) timestamp_from_ustring ( ustring , timestamp ) timet_from_timestamp ( timestamp , int32 ) uint64_from_decimal ( decimal , uint64 ) uppercase_string ( string , string ) uppercase_ustring ( ustring , ustring ) u_raw_from_string ( ustring , raw ) ustring_from_date ( date , ustring ) ustring_from_decimal ( decimal , ustring ) ustring_from_string ( string , ustring ) ustring_from_time ( time , ustring ) ustring_from_timestamp ( timestamp , ustring ) ustring_length ( ustring , int32 ) u_substring ( ustring , ustring ) weekday_from_date ( date , int8 ) year_day_from_date ( date , int16 ) year_from_date ( date , int16 ) year_week_from_date ( date , int8 )
Chapter 7. Operators
199
pcompress operator
The pcompress operator uses the UNIX compress utility to compress or expand a data set. The operator converts a WebSphere DataStage data set from a sequence of records into a stream of raw binary data; conversely, the operator reconverts the data stream into a WebSphere DataStage data set.
input data set compressed data set
in:*;
pcompress
pcompress
out:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator Value 1 1 mode = compress: in:*; mode = expand: out:*; in -> out without record modification for a compress/decompress cycle parallel (default) or sequential mode = compress: any mode = expand: same any mode = compress: sets mode = expand: propagates yes:APT_EncodeOperator
200
Option -expand
Use -expand This option puts the operator in expand mode. The operator takes a compressed data set as input and produces an uncompressed data set as output.
-command
-command compress | gzip Optionally specifies the UNIX command to be used to perform the compression or expansion. When you specify compress the operator uses the UNIX command, compress -f, for compression and the UNIX command, uncompress, for expansion. When you specify gzip, the operator uses the UNIX command, gzip -, for compression and the UNIX command, gzip -d -, for expansion.
The default mode of the operator is -compress, which takes a data set as input and produces a compressed version as output. Specifying -expand puts the command in expand mode, which takes a compressed data set as input and produces an uncompressed data set as output.
Chapter 7. Operators
201
For an expand operation, the operator takes as input a previously compressed data set. If the preserve-partitioning flag in this data set is not set, WebSphere DataStage issues a warning message.
Example
This example consists of two steps. In the first step, the pcompress operator compresses the output of the upstream operator before it is stored on disk:
step1 op1
pcompress
(mode=compress)
compressDS.ds
In osh, the default mode of the operator is -compress, so you need not specify any option:
$ osh " ... op1 | pcompress > compressDS.ds "
In the next step, the pcompress operator expands the same data set so that it can be used by another operator.
202
compressDS.ds
step2 pcompress
(mode=expand)
op2
Peek operator
The peek operator lets you print record field values to the screen as the operator copies records from its input data set to one or more output data sets. This may be helpful for monitoring the progress of your job, or to diagnose a bug in your job.
inRec:*;
peek
outRec:*;
outRec:*;
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Value 1 N (set by user) inRec:* outRec:* inRec -> outRec without record modification
Chapter 7. Operators
203
Property Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator
Value parallel (default) or sequential any (parallel mode) any (sequential mode) propagated no
204
Option -nrecs
Use -nrecs numrec Specifies the number of records to print per partition. The default is 10.
-period
-period p Cause the operator to print every pth record per partition, starting with first record. p must be >= 1.
-part
-part part_num Causes the operator to print the records for a single partition number. By default, the operator prints records from all partitions.
-skip
-skip n Specifies to skip the first n records of every partition. The default value is 0.
-var
-var input_schema_var_name Explicitly specifies the name of the operators input schema variable. This is necessary when your input data set contains a field named inRec.
step op1
peek
(name)
op2
Chapter 7. Operators
205
PFTP operator
The PFTP (parallel file transfer protocol) Enterprise operator transfers files to and from multiple remote hosts. It works by forking an FTP client executable to transfer a file to or from multiple remote hosts using a URI (Uniform Resource Identifier). This section describes the operator and also addresses issues such as restartability, describing how you can restart an ftp transfer from the point where it was stopped if a fails. The restart occurs at the file boundary.
pftp (get)
outRec:*
pftp (put)
206
Operator properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Value 0 <= N <= 1 (zero or one input data set in put mode) 0 <= N <= 1 (zero or one output data set in get mode) inputRec:* (in put mode) outputRec:* (in get mode) inputRec:* is exported according to a user supplied schema and written to a pipe for ftp transfer. outputRec:* is imported according to a user supplied schema by reading a pipe written by ftp. Parallel None None None None Not Propagated Not Propagated Yes No None No
Default execution mode Input partitioning style Output partitioning style Partitioning method Collection method Preserve-partitioning flag in input data set Preserve-partitioning flag in output data set Restartable Combinable operator Consumption pattern Composite Operator
Chapter 7. Operators
207
Option -uri
Use -uri uri1 [-uri uri2...] The URIs (Uniform Resource Identifiers) are used to transfer or access files from or to multiple hosts. There can be multiple URIs. You can specify one or more URIs, or a single URI with a wild card in the path to retrieve all the files using the wild character pointed by the URI. pftp collects all the retrieved file names before starting the file transfer. pftp supports limited wild carding. Get commands are issued in sequence for files when a wild card is specified. You can specify an absolute or a relative pathname. For put operations the syntax for a relative path is: ftp://remotehost.domain.com/path/remotefilename Where path is the relative path of the users home directory. For put operations the syntax for an absolute path is: ftp://remotehost.domain.com//path/remotefilename While connecting to the mainframe system, the syntax for an absolute path is: ftp://remotehost.domain.com/\path.remotefilename\ Where path is the absolute path of the users home directory. For get operations the syntax for a relative path is: ftp://host/path/filename Where path is the relative path of the users home directory. For get operations the syntax for an absolute path is: ftp://host//path/filename While connecting to the mainframe system, the syntax for an absolute path is: ftp://host//\path.remotefilename\ Where path is the absolute path of the users home directory.
-open_command
-open_command cmd Needed only if any operations need to be performed besides navigating to the directory where the file exists This is a sub-option of the URI option. At most one open_command can be specified for an URI. Example: -uri ftp://remotehost/fileremote1.dat -open_command verbose
208
Option -user
Use -user username1 [-user username2...] With each URI you can specify the User Name to connect to the URI. If not specified, the ftp will try to use the .netrc file in the users home directory. There can be multiple user names. User1 corresponds to URI1. When the number of usernames is less than the number of URIs, the last username is set for the remaining URIs. Example: -user User1 -user User2
-password
-password password1 [-password password1] With each URI you can specify the Password to connect to the URI. If not specified, the ftp will try to use the .netrc file in the users home directory. There can be multiple passwords. Password1 corresponds to URI1. When the number of passwords is less than the number of URIs, the last password is set for the remaining URIs. Note The number of passwords should be equal to the number of usernames. Example: -password Secret1 -password Secret2
-schema
-schema schema You can specify the schema for get or put operations. This option is mutually exclusive with -schemafile. Example: -schema record(name:string;)
-schemafile
-schemafile schemafile You can specify the schema for get or put operations. in a schema file. This option is mutually exclusive with -schema. Example: -schemafile file.schema
-ftp_call
-ftp_call cmd The ftp command to call for get or put operations. The default is ftp. You can include absolute path with the command. Example: -ftp_call /opt/gnu/bin/wuftp.
Chapter 7. Operators
209
Option -force_config_file_parallelism
Use -force_config_file_parallelism Optionally limits the number of pftp players via the APT_CONFIG_FILE configuration file. The operator executes with a maximum degree of parallelism as determined by the configuration file. The operator will execute with a lesser degree of parallelism if the number of get arguments is less than the number of nodes in the Configuration file. In some cases this may result in more than one file being transferred per player.
-overwrite
-overwrite Overwrites remote files in ftp put mode. When this option is not specified, the remote file is not overwritten.
210
Use This option is used to initiate a restartable ftp transfer. The restartability option in get mode will reinitiate ftp transfer at the file boundary. The transfer of the files that failed half way is restarted from the beginning or zero file location. The file URIs that were transferred completely are not transferred again. Subsequently, the downloaded URIs are imported to the data set from the downloaded temporary folder path. v A restartable pftp session is initiated as follows: osh "pftp -uri ftp://remotehost/file.dat -user user -password secret -restartable_transfer -jobid 100 -checkpointdir chkdir -mode put < input.ds v -restart_transfer :If the transfer fails, to restart the transfer again, the restartable pftp session is resumed as follows: osh "pftp -uri ftp://remotehost/file.dat -user user -password secret -restart_transfer -jobid 100 -checkpointdir chkdir -mode put < input.ds v -abandon_transfer : Used to abort the operation,the restartable pftp session is abandoned as follows: osh "pftp -uri ftp://remotehost/file.dat -user user -password secret -abandon_transfer -jobid 100 -checkpointdir chkdir -mode put < input.ds
Chapter 7. Operators
211
Option -job_id
Use This is an integer to specify job identifier of restartable transfer job. This is a dependent option of -restartable_transfer, -restart_transfer, or -abandon_transfer Example: -job_id 101
-checkpointdir
This is the directory name/path of location where pftp restartable job id folder can be created. The checkpoint folder must exist. Example: -checkpointdir "/apt/linux207/orch_master/apt/folder"
-transfer_type
This option is used to specify the data transfer type. You can either choose ASCII or Binary as the data transfer type. Example: -transfer_type binary
-xfer_mode
This option is used to specify data transfer protocol. You can either choose FTP or SFTP mode of data transfer. Example: -xfer_mode sftp
Restartability
You can specify that the FTP operation runs in restartable mode. To do this you: 1. Specify the -restartable_transfer option 2. Specify a unique job_id for the transfer 3. Optionally specify a checkpoint directory for the transfer using the -checkpointdir directory (if you do not specify a checkpoint directory, the current working directory is used) When you run the job that performs the FTP operation, information about the transfer is written to a restart directory identified by the job id located in the checkpoint directory prefixed with the string pftp_jobid_. For example, if you specify a job_id of 100 and a checkpoint directory of /home/bgamsworth/checkpoint the files would be written to /home/bgamsworth/checkpoint/ pftp_jobid_100. If the FTP operation does not succeed, you can rerun the same job with the option set to restart or abandon. For a production environment you could build a job sequence that performed the transfer, then tested whether it was successful. If it was not, another job in the sequence could use another PFTP operator with the restart transfer option to attempt the transfer again using the information in the restart directory. For get operations, WebSphere DataStage reinitiates the FTP transfer at the file boundary. The transfer of the files that failed half way is restarted from the beginning or zero file location. The file URIs that were transferred completely are not transferred again. Subsequently, the downloaded URIs are imported to the data set from the temporary folder path. If the operation repeatedly fails, you can use the abandon_transfer option to abandon the transfer and clear the temporary restart directory.
212
Remdup operator
The remove-duplicates operator, remdup, takes a single sorted data set as input, removes all duplicate records, and writes the results to an output data set. Removing duplicate records is a common way of cleansing a data set before you perform further processing. Two records are considered duplicates if they are adjacent in the input data set and have identical values for the key field(s). A key field is any field you designate to be used in determining whether two records are identical. For example, a direct mail marketer might use remdup to aid in householding, the task of cleansing a mailing list to prevent multiple mailings going to several people in the same household. The input data set to the remove duplicates operator must be sorted so that all records with identical key values are adjacent. By default, WebSphere DataStage inserts partition and sort components to meet the partitioning and sorting needs of the remdup operator and other operators.
inRec:*;
remdup
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Input partitioning style Partitioning method Collection method Preserve-partitioning flag in output data set Restartable Composite operator Value 1 1 inRec:* outRec:* inRec -> outRec without record modification parallel (default) or sequential keys in same partition same (parallel mode) any (sequential mode) propagated yes no
Chapter 7. Operators
213
214
In this example, WebSphere DataStage-inserted partition and sort components guarantees that all records with the same key field values are in the same partition of the data set. For example, all of the January records for Customer 86111 are processed together as part of the same partition.
The default result of removing duplicate records on this data set is:
Month Apr Customer 86111 Balance 787.38
Chapter 7. Operators
215
Month May
Customer 86111
Balance 134.66
Using the -last option, you can specify that the last duplicate record is to be retained rather than the first. This can be useful if you know, for example, that the last record in a set of duplicates is always the most recent record. For example, if the osh command is:
$ osh "remdup -key Month -key Customer -last < inDS.ds > outDS.ds"
If a key field is a string, you have a choice about how the value from one record is compared with the value from the next record. The default is that the comparison is case sensitive. If you specify the -ci options the comparison is case insensitive. In osh, specify the -key option with the command:
$osh "remdup -key Month -ci < inDS.ds > outDS.ds"
With this option specified, month values of JANUARY and January match, whereas without the case-insensitive option they do not match. For example, if your input data set is:
Month Apr apr apr May may Customer 59560 43455 59560 86111 86111 Balance 787.38 459.32 333.21 134.66 594.26
Thus the two April records for customer 59560 are not recognized as a duplicate pair because they are not adjacent to each other in the input. To remove all duplicate records regardless of the case of the Month field, use the following statement in osh:
$ osh "remdup -key Month -ci -key Customer < inDS.ds > outDS.ds"
216
This example removes all records in the same month except the first record. The output data set thus contains at most 12 records.
The results differ from those of the previous example if the Month field has mixed-case data values such as May and MAY. When the case-insensitive comparison option is used these values match and when it is not used they do not.
Chapter 7. Operators
217
Sample operator
The sample operator is useful when you are building, testing, or training data sets for use with the WebSphere DataStage data-modeling operators. The sample operator allows you to: v Create disjoint subsets of an input data set by randomly sampling the input data set to assign a percentage of records to output data sets. WebSphere DataStage uses a pseudo-random number generator to randomly select, or sample, the records of the input data set to determine the destination output data set of a record. You supply the initial seed of the random number generator. By changing the seed value, you can create different record distributions each time you sample a data set, and you can recreate a given distribution by using the same seed value. A record distribution is repeatable if you use the same: Seed value Number of output data sets Percentage of records assigned to each data set No input record is assigned to more than one output data set. The sum of the percentages of all records assigned to the output data sets must be less than or equal to 100% v Alternatively, you can specify that every nth record be written to output data set 0.
inRec:*;
sample
outRec:*;
outRec:*;
outRec:*;
Properties
Property Number of input data sets Number of output data sets Value 1 N (set by user)
218
Property Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator
Value inRec:* outRec:* inRec -> outRec without record modification parallel (default) or sequential any (parallel mode) any (sequential mode) propagated no
seed_val ]
Either the -percent option must be specified for each output data set or the -sample option must be specified.
Option maxoutputrows Use -maxoutputrows maxout Optionally specifies the maximum number of rows to be output per process. Supply an integer >= 1 for maxout. -percent -percent percent output_port_num Specifies the sampling percentage for each output data set. You specify the percentage as an integer value in the range of 0, corresponding to 0.0%, to 100, corresponding to 100.0%. The sum of the percentages specified for all output data sets cannot exceed 100.0%. The output_port_num following percent is the output data set number. The -percent and -sample options are mutually exclusive. One must be specified. -sample -sample sample Specifies that each nth record is written to output 0. Supply an integer >= 1 for sample to indicate the value for n. The -sample and -percent options are mutually exclusive. One must be specified.
Chapter 7. Operators
219
Option -seed
Use -seed seed_val Initializes the random number generator used by the operator to randomly sample the records of the input data set. seed_val must be a 32-bit integer. The operator uses a repeatable random number generator, meaning that the record distribution is repeatable if you use the same seed_val, number of output data sets, and percentage of records assigned to each data set.
InDS.ds
step
Sample
5.0%
10.0%
15.0%
In this example, you specify a seed value of 304452, a sampling percentage for each output data set, and three output data sets.
220
Sequence operator
Using the sequence operator, you can copy multiple input data sets to a single output data set. The sequence operator copies all records from the first input data set to the output data set, then all the records from the second input data set, and so forth. This operation is useful when you want to combine separate data sets into a single large data set. This chapter describes how to use the sequence operator. The sequence operator takes one or more data sets as input and copies all input records to a single output data set. The operator copies all records from the first input data set to the output data set, then all the records from the second input data set, etc. The record schema of all input data sets must be identical. You can execute the sequence operator either in parallel (the default) or sequentially. Sequential mode allows you to specify a collection method for an input data set to control how the data set partitions are combined by the operator. This operator differs from the funnel operator, described in Funnel Operators , in that the funnel operator does not guarantee the record order in the output data set.
sequence
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator Value N (set by user) 1 inRec:* outRec:* inRec -> outRec without record modification parallel (default) or sequential round robin (parallel mode) any (sequential mode) propagated no
Chapter 7. Operators
221
step A
step B
step C
outDS1.ds
outDS1.ds
outDS1.ds
step sequence
op1
The osh command for the step beginning with the sequence operator is:
$ osh "sequence < outDS0.ds < outDS1.ds < outDS2.ds | op1 ... rees
222
Switch operator
The switch operator takes a single data set as input. The input data set must have an integer field to be used as a selector, or a selector field whose values can be mapped, implicitly or explicitly, to int8. The switch operator assigns each input record to one of multiple output data sets based on the value of the selector field.
inRec:*;
switch
outRec:*;
outRec:*;
outRec:*;
data set N
The switch operator is analogous to a C switch statement, which causes the flow of control in a C program to branch to one of several cases based on the value of a selector variable, as shown in the following C program fragment.
switch (selector) { case 0: // if selector = 0, // write record to output data set 0 break; case 1: // if selector = 1, // write record to output data set 1 break; . . . case discard: // if selector = discard value // skip record break; case default:// if selector is invalid, // abort operator and end step };
You can attach up to 128 output data sets to the switch operator corresponding to 128 different values for the selector field. Note that the selector value for each record must be in or be mapped to the range 0 to N-1, where N is the number of data sets attached to the operator, or be equal to the discard value. Invalid selector values normally cause the switch operator to terminate and the step containing the operator to return an error. However, you may set an option that allows records whose selector field does not correspond to that range to be either dropped silently or treated as allowed rejects.
Chapter 7. Operators
223
You can set a discard value for the selector field. Records whose selector field contains or is mapped to the discard value is dropped, that is, not assigned to any output data set.
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Preserve-partitioning flag in output data set Value 1 1 <= N <= 128 selector field:any data type;inRec:* outRec:* propagated
If the selector field is of type integer and has no more than 128 values, there are no required options, otherwise you must specify a mapping using the -case option.
Option -allowRejects Use -allowRejects Rejected records (whose selector value is not in the range 0 to N-1, where N is the number of data sets attached to the operator, or equal to the discard value) are assigned to the last output data set. This option is mutually exclusive with the -ignoreRejects, -ifNotFound, and -hashSelector options.
224
Option -case
Use -case mapping Specifies the mapping between actual values of the selector field and the output data sets. mapping is a string of the form selector_value = output_ds , where output_ds is the number of the output data set to which records with that selector value should be written (output_ds can be implicit, as shown in the example below). You must specify an individual mapping for each value of the selector field you want to direct to one of the output data sets, thus -case is invoked as many times as necessary to specify the complete mapping. Multi-byte Unicode character data is supported for ustring selector values. Note: This option is incompatible with the -hashSelector option.
-collation_sequence
-collation_sequence locale |collation_file_pathname | OFF This option determines how your string data is sorted. You can: v Specify a predefined IBM ICU locale v Write your own collation sequence using ICU syntax, and supply its collation_file_pathname v Specify OFF so that string comparisons are made using Unicode code-point value order, independent of any locale or custom sequence. By default, WebSphere DataStage sorts strings using byte-wise comparisons. For more information, reference this IBM ICU site: http://oss.software.ibm.com/icu /userguide/Collate_Intro.htm
-discard
-discard discard_value Specifies an integer value of the selector field, or the value to which it was mapped using case, that causes a record to be discarded by the operator. Note that discard_value must be outside the range 0 to N-1, where N is the number of data sets attached to the operator. Note: This option is mutually exclusive with -hashSelector.
Chapter 7. Operators
225
Option -hashSelector
Use -hashSelector A boolean; when this is set, records are hashed on the selector field modulo the number of output data sets and assigned to an output data set accordingly. The selector field must be of a type that is convertible to uint32 and may not be nullable. Note: This option is incompatible with the -case, -discard, -allowRejects, -ignoreRejects, and -ifNotFound options.
-ifNotFound
-ifNotFound {allow | fail | ignore} Specifies what the operator should do if a data set corresponding to the selector value does not exist: allow Rejected records (whose selector value is not in the range 0 to N-1 or equal to the discard value) are assigned to the last output data set. If this optionvalue is used, you may not explicitly assign records to the last data set. fail When an invalid selector value is found, return an error and terminate. This is the default. ignore Drop the record containing the out-of-range value and continue. Note. This option is incompatible with -allowRejects, -ignoreRejects, and -hashSelector options.
-ignoreRejects
-ignoreRejects Drop the record containing the out-of-range value and continue. Note. This option is mutually exclusive with the -allowRejects, -ifNotFound, and -hashSelector options.
-key
-key field_name [-cs | -ci] Specifies the name of a field to be used as the selector field. The default field name is selector. This field can be of any data type that can be converted to int8, or any non-nullable type if case options are specified. Field names can contain multi-byte Unicode characters. Use the -ci flag to specify that field_name is case-insensitive. The -cs flag specifies that field_name is treated as case sensitive, which is the default.
In this example, you create a switch operator and attach three output data sets numbered 0 through 2. The switch operator assigns input records to each output data set based on the selector field, whose year values have been mapped to the numbers 0 or 1 by means of the -case option. A selector field value that maps to an integer other than 0 or 1 causes the operator to write the record to the last data set. You may not explicitly assign input records to the last data set if the -ifNotFound option is set to allow. With these settings, records whose year field has the value 1990, 1991, or 1992 go to outDS0.ds. Those whose year value is 1993 or 1994 go to outDS1.ds. Those whose year is 1995 are discarded. Those with
226
any other year value are written to outDS2.ds, since rejects are allowed by the -ifNotFound setting. Note that because the -ifNotFound option is set to allow rejects, switch does not let you map any year value explicitly to the last data set (outDS2.ds), as that is where rejected records are written. Note also that it was unnecessary to specify an output data set for 1991 or 1992, since without an explicit mapping indicated, case maps values across the output data sets, starting from the first (outDS0.ds). You may map more than one selector field value to a given output data set. The operator also verifies that if a -case entry maps a selector field value to a number outside the range 0 to N-1, that number corresponds to the value of the -discard option.
InDS.ds
schema: income:int32; year:string; name:string; state:string;
step
selector = year; selector:type; inRec:*;
switch
outRec:*; outRec:*; outRec:*;
Chapter 7. Operators
227
-key year < inDS.ds > outDS0.ds > outDS1.ds > outDS2.ds "
Note that by default output data sets are numbered starting from 0. You could also include explicit data set numbers, as shown below:
$ osh "switch -discard 3 < inDS.ds 0> outDS0.ds 1> outDS1.ds 2> outDS2.ds "
The output summary per criterion is included in the summary messages generated by WebSphere DataStage as custom information. It is identified with:
name="CriterionSummary"
The XML tags criterion, case and where are used by the switch operator when generating business logic and criterion summary custom information. These tags are used in the example information below.
228
Tail operator
The tail operator copies the last N records from each partition of its input data set to its output data set. By default, N is 10 records. However, you can determine the following by means of options: v The number of records to copy v The partition from which the records are copied This control is helpful in testing and debugging jobs with large data sets. The head operator performs a similar operation, copying the first N records from each partition. See Head Operator .
inRec:*;
tail
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Value 1 1 inRec:* outRec:* inRec -> outRec without record modification
Chapter 7. Operators
229
0 9 18 19 23 9 18 19 23 25 36 37 40 25 36 37 40 47 51 47 51
3 5 11 12 13 16 17 35 42 14 15 16 17 46 49 50 53 35 42 46 49 57 59 50 53 57 59
230
Transform operator
The transform operator modifies your input records, or transfers them unchanged, guided by the logic of the transformation expression you supply. You build transformation expressions using the Transformation Language, which is the language that defines expression syntax and provides built-in functions. By using the Transformation Language with the transform operator, you can: v Transfer input records to one or more outputs v Define output fields and assign values to them based on your job logic v Use local variables and input and output fields to perform arithmetic operations, make function calls, and construct conditional statements v Control record processing behavior by explicitly calling writerecord dataset_number, droprecord, and rejectrecord as part of a conditional statement
filesetN
table0.ds
tableN.ds
transform
Properties
Property Number of input data sets Number of output data sets Transfer behavior Execution mode Value 1 plus the number of lookup tables specified on the command line. 1 or more and, optionally, 1 or more reject data sets See Transfer Behavior parallel by default, or sequential
Chapter 7. Operators
231
Property Partitioning method Collection method Preserve-partitioning flag in output data set Composite operator Combinable operator
Value any (parallel mode) any (sequential mode) propagated yes yes
part_key_options are:
[-ci | -cs] [-param params ]
flag_compilation_options are:
[-dir dir_name_for_compilation ] [-name library_path_name ] [-optimize | -debug] [-verbose] [-compiler cpath ] [-staticobj absolute_path_name ] [-sharedobj absolute_path_name ] [compileopt options] [-linker lpath] [-linkopt options ]
[-t
options ]
The -table and -fileset options allow you to use conditional lookups. Note: The following option values can contain multi-byte Unicode values: v the field names given to the -inputschema and -outputschema options and the ustring values v -inputschemafile and -outputschemafile files v -expression option string and the -expressionfile option filepath v -sort and -part key-field names v -compiler, -linker, and -dir pathnames v -name file name
232
Chapter 7. Operators
233
Option -flag
Use -flag {compile | run | compileAndRun} suboptions compile: This option indicates that you wish to check the Transformation Language expression for correctness, and compile it. An appropriate version of a C++ compiler must be installed on your computer. Field information used in the expression must be known at compile time; therefore, input and output schema must be specified. run: This option indicates that you wish to use a pre-compiled version of the Transformation Language code. You do not need to specify input and output schemas or an expression because these elements have been supplied at compile time. However, you must add the directory containing the pre-compiled library to your library search path. This is not done by the transform operator.You must also use the -name suboption to provide the name of the library where the pre-compiled code resides. compileAndRun: This option indicates that you wish to compile and run the Transformation Language expression. This is the default value. An appropriate version of a C++ compiler must be installed on your computer. You can supply schema information in the following ways: v You can omit all schema specifications. The transform operator then uses the up-stream operators output schema as its input schema, and the schema for each output data set contains all the fields from the input record plus any new fields you create for a data set. v You can omit the input data set schema, but specify schemas for all output data sets or for selected data sets. The transform operator then uses the up-stream operators output schema as its input schema. Any output schemas specified on the command line are used unchanged, and output data sets without schemas contain all the fields from the input record plus any new fields you create for a data set. v You can specify an input schema, but omit all output schemas or omit some output schemas. The transform operator then uses the input schema as specified. Any output schemas specified on the command line are used unchanged, and output data sets without schemas contain all the fields from the input record plus any new fields you create for a data set.
234
Use v The flag option has the following suboptions: -dir dir_name lets you specify a compilation directory. By default, compilation occurs in the TMPDIR directory or, if this environment variable does not point to an existing directory, to the /tmp directory. Whether you specify it or not, you must make sure the directory for compilation is in the library search path. -name file_name lets you specify the name of the file containing the compiled code. If you use the -dir dir_name suboption, this file is in the dir_name directory. v The following examples show how to use the -dir and -name options in an osh command line: For development: osh transform -inputschema schema -outputschema schema -expression expression -flag compile - dir dir_name -name file_name For your production machine: osh ... | transform -flag run -name file_name | ... The library file must be copied to the production machine. -flag compile and -flag compileAndRun have these additional suboptions: -optimize specifies the optimize mode for compilation. -debug specifies the debug mode for compilation. v -verbose causes verbose messages to be output during compilation. -compiler cpath lets you specify the compiler path when the compiler is not in the default directory. The default compiler path for each operating system is: Solaris: /opt/SUNPRO6/SUNWspro/bin/CC AIX: /usr/vacpp/bin/xlC_r Tru64: /bin/cxx HP-UX: /opt/aCC/bin/aCC -staticobj absolute_path_name -sharedobj absolute_path_name These two suboptions specify the location of your static and dynamic-linking C-object libraries. The file suffix can be omitted. See External Global C-Function Support for details. -compileopt options lets you specify additional compiler options. These options are compiler-dependent. Pathnames may contain multi-byte Unicode characters. -linker lpath lets you specify the linker path when the linker is not in the default directory. The default linker path of each operating system is the same as the default compiler path listed above. -linkopt options lets you specify link options to the compiler. Pathnames may contain multi-byte Unicode characters.
Chapter 7. Operators
235
Option -inputschema
Use -inputschema schema Use this option to specify an input schema. The schema may contain multi-byte Unicode characters. An error occurs if an expression refers to an input field not in the input schema. The -inputschema and the -inputschemafile options are mutually exclusive. The -inputschema option is not required when you specify compileAndRun or run for the -flag option; however, when you specify compile for the -flag option, you must include either the -inputschema or the -inputschemafile option. See the -flag option description in this table for information on the -compile suboption.
-inputschemafile
-inputschemafile schema_file Use this option to specify an input schema. An error occurs if an expression refers to an input field not in the input schema. To use this option, the input schema must reside in a schema_file, where schema_file is the name and path to the file which may contain multi-byte Unicode characters. You can use an absolute path, or by default the current UNIX directory. The -inputschemafile and the -inputschema options are mutually exclusive. The -inputschemafile option is not required when you specify compileAndRun or run for the -flag option; however, when you specify compile for the -flag option, you must include either the -inputschema or the -inputschemafile option. See the -flag option description in this table for information on the -compile suboption.
-maxrejectlogs
-maxrejectlogs integer An information log is generated every time a record is written to the reject output data set. Use this option to specify the maximum number of output reject logs the transform option generates. The default is 50. When you specify -1 to this option, an unlimited number of information logs are generated.
236
Option -outputschema
Use -outputschema schema Use this option to specify an output schema. An error occurs if an expression refers to an output field not in the output schema. The -outputschema and -outputschemafile options are mutually exclusive. The -outputschema option is not required when you specify compileAndRun or run for the -flag option; however, when you specify compile for the -flag option, you must include either the -outputschema or the -outputschemafile option. See the -flag option description in this table for information on the -compile suboption. For multiple output data sets, repeat the -outputschema or -outputschemafile option to specify the schema for all output data sets.
-outputschemafile
-outputschemafile schema_file Use this option to specify an output schema. An error occurs if an expression refers to an output field not in the output schema. To use this option, the output schema must reside in a schema_file which includes the name and path to the file. You can use an absolute path, or by default the current UNIX directory. The -outputschemafile and the -outputschema options are mutually exclusive. The -outputschemafile option is not required when you specify compileAndRun or run for the -flag option; however, when you specify compile for the -flag option, you must include either the -outputschema or the -outputschemafile option. See the -flag option description in this table for information on the -compile suboption. For multiple output data sets, repeat the -outputschema or -outputschemafile option to specify the schema for all output data sets.
-part
-part {-input | -output[ port ]} -key field_name [-ci | -cs] [-param params ] You can use this option 0 or more times. It indicates that the data is hash partitioned. The required field_name is the name of a partitioning key. Exactly one of the suboptions -input and -output[ port ] must be present. These suboptions determine whether partitioning occurs on the input data or the output data. The default for port is 0. If port is specified, it must be an integer which represents an output data set where the data is partitioned. The suboptions to the -key option are -ci for case-insensitive partitioning, or -cs for a case-sensitive partitioning. The default is case-sensitive. The -params suboption is to specify any property=value pairs. Separate the pairs by commas (,).
Chapter 7. Operators
237
Option -reject
Use -reject [-rejectinfo reject_info_column_name_string] This is optional. You can use it only once. When a null field is used in an expression, this option specifies that the input record containing the field is not dropped, but is sent to the output reject data set. The -rejectinfo suboption specifies the column name for the reject information.
-sort
-sort {-input | -output [ port ]} -key field_name [-ci | -cs] [-asc | -desc] [-nulls {first | last}] [-param params ] You can use this option 0 or more times. It indicates that the data is sorted for each partition. The required field_name is the name of a sorting key. Exactly one of the suboptions -input and -output[ port ] must be present. These suboptions determine whether sorting occurs on the input data or the output data. The default for port is 0. If port is specified, it must be an integer that represents the output data set where the data is sorted. You can specify -ci for a case-insensitive sort, or -cs for a case-sensitive sort. The default is case-sensitive. You can specify -asc for an ascending order sort or -desc for a descending order sort. The default is ascending. You can specify -nulls {first | last} to determine where null values should sort. The default is that nulls sort first. You can use -param params to specify any property = value pairs. Separate the pairs by commas (,).
238
Option -table
Use -table -key field [ci | cs] [-key field [ci | cs] ...] [-allow_dups] [-save fileset_descriptor] [-diskpool pool] [-schema schema | -schemafile schema_file] Specifies the beginning of a list of key fields and other specifications for a lookup table. The first occurrence of -table marks the beginning of the key field list for lookup table1; the next occurrence of -table marks the beginning of the key fields for lookup table2, etc. For example: lookup -table -key field -table -key field The -key option specifies the name of a lookup key field. The -key option must be repeated if there are multiple key fields. You must specify at least one key for each table. You cannot use a vector, subrecord, or tagged aggregate field as a lookup key. The -ci suboption specifies that the string comparison of lookup key values is to be case insensitive; the -cs option specifies case-sensitive comparison, which is the default. In create-only mode, the -allow_dups option causes the operator to save multiple copies of duplicate records in the lookup table without issuing a warning. Two lookup records are duplicates when all lookup key fields have the same value in the two records. If you do not specify this option, WebSphere DataStage issues a warning message when it encounters duplicate records and discards all but the first of the matching records. In normal lookup mode, only one lookup table (specified by either -table or -fileset) can have been created with -allow_dups set. The -save option lets you specify the name of a fileset to write this lookup table to; if -save is omitted, tables are written as scratch files and deleted at the end of the lookup. In create-only mode, -save is, of course, required. The -diskpool option lets you specify a disk pool in which to create lookup tables. By default, the operator looks first for a lookup disk pool, then uses the default pool (). Use this option to specify a different disk pool to use. The -schema suboption specifies the schema that interprets the contents of the string or raw fields by converting them to another data type. The -schemafile suboption specifies the name of a file containing the schema that interprets the content of the string or raw fields by converting them to another data type. You must specify either -schema or -schemafile. One of them is required if the -compile option is set, but are not required for -compileAndRun or -run.
Chapter 7. Operators
239
Option -fileset
Use [-fileset fileset_descriptor ...] Specify the name of a fileset containing one or more lookup tables to be matched. In lookup mode, you must specify either the -fileset option, or a table specification, or both, in order to designate the lookup table(s) to be matched against. There can be zero or more occurrences of the -fileset option. It cannot be specified in create-only mode. Warning: The fileset already contains key specifications. When you follow -fileset fileset_descriptor by key_specifications , the keys specified do not apply to the fileset; rather, they apply to the first lookup table. For example, lookup -fileset file -key field, is the same as: lookup -fileset file1 -table -key field
Transfer behavior
You can transfer your input fields to your output fields using any one of the following methods: v Set the value of the -flag option to compileAndRun. For example:
osh "... | transform -expression expression -flacompileAndRun -dir dir_name -name file_name | ..."
v Use schema variables as part of the schema specification. A partial schema may be used for both the input and output schemas. This example shows a partial schema in the output:
osh "transform -expression expression -inputschema record(a:int32;b:string[5];c:time) -outputschema record(d:dfloat:outRec:*;) -flag compile ..."
This example shows partial schemas in the input and the output:
osh "transform -expression expression -inputschema record(a:int32;b:string[5];c:time;Inrec:*) -outputschema record(d:dfloat:outRec:*;) -flag compile ..." osh "... | transform -flag run ... | ..."
Output 0 contains the fields d, a, b, and c, plus any fields propagated from the up-stream operator. v Use name matching between input and output fields in the schema specification. When input and output field names match and no assignment is made to the output field, the input field is transferred to the output data set unchanged. Any input field which doesnt have a corresponding output field is dropped. For example:
osh "transform -expression expression -inputschema record(a:int32;b:string[5];c:time) -outputschema record(a:int32;) -outputschema record(a:int32;b:string[5];c:time) -flag compile ..."
240
Field a is transferred from input to output 0 and output 1. Fields b and c are dropped in output 0, but are transferred from input to output 1. v Specify a reject data set. In the Transformation Language, it is generally illegal to use a null field in expressions except in the following cases: In function calls to notnull(field_name) and null(fieldname) In an assignment statement of the form a=b where a and b are both nullable and b is null In these expressions:
if (null(a)) b=a else b=a+1 if (notnull(a)) b=a+1 else b=a b=null (a)?a:a +1; b=notnull(a)?a+1:a;
If a null field is used in an expression in other than these cases and a reject set is specified, the whole input record is transferred to the reject data set.
General structure
As in C, statements must be terminated by semi-colons and compound statements must be grouped by braces. Both C and C++ style comments are allowed.
241
// externs this C function: int my_times(int x, int y) { ... } extern int32 my_times(int32 x, int32 y); // externs this C function: void my_print_message(char *msg) { ... } extern void my_print_message(string msg); inputname 0 in0; outputname 0 out0; mainloop { ... }
The shared object file name has lib prepended to it and and has a platform-dependent object-file suffix: .so for Sun Solaris and Linux; .sl for HP-UX, and .o for AIX. The file must reside in this directory:
/external-functions/dynamic
242
/external-functions/dynamic/libgenerate.so
Dynamically-linked libraries must be manually deployed to all running nodes. Add the library-file locations to your library search path. See Example 8: External C Function Calls for an example job that includes C header and source files, a Transformation Language expression file with calls to external C functions, and an osh script.
243
The name of any field in the lookup schema, other than key fields, can be used to access the field value, such as table1.field1. If a field is accessed when is_match() returns false, the value of the field is null if it is nullable or it has its default value. Here is an example of lookup table usage:
transform -expressionfile trx1 -table -key a -fileset sKeyTable.fs < dataset.v < table.v > target.v trx1: inputname 0 in1; outputname 0 out0; tablename 0 tbl1; tablename 1 sKeyTable; mainloop { // This code demonstrates the interface without doing anything really // useful int nullCount; nullCount = 0; lookup(sKeyTable); if (is_match(sKeyTable)) // if theres no match { lookup(tbl1); if (!is_match(tbl1)) { out0.field2 = "missing"; } } else { // Loop through the results while (is_match(sKeyTable)) { if (is_null(sKeyTable.field1)) { nullCount++; } next_match(sKeyTable); } } writerecord 0; }
Because the transform operator accepts only a single input data set, the data set number for inputname is 0. You can specify 0 through (the number of output data sets - 1) for the outputname data set number. For example:
inputname 0 input-grades; outputname 0 output-low-grades; outputname 1 output-high-grades;
Data set numbers cannot be used to qualify field names. You must use the inputname and outputname data set names to qualify field names in your Transformation Language expressions. For example:
output-low-grades.field-a = input-grades.field-a + 10; output-high-grades.field-a = output-low-grades.field-a - 10;
Field names that are not qualified by a data set name always default to output data set 0. It is good practice to use the inputname data set name to qualify input fields in expressions, and use the
244
outputname data set name to qualify output fields even though these fields have unique names among all data sets. The Transformation Language does not attempt to determine if an unqualified, but unique, name exists in another data set. The inputname and outputname statements must appear first in your Transformation Language code.For an example, see the Transformation Language section of Example 2: Student-Score Distribution With a Letter Grade Added to Example 1 .
floating Point
string
decimal[p, s]
Chapter 7. Operators
245
Forms date time time[microseconds] timestamp timestamp[microseconds] raw raw[max=n] raw[n] raw[align=k] raw[max=n, align=k]
Meaning Date with year, month, and day Time with one second resolution Time with one microsecond resolution Date/time with one second resolution Date/time with one microsecond resolution Variable length binary data. Variable length binary data with at most n bytes. Fixed length (n-byte) binary data. Variable length binary data, aligned on k-byte boundary (k = 1, 2, 4, or 8). Variable length binary data with at most n bytes, aligned on k-byte boundary (k = 1, 2, 4, or 8) Fixed length (n-byte) binary data, aligned on k-byte boundary (k = 1, 2, 4, or 8)
raw
raw[n, align=k]
WebSphere DataStage supports the following complex field types: v vector fields v subrecord fields v tagged fields. Note: Tagged fields cannot be used in expressions; they can only be transferred from input to output.
Local variables
Local variables are used for storage apart from input and output records. You must declare and initialize them before use within your transformation expressions. The scope of local variables differs depending on which code segment defines them: v Local variables defined within the global and initialize code segments can be accessed before, during, and after record processing. v Local variables defined in the mainloop code segment are only accessible for the current record being processed. v Local variables defined in the finish code segment are only accessible after all records have been processed. v Local variables can represent any of the simple value types: int8, uint8, int16, uint16, int32, uint32, int64, uint64 sfloat, dfloat decimal string date, time, timestamp raw
246
Declarations are similar to C, as in the following examples: v int32 a[100]; declares a to be an array of 100 32-bit integers v dfloat b; declares b to be an double-precision float v string c; declares c to be a variable-length string v string[n] e; declares e to be a string of length n v string[n] f[m]; declares f to be an array of m strings, each of length n v decimal[p] g; declares g to be a decimal value with p (precision) digits v decimal[p, s] h; declares h to be a decimal value with p (precision) digits and s (scale) digits to the right of the decimal You cannot initialize variables as part of the declaration. They can only be initialized on a separate line. For example:
int32 a; a = 0;
The result is uncertain if a local variable is used without being initialized. There are no local variable pointers or structures, but you can use arrays.
Expressions
The Transformation Language supports standard C expressions, with the usual operator precedence and use of parentheses for grouping. It also supports field names as described in Data types and record fields , where the field name is specified in the schema for the data set.
Language elements
The Transformation Language supports the following elements: v Integer, character, floating point, and string constants v v v v v v v v Local variables Field names Arithmetic operators Function calls Flow control Record processing control Code segmentation Data set name specification
operators
The Transformation Language supports several unary operators, which all apply only to simple value types.
Symbol ~ Name Ones complement Applies to Integer Comments ~a returns an integer with the value of each bit reversed !a returns 1 if a is 0; otherwise returns 0 +a returns a
Chapter 7. Operators
! +
Integer Numeric
247
Symbol ++ --
Comments -a returns the negative of a a++ or ++a returns a + 1 a-- or --a returns a - 1.
The Transformation Language supports a number of binary operators, and one ternary operator.
Symbol + * / % Name Addition Subtraction Multiplication Division Modulo Applies to Numeric Numeric Numeric Numeric Integers a % b returns the remainder when a is divided by b a << b returns a left-shifted b-bit positions a >> b returns a right-shifted b-bit positions a == b returns 1 (true) if a equals b and 0 (false) otherwise. a < b returns 1 if a is less than b and 0 otherwise. (See the note below the table.) a > b returns 1 if a is greater than b and 0 otherwise. (See the note below the table.) a <= b returns 1 if a < b or a == b, and 0 otherwise. (See the note below the table.) a >= b returns 1 if a > b or a == b, and 0 otherwise. (See the note below the table.) a != b returns 1 if a is not equal to b, and 0 otherwise. a ^ b returns an integer with bit value 1 in each bit position where the bit values of a and b differ, and a bit value of 0 otherwise. Comments
<< >> ==
Integer Integer Any; a and b must be numeric or of the same data type Same as ==.
<
Less than
>
Greater than
Same as ==
<=
Same as ==
>=
Same as ==
!= ^
Same as == Integer
248
Symbol &
Applies to Integer
Comments a & b returns an integer with bit value 0 in each bit position where the bit values of a and b are both 1, and a bit value of 0 otherwise. a | b returns an integer with a bit value 1 in each bit position where the bit value a or b (or both) is 1, and 0 otherwise. a && b returns 0 if either a == 0 or b == 0 (or both), and 1otherwise. a || b returns 1 if either a != 0 or b != 0 (or both), and 0 otherwise. a + b returns the string consisting of substring a followed by substring b. The ternary operator lets you write a conditional expression without using the if...else keyword. a ? b : c returns the value of b if a is true (non-zero) and the value of c if a is false.
Bitwise (inclusive) OR
Integer
&&
Logical AND
Any; a and b must be numeric or of the same data type Any; a and b must be numeric or of the same data type String
||
Logical OR
Concatenation
?:
Assignment
Any scalar; a and b must be numeric, numeric strings, or of the same data type
a = b places the value of b into a. Also, you can use = to do default conversions among integers, floats, decimals, and numeric strings.
Note: For the <, >, <=, and >= operators, if a and b are strings, lexicographic order is used. If a and b are date, time, or timestamp, temporal order is used. The expression a * b * c evaluates as (a * b) * c. We describe this by saying that multiplication has left to right associativity. The expression a + b * c evaluates as a + (b * c). We describe this by saying multiplication has higher precedence than addition. The following table describes the precedence and associativity of the Transformation Language operators. Operators listed in the same row of the table have the same precedence, and you use parentheses to force a particular order of evaluation. Operators in a higher row have a higher order of precedence than operators in a lower row.
Table 10. Precedence and Associativity of Operators Operators () [] ! ~ ++ -- + - (unary) * / % + - (binary) Associativity left to right right to left left to right left to right
Chapter 7. Operators
249
Table 10. Precedence and Associativity of Operators (continued) Operators << >> < <= > >= == != & ^ | && || : ? = Associativity left to right left to right left to right left to right left to right left to right left to right left to right for || right to left for : right to left right to left
Conditional Branching
The Transformation Language provides facilities for conditional branching. The following sections describe constructs available for conditional branching. if ... else
if (expression) statement1 else statement2;
If expression evaluates to a non-zero value (true) then statement1 is executed. If expression evaluates to 0 (false) then statement2 is executed. Both statement1 and statement2 can be compound statements. You can omit else statement2. In that case, if expression evaluates to 0 the if statement has no effect. Sample usage:
if (a < b) abs_difference = b - a; else abs_difference = a - b;
The order of execution is: 1. expression1. It is evaluated only once to initialize the loop variable. 2. expression2. If it evaluates to false, the loop terminates; otherwise, these expressions are executed in order:
statement expression3
250
This code sets sum to the sum of the first n integers and sum_squares to the sum of the squares of the first n integers. While Loop
while ( expression ) statement ;
In a while loop, statement, which may be a compound statement, is executed repeatedly as long as expression evaluates to true. A sample usage is:
sum = 0; i = 0; while ((a[i] >= 0) && (i < n)) { sum = sum + a[i]; i++; }
This evaluates the sum of the array elements a[0] through a[n-1], or until a negative array element is encountered. Break The break command causes a for or while loop to exit immediately. For example, the following code does the same thing as the while loop shown immediately above:
sum = 0; for (i = 0; i < n; i++) { if (a[i] >= 0) sum = sum + a[i]; else break; }
Continue The continue command is related to the break command, but used less often. It causes control to jump to the top of the loop. In the while loop, the test part is executed immediately. In a for loop, control passes to the increment step. If you want to sum all positive array entries in the array a[n], you can use the continue statement as follows:
sum = 0; for (i = 0; i < n; i++) { if (a[i] <= 0) continue; sum = sum + a[i]; }
This example could easily be written using an else statement rather than a continue statement. The continue statement is most useful when the part of the loop that follows is complicated, to avoid nesting the program too deeply.
Built-in functions
This section defines functions that are provided by the Transformation Language. It is presented in a series of tables that deal with data transformation functions of the following types:
Chapter 7. Operators
251
v v v v v v v
Lookup table functions Data conversion functions Mathematical functions String field functions Ustring field functions Bit manipulation functions Job monitoring functions
v Miscellaneous functions When a function generates an output value, it returns the result. For functions with optional arguments, simply omit the optional argument to accept the default value. Default conversions among integer, float, decimal, and numeric string types are supported in the input arguments and the return value of the function. All integers can be signed or unsigned. The transform operator has default NULL handling at the record-level with individual field overrides. Options can be entered at the record level or the field level.
252
The default format of the date contained in the string is yyyy-mm-dd. However, you can specify an optional format string that defines another format. The format string requires that you provide enough information for WebSphere DataStage to determine a complete date (either day, month, and year, or year and day of year). The format_string can contain one or a combination of the following elements:
Table 11. Date format tags Tag %d %dd %ddd %m %mm %mmm %mmmm %yy %yyyy %NNNNyy %e %E %eee %eeee %W %WW import/export import import/export with v option import Variable width availability import Description Day of month, variable width Day of month, fixed width Day of year Month of year, variable width Month of year, fixed width Month of year, short name, locale specific Month of year, full name, locale specific Year of century Four digit year Cutoff year plus year of century Day of week, Sunday = day 1 Day of week, Monday = day 1 Value range 1...31 01...31 1...366 1...12 01...12 Jan, Feb ... January, February ... 00...99 0001 ...9999 yy = 00...99 1...7 1...7 t, u, w t, u, w, -N, +N s s s Options s s s, v s s t, u, w t, u, w, -N, +N s
Weekday short name, Sun, Mon ... locale specific Weekday long name, locale specific Week of year (ISO 8601, Mon) Week of year (ISO 8601, Mon) Sunday, Monday ... 1...53 01...53
When you specify a date format string, prefix each component with the percent symbol (%) and separate the strings components with a suitable literal character. The default date_format is %yyyy-%mm-%dd. Where indicated the tags can represent variable-width data elements. Variable-width date elements can omit leading zeroes without causing errors. The following options can be used in the format string where indicated in the table: s Specify this option to allow leading spaces in date formats. The s option is specified in the form:
Chapter 7. Operators
253
%(tag,s) Where tag is the format string. For example: %(m,s) indicates a numeric month of year field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property: %(d,s)/%(m,s)/%yyyy Then the following dates would all be valid: 8/ 8/1958 08/08/1958 8/8/1958 v Use this option in conjunction with the %ddd tag to represent day of year in variable-width format. So the following date property: %(ddd,v) represents values in the range 1 to 366. (If you omit the v option then the range of values would be 001 to 366.) u w t Use this option to render uppercase text on output. Use this option to render lowercase text on output. Use this option to render titlecase text (initial capitals) on output.
The u, w, and t options are mutually exclusive. They affect how text is formatted for output. Input dates will still be correctly interpreted regardless of case. -N +N Specify this option to left justify long day or month names so that the other elements in the date will be aligned. Specify this option to right justify long day or month names so that the other elements in the date will be aligned.
Names are left justified or right justified within a fixed width field of N characters (where N is between 1 and 99). Names will be truncated if necessary. The following are examples of justification in use: %dd-%(mmmm,-5)-%yyyyy
21-Augus-2006
%dd-%(mmmm,-10)-%yyyyy
21-August -2005
%dd-%(mmmm,+10)-%yyyyy
21August-2005
The locale for determining the setting of the day and month names can be controlled through the locale tag. This has the format:
%(L,locale)
Where locale specifies the locale to be set using the language_COUNTRY.variant naming convention supported by ICU. See NLS Guide for a list of locales. The default locale for month names and weekday names markers is English unless overridden by a %L tag or the APT_IMPEXP_LOCALE environment variable (the tag takes precedence over the environment variable if both are set).
254
Use the locale tag in conjunction with your time format, for example the format string: %(L,es)%eeee, %dd %mmmm %yyyy Specifies the Spanish locale and would result in a date withe the following format: mircoles, 21 septembre 2005 The format string is subject to the restrictions laid out in the following table. A format string can contain at most one tag from each row. In addition some rows are mutually incompatible, as indicated in the incompatible with column. When some tags are used the format string requires that other tags are present too, as indicated in the requires column.
Table 12. Format tag restrictions Element year month Numeric format tags %yyyy, %yy, %[nnnn]yy %mm, %m Text format tags %mmm, %mmmm Requires year month year %eee, %eeee month, week of year year Incompatible with week of year day of week, week of year day of month, day of week, week of year day of year month, day of month, day of year
day of month %dd, %d day of year day of week week of year %ddd %e, %E %WW
When a numeric variable-width input tag such as %d or %m is used, the field to the immediate right of the tag (if any) in the format string cannot be either a numeric tag, or a literal substring that starts with a digit. For example, all of the following format strings are invalid because of this restriction: %d%m-%yyyy %d%mm-%yyyy %(d)%(mm)-%yyyy %h00 hours The year_cutoff is the year defining the beginning of the century in which all two-digit years fall. By default, the year cutoff is 1900; therefore, a two-digit year of 97 represents 1997. You can specify any four-digit year as the year cutoff. All two-digit years then specify the next possible year ending in the specified two digits that is the same or greater than the cutoff. For example, if you set the year cutoff to 1930, the two-digit year 30 corresponds to 1930, and the two-digit year 29 corresponds to 2029. On import and export, the year_cutoff is the base year. This property is mutually exclusive with days_since, text, and julian. You can include literal text in your date format. Any Unicode character other than null, backslash, or the percent sign can be used (although it is better to avoid control codes and other non-graphic characters). The following table lists special tags and escape sequences:
Chapter 7. Operators
255
Tag %% \% \n \t \\
Escape sequence literal percent sign literal percent sign newline horizontal tab single backslash
date Uformat The date uformat provides support for international components in date fields. Its syntax is:
String%macroString%macroString%macroString
where %macro is a date formatting macro such as %mmm for a 3-character English month. Only the String components of date uformat can include multi-byte Unicode characters. Note: Any argument that has to be double quoted cannot be a field name or a local variable. An argument must have the data format of its type.
Function date date_from_days_since ( int32 , date | format_variable ) Description Returns date by adding the given integer to the baseline date. Converts an integer field into a date by adding the integer to the specified base date. The date must be in the format yyyy-mm-dd and must be either double quoted or a variable. date date_from_julian_day( uint32 ) date date_from_string ( string , date_format | date_uformat | format_variable ) Returns the date given a Julian day. Returns a date from the given string formatted in the optional format specification. By default the string format is yyyy-mm-dd. For format descriptions, see and date Uformat . date date_from_ustring ( string , date_format | date_uformat | format_variable ) Returns a date from the given ustring formatted in the optional format specification. By default the ustring format is yyyy-mm-dd. For format descriptions, see and date Uformat . string string_from_date ( date , date_format | date_uformat ) Converts the date to a string representation using the given format specification. By default the ustring format is yyyy-mm-dd. For format descriptions, see and date Uformat . ustring ustring_from_date ( date , date_format | date_uformat ) Converts the date to a ustring representation using the given format specification. By default the ustring format is yyyy - mm -dd. For format descriptions, see and date Uformat . date date_from_timestamp( timestamp ) int32 days_since_from_date ( date , source_date | format_variable ) Returns the date from the given timestamp . Returns a value corresponding to the number of days from source_date to date . source_date must be in the form yyyy - mm -dd and must be double quoted or be a variable.
256
Function uint32 julian_day_from_date( date ) int8 month_day_from_date( date ) int8 month_from_date( date ) date next_weekday_from_date ( date , day | format_variable )
Description Returns a Julian date given the date . Returns the day of the month given the date . For example, the date 07-23-2001 returns 23. Returns the month from the given date . For example, the date 07-23-2001 returns 7. The value returned is the date of the specified day of the week soonest after date (including the date ). The day argument is optional. It is a string or variable specifying a day of the week. You can specify day by either the first three characters of the day name or the full day name. By default, the value is Sunday.
Returns the previous weekday date from date . The destination contains the closest date for the specified day of the week earlier than the source date (including the source date) The day argument is optional. It is a string or variable specifying a day of the week. You can specify day using either the first three characters of the day name or the full day name. By default, the value is Sunday.
Returns the day of the week from date . The optional argument origin_day is a string or variable specifying the day considered to be day zero of the week. You can specify the day using either the first three characters of the day name or the full day name. If omitted, Sunday is day zero. Returns the day of the year (1-366) from date . Returns the year from date . For example, the date 07-23-2001 returns 2001. Returns the week of the year from date . For example, the date 07-23-2001 returns 30.
decimal and float Field Functions You can do the following transformations using the decimal and float field functions. v Assign a decimal to an integer or float or numeric string, or compare a decimal to an integer or float or numeric string. v Specify an optional fix_zero argument (int8) to cause a decimal field containing all zeros to be treated as a valid zero. v Optionally specify a value for the rounding type (r_type) for many conversions. The values of r_type are: ceil: Round the source field toward positive infinity. This mode corresponds to the IEEE 754 Round Up mode. Examples: 1.4 -> 2, -1.6 -> -1 floor: Round the source field toward negative infinity. This mode corresponds to the IEEE 754 Round Down mode. Examples: 1.6 -> 1, -1.4 -> -2
Chapter 7. Operators
257
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. This mode corresponds to the COBOL ROUNDED mode. Examples: 1.4 -> 1, 1.5 -> 2, -1.4 -> -1, -1.5 -> -2 trunc_zero (default): Discard any fractional digits to the right of the right-most 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. This mode corresponds to the COBOL INTEGER-PART function. Examples: 1.6 -> 1, -1.6 -> -1
Function decimal decimal_from_decimal ( decimal , r_type | format_variable ) Description Returns decimal in decimal representation, changing the precision and scale according to the returned type. The rounding type, r_type, may be ceil, floor, round_inf, or trunc_zero as described above this table. The default rtype is trunc_zero. Returns dfloat in decimal representation. The rounding type, r_type , may be ceil, floor, round_inf, or trunc_zero as described above this table. The default is trunc_zero. Returns string in decimal representation. The rounding type, r_type , may be ceil, floor, round_inf, or trunc_zero as described above this table. The default is trunc_zero. Returns ustring in decimal representation. The rounding type, r_type , may be ceil, floor, round_inf, or trunc_zero as described above this table. The default is trunc_zero. Returns decimal in dfloat representation. Returns int32 in decimal representation. The rounding type, r_type , may be ceil, floor, round_inf, or trunc_zero as described above this table. The default is trunc_zero. Returns int64 in decimal representation. The rounding type, r_type , may be ceil, floor, round_inf, or trunc_zero as described above this table. The default is trunc_zero. Returns uint64 in decimal representation. The rounding type, r_type , may be ceil, floor, round_inf, or trunc_zero as described above this table. The default is trunc_zero. Returns string in decimal representation. fix_zero causes a decimal field containing all zeros to be treated as a valid zero. suppress_zero argument specifies that the returned ustring value will have no leading or trailing zeros. Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
decimal decimal_from_dfloat ( dfloat , r_type | format_variable ) decimal decimal_from_string ( string , r_type | format_variable ) decimal decimal_from_ustring ( ustring , r_type | format_variable ) dfloat dfloat_from_decimal ( decimal , fix-zero | format_variable ) int32 int32_from_decimal ( decimal , r_type fix_zero)
int64 int64_from_decimal ( decimal , r_type fix_zero) uint64 uint64_from_decimal ( decimal , r_type fix_zero)
258
Description Returns ustring in decimal representation. fix_zero causes a decimal field containing all zeros to be treated as a valid zero. suppress_zero argument specifies that the returned ustring value will have no leading or trailing zeros. Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
Returns ustring in decimal representation. fix_zero causes a decimal field containing all zeros to be treated as a valid zero. suppress_zero argument specifies that the returned ustring value will have no leading or trailing zeros. Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1
Returns the mantissa (the digits right of the decimal point) from dfloat . Returns the mantissa (the digits right of the decimal point) from decimal .
raw Field Functions Use the raw field functions to transform a string into a raw data type and to determine the length of a raw value.
Function raw raw_from_string( string ) raw u_raw_from_string( ustring ) int32 raw_length( raw ) Description Returns string in raw representation. Returns ustring in raw representation. Returns the length of the raw field.
259
The time uformat provides support for international components in time fields. Its syntax is:
String % macroString % macroString % macroString
where %macro is a time formatting macro such as %hh for a two-digit hour. See below for a description of the date format macros. Only the String components of time uformat can include multi-byte Unicode characters. timestamp Uformat This format is a concatenation of the date uformat and time uformat which are described in date Uformat and time Uformat. The order of the formats does not matter, but the two formats cannot be mixed. time Format The possible components of the time_format string are given in the following table:
Table 13. Time format tags Tag %h %hh %H %HH %n %nn %s %ss %s.N %ss.N %SSS %SSSSSS %aa with v option with v option German import import import import Variable width availability import Description Hour (24), variable width Hour (24), fixed width Hour (12), variable width Hour (12), fixed width Minutes, variable width Minutes, fixed width Seconds, variable width Seconds, fixed width Value range 0...23 0...23 1...12 01...12 0...59 0...59 0...59 0...59 Options s s s s s s s s s, c, C s, c, C s, v s, v u, w
Seconds + fraction (N = 0...6) Seconds + fraction (N = 0...6) Milliseconds Microseconds am/pm marker, locale specific 0...999 0...999999 am, pm
By default, the format of the time contained in the string is %hh:%nn:%ss. However, you can specify a format string defining the format of the string field. You must prefix each component of the format string with the percent symbol. Separate the strings components with any character except the percent sign (%). Where indicated the tags can represent variable-fields on import, export, or both. Variable-width date elements can omit leading zeroes without causing errors.
260
The following options can be used in the format string where indicated: s Specify this option to allow leading spaces in time formats. The s option is specified in the form: %(tag,s) Where tag is the format string. For example: %(n,s) indicates a minute field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property: %(h,s):$(n,s):$(s,s) Then the following times would all be valid: 20: 6:58 20:06:58 20:6:58 v Use this option in conjunction with the %SSS or %SSSSSS tags to represent milliseconds or microseconds in variable-width format. So the time property: %(SSS,v) represents values in the range 0 to 999. (If you omit the v option then the range of values would be 000 to 999.) u w c C Use this option to render the am/pm text in uppercase on output. Use this option to render the am/pm text in lowercase on output. Specify this option to use a comma as the decimal separator in the %ss.N tag. Specify this option to use a period as the decimal separator in the %ss.N tag.
The c and C options override the default setting of the locale. The locale for determining the setting of the am/pm string and the default decimal separator can be controlled through the locale tag. This has the format:
%(L,locale)
Where locale specifies the locale to be set using the language_COUNTRY.variant naming convention supported by ICU. See NLS Guide for a list of locales. The default locale for am/pm string and separators markers is English unless overridden by a %L tag or the APT_IMPEXP_LOCALE environment variable (the tag takes precedence over the environment variable if both are set). Use the locale tag in conjunction with your time format, for example: %L(es)%HH:%nn %aa Specifies the Spanish locale. The format string is subject to the restrictions laid out in the following table. A format string can contain at most one tag from each row. In addition some rows are mutually incompatible, as indicated in the incompatible with column. When some tags are used the format string requires that other tags are present too, as indicated in the requires column.
Table 14. Format tag restrictions Element hour Numeric format tags %hh, %h, %HH, %H Text format tags Requires Incompatible with Chapter 7. Operators
261
Table 14. Format tag restrictions (continued) Element am/pm marker minute second fraction of a second Numeric format tags %nn, %n %ss, %s %ss.N, %s.N, %SSS, %SSSSSS Text format tags %aa Requires hour (%HH) Incompatible with hour (%hh) -
You can include literal text in your date format. Any Unicode character other than null, backslash, or the percent sign can be used (although it is better to avoid control codes and other non-graphic characters). The following table lists special tags and escape sequences:
Tag %% \% \n \t \\ Escape sequence literal percent sign literal percent sign newline horizontal tab single backslash
Function int8 hours_from_time( time ) int32 microseconds_from_time( time ) dfloat midnight_seconds_from_time ( time ) int8 minutes_from_time( time ) dfloat seconds_from_time( time ) dfloat seconds_since_from_timestamp ( timestamp , source_timestamp_string | format_variable )
Description Returns the hour portion of the given time. Returns the number of microseconds from the given time. Returns the number of seconds from midnight to time . Returns the number of minutes from time . Returns the number of seconds from time. Returns the number of seconds from timestamp to the base timestamp, or optionally the second timestamp argument for the number of seconds between timestamps. The source_timestamp_string argument must be double quoted or be a variable. Returns the time given the number of seconds ( dfloat ) since midnight. Returns a time representation of string using the optional time_format , time_uformat , or format_variable. By default, the time format is hh:nn:ss. For format descriptions, see and time Uformat . Returns a time representation of ustring using the optional time_format , time_uformat , or format_variable specification. By default, the time format is hh:nn:ss. For format descriptions, see and time Uformat . Returns a string from time. The format argument is optional.The default time format is hh:nn:ss. For format descriptions, see and time Uformat . Returns a ustring from time . The format argument is optional.The default time format is hh:nn:ss. For format descriptions, see and time Uformat .
string string_from_time ( time , time_format | format_variable | time_uformat ) string string_from_time ( time , time_format | format_variable | time_format )
262
Function time time_from_timestamp( timestamp ) date date_from_timestamp( timestamp ) timestamp timestamp_from_date_time ( date , time )
Description Returns the time from timestamp . Returns the date from the given timestamp . Returns a timestamp from date and time . The date specifies the date portion ( yyyy - nn - dd ) of the timestamp. The time argument specifies the time to be used when building the timestamp. The time argument must be in the hh : nn :ss format. Returns the timestamp from the number of seconds ( dfloat ) from the base timestamp or the original_timestamp_string argument. The original_timestamp_string must be double quoted or be a variable. Returns a timestamp from string, in the optional timestamp_format , timestamp_uformat, or format_variable . The timestamp_format must be double quoted or be a variable. The default format is yyyy - nn - dd hh : nn : ss . timestamp_format is described in . Returns a timestamp from ustring , in the optional format specification. The timestamp_format must be a double quoted string, a uformat , or a variable. The default format is yyyy - nn - dd hh : nn : ss . timestamp_uformat is described in . Returns a string from timestamp . The formatting specification is optional. The default format is yyyy - mm - dd hh : mm : ss . Returns a ustring from timestamp . The formatting specification is optional. The default format is yyyy - mm - dd hh : mm : ss . Returns a timestamp from time . For format descriptions, see and time Uformat Returns the date from the given timestamp . Returns a timestamp from the given UNIX time_t representation ( int32 ). Returns the UNIX time_t representation of timestamp.
string string_from_timestamp ( timestamp , timestamp_format | format_variable ) ustring ustring_from_timestamp ( timestamp , timestamp_format | format_variable ) timestamp timestamp_from_time ( time , time_format | time_uformat ) date date_from_timestamp( timestamp ) timestamp timestamp_from_timet( int32 ) int32 timet_from_timestamp( timestamp )
null handling functions lists the transformation functions for NULL handling. All WebSphere DataStage data types support nulls. As part of processing a record, an operator can detect a null and take the appropriate action, for example, it can omit the null field from a calculation or signal an error condition. WebSphere DataStage represents nulls in two ways. v It allocates a single bit to mark a field as null. This type of representation is called an out-of-band null. v It designates a specific field value to indicate a null, for example a numeric fields most negative possible value. This type of representation is called an in-band null. In-band null representation can be disadvantageous because you must reserve a field value for nulls and this value cannot be treated as valid data elsewhere.
Chapter 7. Operators
263
The null-handling functions can change a null representation from an out-of-band null to an in-band null and from an in-band null to an out-of-band null.
Function destination_field handle_null ( source_field , value ) Description Change the source_field NULL representations from out-of-band representation to an in-band representation. The value field assigns the value that corresponds to NULL. Changes source_field NULL representation from in-band NULL representation to out-of-band. The value field allows multiple valid NULL values to be inputted as arguments. Returns 1 if source_field is not NULL, otherwise returns 0. Returns 1 if source_field is NULL, otherwise returns 0. This function is used with = to set the left side output field, when it is nullable, to null. For example: a-field = set_null(); int8 is_dfloat_inband_null ( dfloat ) int8 is_int16_inband_null ( int16 ) int8 is_int32_inband_null ( int32 ) int8 is_int64_inband_null ( int64 ) int8 is_sfloat_inband_null ( sfloat ) int8 is_string_inband_null ( string ) int8 u_is_string_inband_null ( ustring ) Returns 1 if dfloat is an inband null; otherwise it returns 0. Returns 1 if int16 is an inband null; otherwise it returns 0. Returns 1 if int32 is an inband null; otherwise it returns 0. Returns 1 if int64 is an inband null; otherwise it returns 0. Returns 1 if sfloat is an inband null; otherwise it returns 0. Returns 1 if string is an inband null; otherwise it returns 0. Returns 1 if ustring is an inband null; otherwise it returns 0.
Mathematical functions
Function int32 abs( int32 ) dfloat acos( dfloat ) dfloat asin( dfloat ) dfloat atan( dfloat ) dfloat atan2( dfloat , dfloat ) int ceil( decimal ) dfloat cos( dfloat ) dfloat cosh( dfloat ) Description Returns the absolute value of int32 . Returns the principal value of the arc cosine of dfloat . Returns the principal value of the arc sine of dfloat . Returns the principal value of the arc tangent of dfloat. Returns the principal value of the arc tangent of y/x (where y is the first argument). Returns the smallest integer value greater than or equal to decimal . Returns the cosine of the given angle ( dfloat ) expressed in radians. Returns the hyperbolic cosine of dfloat .
264
Function dfloat exp( dfloat ) dfloat fabs( dfloat ) int floor( decimal ) dfloat ldexp( dfloat , int32 ) uint64 llabs( int64 ) dfloat log( dfloat ) dfloat log10( dfloat ) int32 max( int32 , int32 ) int32 min( int32 , int32 ) dfloat pow( dfloat , dfloat ) uint32 rand()
Description Returns the exponential of dfloat. Returns the absolute value of dfloat . Returns the largest integer value less than or equal to decimal . Reconstructs dfloat out of the mantissa and exponent of int32 . Returns the absolute value of int64 . Returns the natural (base e) logarithm of dfloat . Returns the logarithm to the base 10 of dfloat . Returns the larger of the two integers. Returns the smaller of the two integers. Returns the result of raising x (the first argument) to the power y (the second argument). Returns a pseudo-random integer between 0 and 232 - 1. The function uses a multiplicative congruential random-number generator with period 232. See the UNIX man page for rand for more details. Returns a random integer between 0 and 231 - 1. The function uses a nonlinear additive feedback random-number generator employing a default state array size of 31 long integers to return successive pseudo-random numbers. The period of this random-number generator is approximately 16 x (231 - 1). Compared with rand, random is slower but more random. See the UNIX man page for random for more details. Returns the sine of dfloat expressed in radians. Returns the hyperbolic sine of dfloat. Returns the square root of dfloat . Returns the value of the quotient after dfloat1 is divided by dfloat2 . Sets a new seed ( uint32 ) for the frand() or srand() random number generator. Sets a random seed for the random() number generator. See the UNIX man page for srandom for more details. Returns the tangent of the given angle ( dfloat ) expressed in radians. Returns the hyperbolic tangent of dfloat .
uint32 random()
dfloat sin( dfloat ) dfloat sinh( dfloat ) dfloat sqrt( dfloat ) int32 quotient_from_dfloat ( dfloat1 , dfloat2) srand( uint32 ) srandom( uint32 ) dfloat tan( dfloat ) dfloat tanh( dfloat )
265
You can construct a string lookup table to use when default conversions do not yield satisfactory results. A string lookup table is a table of two columns and as many rows as are required to perform a conversion to or from a string as shown in the following table.
Numeric Value numVal1 numVal2 ... numVal3 String or Ustring string1 | ustring1 string2 | ustring1 ... stringn | ustringn
Each row of the lookup table specifies an association between a 16-bit integer or unsigned 32-bit integer value and a string or ustring. WebSphere DataStage scans the Numeric Value or the String or Ustring column until it encounters the value or string to be translated. The output is the corresponding entry in the row. The numeric value to be converted may be of the int16 or the uint32 data type. WebSphere DataStage converts strings to values of the int16 or uint32 data type using the same table. If the input contains a numeric value or string that is not listed in the table, WebSphere DataStage operates as follows: v If a numeric value is unknown, an empty string is returned by default. However, you can set a default string value to be returned by the string lookup table. v If a string has no corresponding value, 0 is returned by default. However, you can set a default numeric value to be returned by the string lookup table. A table definition defines the rows of a string or ustring lookup table and has the following form:
{propertyList} (string | ustring = value; string | ustring= value; ... )
where: propertyList is one or more of the following options; the entire list is enclosed in braces and properties are separated by commas if there are more than one: v case_sensitive: perform a case-sensitive search for matching strings; the default is case-insensitive. v default_value = defVal: the default numeric value returned for a string that does not match any of the strings in the table. v default_string = defString: the default string returned for numeric values that do not match any numeric value in the table. v string or ustring specifies a comma-separated list of strings or ustrings associated with value; enclose each string or ustring in quotes. v value specifies a comma-separated list of 16-bit integer values associated with string or ustring.
Function int8 is_alnum( string ) int8 is_alpha( string ) int8 is_numeric( string ) Description Returns 1 true if string consists entirely of alphanumeric characters. Returns 1 true if string consists entirely of alphabetic characters. Returns 1 true if string consists entirely of numeric characters, including decimal and sign.
266
Description Returns 1 (true) if value_string is valid according to type_string , including NULL. The type_string argument is required. It must specify a WebSphere DataStage schema data type. Integer types are checked to ensure the value_string is numeric (signed or unsigned), a whole number, and a valid value (for example, 1024 can not be assigned to an int8 type). Decimal types are checked to ensure the value_string is numeric (signed or unsigned) and a valid value. Float types are checked to ensure the value_string is numeric (signed or unsigned) and a valid value (exponent is valid). String is always valid with the NULL exception below. For all types, if the field cannot be set to NULL and the string is NULL, 0 (false) is returned. Date, time, and timestamp types are checked to ensure they are correct, using the optional format argument, and valid values. Raw cannot be checked since the input is a string.
int16 lookup_int16_from_string ( string , table_definition | table_variable ) string lookup_string_from_int16 ( int16 , table_definition | table_variable ) string lookup_string_from_uint32 ( uint32 , table_definition | table_variable ) uint32 lookup_uint32_from_ string ( string , table_definition | table_variable ) string lower_case( string ) string string_from_date ( date , date_format | format_variable | date_uformat)
Returns an integer corresponding to string using table_definition string or variable. See String Conversions and Lookup Tables for more information. Returns a string corresponding to int16 using table_definition string or variable. See String Conversions and Lookup Tables for more information. Returns a string corresponding to uint32 using table_definition string or variable. See String Conversions and Lookup Tables for more information. Returns an unsigned integer from string using table_definition string or variable. Converts string to lowercase. Non-alphabetic characters are ignored in the transformation. Converts date to a string representation using the specified optional formatting specification. By default, the date format is yyyy - mm - dd . For format descriptions, seeand date Uformat .
Returns a string from decimal . fix_zero causes a decimal field containing all zeros to be treated as a valid zero. suppress_zero argument specifies that the returned ustring value will have no leading or trailing zeros. Examples: 000.100 -> 0.1; 001.000 -> 1; -001.100 -> -1.1 The formatting specification is optional.
Chapter 7. Operators
267
Function string string_from_time ( time , time_format | format_variable | time_uformat) string string_from_timestamp ( timestamp , timestamp_format | format_variable ) string soundex ( input_string , length , censusOption)
Description Returns a string from time . The format argument is optional.The default time format is hh : nn :ss. For format descriptions, see and time Uformat . Returns a string from timestamp . The formatting specification is optional. The default format is yyyy-mm-dd hh:mm:ss. Returns a string which represents the phonetic code for the string input word. Input words that produce the same code are considered phonetically equivalent. The empty string is returned if the input string is empty. length is an int8 and can be any value between 4 and 10. The default is 4. censusOption can be 0, 1, or 2 where 0 (the default) is enhanced soundex and not a census code; 1 are the normal census codes used in all censuses from 1920 on; and 2 are special census codes used intermittently in 1880, 1900, and 1910.
string upper_case( string ) string compact_whitespace ( string ) string pad_string ( string , pad_string , pad_length )
Converts string to uppercase. Non-alphabetic characters are ignored in the transformation. Returns a string after reducing all consecutive white space in string to a single space. Returns the string with the pad_string appended to the bounded length string for pad_length number of characters. pad_length is an int16. When the given string is a variable-length string, it defaults to a bounded-length of 1024 characters. If the given string is a fixed-length string, this function has no effect.
string strip_whitespace( string ) string trim_leading_trailing ( string ) string trim_leading( string ) string trim_trailing( string )
Returns string after stripping all white space in the string. Returns string after removing all leading and trailing white space. Returns a string after removing all leading white space. Returns a string after removing all trailing white space.
int32 string_order_compare ( string1 , string2, justification) Returns a numeric value specifying the result of the comparison. The numeric values are: -1: string1 is less than string2 0: string1 is equal to string2 1: string1 is greater than string2 The string justification argument is either L or R. It defaults to L if not specified. L means a standard character comparison, left to right. R means that any numeric substrings within the strings starting at the same position are compared as numbers. For example an R comparison of AB100 and AB99 indicates that AB100 is great than AB99, since 100 is greater than 99. The comparisons are case sensitive.
268
Description Returns a string value that contains the given string , with any characters in expression1 replaced by their corresponding characters in expression2. For example: replace_substring (ABC:, abZ, AGDCBDA) returns aGDZbDa, where any A gets replaced by a, any B gets replaced by b and any C gets replaced by Z. If expression2 is longer than expression1, the extra characters are ignored. If expression1 is longer than expression2, the extra characters in expression1 are deleted from the given string (the corresponding characters are removed.) For example: replace_substring(ABC, ab, AGDCBDA) returns aGDbDa.
Returns the number of times that substring occurs in string . If substring is an empty string, the number of characters in string is returned. Returns the number of fields in string delimited by delimiter , where delimiter is a string. For example, dcount_substring(abcFdefFghi, F) returns 3. If delimiter is an empty string, the number of characters in the string + 1 is returned. If delimiter is not empty, but does not exist in the given string, 1 is returned.
Returns the given string expression enclosed in double quotes. The string and delimiter arguments are string values, and the occurrence and numsubstr arguments are int32 values. This function returns numsubstr substrings from string , delimited by delimiter and starting at substring number occurence . An example is: substring_by_delimiter (abcFdefFghiFjkl, F, 2, 2) The string defFghi is returned. If occurence is < 1, then 1 is assumed. If occurence does not point to an existing field, the empty string is returned. If numsubstr is not specified or is less than 1, it defaults to 1.
Returns the starting position of the nth occurrence of substring in string . The occurrence argument is an integer indicating the nth occurrence. If there is no nth occurrence or string doesnt contain any substring , -1 is returned. If substring is an empty string, -2 is returned.
Chapter 7. Operators
269
Description Returns the first length characters of string . If length is 0, it returns the empty string. If length is greater than the length of the string, the entire string is returned. Returns the last length characters of string. If length is 0, it returns the empty string. If length is greater than the length of string , the entire string is returned. Returns a string containing count spaces. The empty string is returned for a count of 0 or less. Returns the expression string enclosed in single quotes. Returns a string containing count occurrences of string. The empty string is returned for a count of 0 or less. If only string is specified, all leading and trailing spaces and tabs are removed, and all multiple occurrences of spaces and tabs are reduced to a single space or tab. If string and character are specified, option defaults to R The available option values are: A remove all occurrences of character B remove both leading and trailing occurrences of character. D remove leading, trailing, and redundant white-space characters. E remove trailing white-space characters F remove leading white-space characters L remove all leading occurrences of character R remove all leading, trailing, and redundant occurrences of character T remove all trailing occurrences of character
string string_of_space( count) string single_quote_string ( expression) string string_of_substring ( string , count) string trimc_string ( string [, character [, option ]])
string system_time_date()
Returns the current system time in this 24-hour format: hh : mm :ss dd : mmm : yyyy
Searches for the substring in the string beginning at character number position , where position is an uint32. Returns the starting position of the substring. This is a case-insensitive version of string_compare() below. Compares two strings and returns the index (0 or 1) of the greater string. This is a case-insensitive version of string_num_compare() below. Returns a string after appending uint16 characters from the second string onto the first string. Compares first uint16 characters of two given strings and returns the index (0 or 1) of the greater string. Returns the first uint16 characters from the given string . Returns the length of the string. Copies parts of strings to shorter strings by string extraction. The starting_position specifies the starting location of the substring; length specifies the substring length. The arguments starting_position and length are uint16 types and must be positive (>= 0).
int8 string_case_compare ( string , string) int8 string_compare ( string , string) int8 string_num_case_compare ( string , string, uint16) string string_num_concatenate ( string , string, uint16) int8 string_num_compare ( string , string, uint16) string string_num_copy ( string , uint16) int32 string_length( string ) string substring ( string , starting_position, length)
270
Description Returns an ASCII character from the given int32 . If given a value that is not associated with a character such as -1, the function returns a space. An example use is: char_from_num(38) which returns &
Returns the numeric value of the ASCII-character in the string. When this function is given an empty string, it returns 0; and when it is given a multi-character string, it uses the first character in the string. An example use is: num_from_char(&) which returns 38.
Chapter 7. Operators
271
Function int16 lookup_int16_from_ustring ( ustring , table_definition | table_variable ) ustring lookup_ustring_from_int16 ( int16 , table_definition | table_variable ) ustring lookup_ustring_from_uint32 ( uint32 , table_definition | table_variable ) uint32 lookup_uint32_from_ustring ( string , table_definition | table_variable ) int8 u_is_valid ( type_ustring , value_ustring )
Description Returns an integer corresponding to ustring using table_definition string or variable. See String Conversions and Lookup Tables for more information. Returns a ustring corresponding to int16 using table_definition string or table_variable . See String Conversions and Lookup Tables for more information. Returns a ustring corresponding to uint32 using table_definition string or variable. SeeString Conversions and Lookup Tables for more information. Returns an unsigned integer from ustring using table_definition or table_variable . Returns 1 (true) if value_ustring is valid according to type_ustring , including NULL. The type_ustring argument is required. It must specify a WebSphere DataStage schema data type. Integer types are checked to ensure the value_ustring is numeric (signed or unsigned), a whole number, and a valid value (for example, 1024 can not be assigned to an int8 type). Decimal types are checked to ensure the value_ustring is numeric (signed or unsigned) and a valid value. Float types are checked to ensure the value_ustring is numeric (signed or unsigned) and a valid value (exponent is valid). String is always valid with the NULL exception below. For all types, if the field cannot be set to NULL and the string is NULL, 0 (false) is returned. Date, time, and timestamp types are checked to ensure they are correct, using the optional format argument, and valid values. Raw cannot be checked since the input is a string.
ustring u_lower_case( ustring ) ustring u_upper_case( ustring ) ustring u_compact_whitespace ( ustring ) ustring u_pad_string ( ustring , pad_ustring , pad_length )
Converts ustring to lowercase. Non-alphabetic characters are ignored in the transformation. Converts ustring to uppercase. Non-alphabetic characters are ignored in the transformation. Returns the ustring after reducing all consecutive white space in ustring to a single space. Returns the ustring with pad_ustring appended to the bounded length string for pad_length number of characters. pad_length is an int16. When the given ustring is a variable-length string, it defaults to a bounded-length of 1024 characters. If the given ustring is a fixed-length string, this function has no effect.
Returns ustring after stripping all white space in the string. Returns ustring after removing all leading and trailing white space.
272
Function ustring u_trim_leading( ustring ) ustring u_trim_trailing ( ustring ) int32 u_string_order_compare ( ustring1 , ustring2, justification)
Description Returns ustring after removing all leading white space. Returns a ustring after removing all trailing white space. Returns a numeric value specifying the result of the comparison. The numeric values are: -1: ustring1 is less than ustring2 0: ustring1 is equal to ustring2 1: ustring1 is greater than ustring2 The string justification argument is either L or R. It defaults to L if not specified. L means a standard character comparison, left to right. R means that any numeric substrings within the strings starting at the same position are compared as numbers. For example an R comparison of AB100 and AB99 indicates that AB100 is great than AB99, since 100 is greater than 99. The comparisons are case sensitive.
Returns a ustring value that contains the given ustring , with any characters in expression1 replaced by their corresponding characters in expression2 . For example: u_replace_substring (ABC, abZ, AGDCBDA) returns aGDZbDa, where any A gets replaced by a, any B gets replaced by b and any C gets replaced by Z. If expression2 is longer than expression1 , the extra characters are ignored. If expression1 is longer than expression2, the extra characters in expression1 are deleted from the given string (the corresponding characters are removed.) For example: u_replace_substring(ABC, ab, AGDCBDA) returns aGDbDa.
Returns the number of times that sub_ustring occurs in ustring . If sub_ustring is an empty string, the number of characters in ustring is returned. Returns the number of fields in ustring delimited by delimiter , where delimiter is a string. For example, dcount_substring(abcFdefFghi, F) returns 3. If delimiter is an empty string, the number of characters in the string + 1 is returned. If delimiter is not empty, but does not exist in the given string, 1 is returned.
Chapter 7. Operators
273
Description The delimiter argument is a ustring value, and the occurrence and numsubstr arguments are int32 values. This function returns numsubstr substrings from ustring , delimited by delimiter and starting at substring number occurence . An example is: u_substring_by_delimiter (abcFdefFghiFjkl, F, 2, 2) The string defFghi is returned. If occurence is < 1, then 1 is assumed. If occurence does not point to an existing field, the empty string is returned. If numsubstr is not specified or is less than 1, it defaults to 1.
Returns the starting position of the nth occurrence of sub_ustring in ustring. The occurrence argument is an integer indicating the nth occurrence . If there is no nth occurrence, 0 is returned; if sub_ustring is an empty string, -2 is returned; and if ustring doesnt contain any sub_ustring , -1 is returned.
Returns the first length characters of ustring. If length is 0, it returns the empty string. If length is greater than the length of the ustring , the entire ustring is returned. Returns the last length characters of ustring . If length is 0, it returns the empty string. If length is greater than the length of ustring , the entire ustring is returned. Returns a ustring containing count spaces. The empty string is returned for a count of 0 or less. Returns expression enclosed in single quotes. Returns a ustring containing count occurrences of ustring. The empty string is returned for a count of 0 or less. If only ustring is specified, all leading and trailing spaces and tabs are removed, and all multiple occurrences of spaces and tabs are reduced to a single space or tab. If ustring and character are specified, option defaults to R The available option values are: A remove all occurrences of character B remove both leading and trailing occurrences of character. D remove leading, trailing, and redundant white-space characters. E remove trailing white-space characters F remove leading white-space characters L remove all leading occurrences of character R remove all leading, trailing, and redundant occurrences of character T remove all trailing occurrences of character
ustring u_string_of_space( count) ustring u_single_quote_string ( expression) ustring u_string_of_substring ( ustring , count) ustring u_trimc_string ( ustring [, character [, option ]])
ustring u_system_time_date()
Returns the current system time in this 24-hour format: hh:mm:ss dd:mmm:yyyy
Searches for the sub_ustring in the ustring beginning at character number position, where position is an uint32. Returns the starting position of the substring. This is a case-insensitive version of u_string_compare() below.
274
Function int8 u_string_compare ( ustring , ustring) int8 u_string_num_case_compare ( ustring , ustring, uint16) ustring u_string_num_concatenate ( ustring , ustring, uint16) int8 u_string_num_compare ( utring , ustring, uint16) ustring u_string_num_copy ( ustring , uint16) int32 u_string_length( ustring ) ustring u_substring ( ustring , starting_position, length)
Description Compares two ustrings and returns the index (0 or 1) of the greater string. This is a case-insensitive version of u_string_num_compare() below. Returns a ustring after appending uint16 characters from the second ustring onto the first ustring . Compares first uint16 characters of two given ustrings and returns the index (0 or 1) of the greater ustring . Returns the first uint16 characters from the given ustring . Returns the length of the ustring . Copies parts of ustrings to shorter strings by string extraction. The starting_position specifies the starting location of the substring; length specifies the substring length. The arguments starting_position and length are uint16 types and must be positive (>= 0).
Returns a ustring character value from the given int32 . If given a value that is not associated with a character such as -1, the function returns a space. An example use is: u_char_from_num(38) which returns &
Returns the numeric value of the character in the ustring . When this function is given an empty string, it returns 0; and when it is given a multi-character string, it uses the first character in the string. An example use is: u_num_from_char(&) which returns 38
275
Miscellaneous functions
The following table describes functions in the Transformation Language that do not fit into any of the above categories.
Function void force_error ( error_message_string ) u_force_error ( error_message_ustring ) string get_environment( string ) Description Terminates the data flow when an error is detected, and prints error_message_string to stderr. Terminates the data flow when an error is detected, and prints error_message_ustring to stderr. Returns the current value of string , a UNIX environment variable. The functionality is the same as the C getenv function. Returns the current value of utring , a UNIX environment variable. The functionality is the same as the C getenv function. Returns the current partition number. Returns the number of partitions. Prints message_string to stdout.
276
Description Prints message_ustring to stdout. Returns the actual size value when it is stored, not the length.
You can override the default values using these environment variables: v APT_DECIMAL_INTERM_PRECISION value v APT_DECIMAL_INTERM_SCALE value v APT_DECIMAL_INTERM_ROUNDMODE ceil | floor | round_inf | trunc_zero Fatal errors may occur at runtime if the precision of the destination decimal is smaller than that of the source decimal
Keywords
Keywords in the Transformation Language are not case sensitive.
Local variables
You cannot initialize variables as part of the declaration. There are no local variable pointers or structures. Enums are not supported.
Operators
Several C operators are not part of the language: v The comma operator v Composite assignment operators such as +=.
Chapter 7. Operators
277
Flow control
The switch and case C keywords do not appear in the Transformation Language. The if ... else if construct for multiple branching is not supported. You can accomplish the same effect by using multiple if statements in sequence together with complex boolean expressions. For example, where in C you could write:
if (size < 7) tag = "S"; else if (size < 9) tag = "M"; else tag = "L";
278
transform
After the records are processed, a report is printed that shows the number of students in each score category.
Transformation language
The record-processing logic can be expressed in the Transformation Language as follows. The expression file name for this example is score_distr_expr.
global { // the global variable that contains the name for each job run string jobName; } initialize { // the number of records in output 0 int32 recNum0; // the number of records in output 1 int32 recNum1; // the number of records in output 2 int32 recNum2;
Chapter 7. Operators
279
// initialization recNum0 = 0; recNum1 = 0; recNum2 = 0; } mainloop { // records in output 0 if (score < 75) { recNum0++; writerecord 0; } // records of output 1 if (score >= 75 && score <= 90) { RecNum1++; writerecord 1; } // records of output2 if (score > 90) { recNum2++; writerecord 2; } } finish { // define a string local variable to store the number of // students with poor scores string NumOfPoorScores; numOfPoorScores = recNum0; // define a string local variable to store the number of // students with fair scores string NumOfFairScores; numOfFairScores = recNum1; // define a string local variable to store the number of // students with good scores string NumOfGoodScores; numOfGoodScores = recNum2; // Print out the number of records in each output data set print_message(jobName+ "has finished running."); print_message("The number of students having poor scores are" +numOfPoorScores); print_message("The number of students having fair scores are" +numOfFairScores); print_message("The number of students having good scores are" +numOfGoodScores); }
osh command
An example osh command to run this job is:
osh -params "jobName=classA" -f score_distr
osh script
The contents of score_distr are:
#compile the expression code transform -inputschema record(student_id:string[10];score:int32;) -outputschema record(student_id:string[10];score:int32;) -outputschema record(student_id:string[10];score:int32;) -outputschema record(student_id:string[10];score:int32;) -expressionfile score_distr_expr -flag compile -name score_map; #run the job
280
import -schema record(student_id:string[10];score:int32;) -file [&jobName].txt | transform -flag run -name score_map 0> export -schema record(student_id:string[10];score:int32) -filename [&jobName]poor_score.out -overwrite 1> -export -schema record(student_id:string[10];score:int32) -file [&jobName]fair_score.out -overwrite 2> -export -schema record(student_id:string[10];score:int32) -file [&jobName]good_score.out -overwrite
classAfair_score.out:
A112387567 A731347820 A897382711 A327637289 A238967521 A763567100 80 75 85 82 87 89
classAgood_score.out:
A218925316 95 A238950561 92
The global variable jobName is initialized using the -params option. To determine the score distribution for class B, for example, assign jobName another value:
osh -params "jobName=classB" -f score_distr
Chapter 7. Operators
281
transform
Transformation language
The record-processing logic can be expressed in the Transformation Language as follows. The expression file name for this example is score_grade_expr.
inputname 0 in0; outputname 0 out0; outputname 1 out1; outputname 2 out2; global { // the global variable that contains the name for each job run string jobName; } initialize { // the number of records in the outputs int32 recNum0, recNum1, recNum2; // initialization recNum0 = 0; recNum1 = 0; recNum2 = 0; } mainloop { if (in0.score < 75)
282
{ recNum0++; out0.grade = "C"; writerecord 0; } if (in0.score >= 75 && in0.score <= 90) { recNum1++; out1.grade = "B"; writerecord 1; } if (in0.score > 90) { recNum2++; out2.grade = "A"; writerecord 2; } } finish { // define string local variables to store the number of // students having different letter grades string numOfCs, numOfBs, numOfAs; // default conversions using assignments numOfCs = recNum0; numOfBs = recNum1; numOfAs = recNum2; // Print out the number of records in each output data set print_message(jobName+ " has finished running."); print_message("The number of students getting C is " +numOfCs); print_message("The number of students getting B is " +numOfBs); print_message("The number of students getting A is " +numOfAs); }
osh command
An example osh command to run this job is:
osh -params "jobName=classA" -f score_grade
osh script
The contents of score_grade are:
#compile the expression code transform -inputschema record(student_id:string[10];score:int32;) -outputschema record (student_id:string[10];score:int32;grade:string[1]) -outputschema record (student_id:string[10];score:int32;grade:string[1]) -outputschema record (student_id:string[10];score:int32;grade:string[1]) -expressionfile score_grade_expr -flag compile -name score_map; #run the job import -schema record(student_id:string[10];score:int32;) -file [&jobName].txt | transform -flag run -name score_map 0> -export record(student_id:string[10];score:int32;grade:string[1]) -file [&jobName]poor_scores.out -overwrite 1> -export record(student_id:string[10];score:int32;grade:string[1]) -file [&jobName]fair_scores.out -overwrite 2> -export record(student_id:string[10];score:int32;grade:string[1]) -file [&jobName]good_scores.out -overwrite
Chapter 7. Operators
283
classAfair_scores.out
A112387567 A731347820 A897382711 A327637289 A238967521 A763567100 80 75 85 82 87 89 B B B B B B
classAgood_scores.out
A218925316 95 A A238950561 92 A
284
transform
Transformation language
The record-processing logic can be expressed in the Transformation Language as follows. The expression file for this example is score_class_expr.
inputname 0 int0; outputname 0 out0; outputname 1 out1; outputname 2 out2; mainloop { //define an int32 local variable to store the score int32 score_local; score_local=(in0.score < 75) ? (in0.score+(200-in0.score*2)/4): (in0.score+(200-in0.score*2)/3) // define a string local variable to store the grade string[1] grade_local; if (score_local < 75) grade_local = "C"; if (score_local >= 75 && score_local <= 90) grade_local = "B"; if (score_local > 90) grade_local = "A"; // define string local variables to check the class level string[max=15] class_local; string[1] class_init; class_init = substring(in0.student_id,0,1); if (class_init == "B") class_local = "Beginner"; if (class_init == "I") class_local = "Intermediate"; if (class_init == "A") class_local = "Advanced"; // outputs if (class_local == "Beginner") { out0.score = score_local;
Chapter 7. Operators
285
out0.grade = grade_local; out0.class = class_local; writerecord 0; } if (class_local == "Intermediate") { out1.score = score_local; out1.grade = grade_local; out1.class = class_local; writerecord 1; } if (class_local == "Advanced") { out2.score = score_local; out2.grade = grade_local; out2.class = class_local; writerecord 2; } }
osh command
The osh command to run this job is:
osh -f score_class
osh script
The contents of score_class are:
#compile the expression code transform -inputschema record(student_id:string[10];score:int32;) -outputschema record (student_id:string[10];score:int32;grade:string[1]; class:string[max=15]) -outputschema record (student_id:string[10];score:int32;grade:string[1]; class:string[max=15]) -outputschema record (student_id:string[10];score:int32;grade:string[1]; class:string[max=15]) -expressionfile score_class_expr -flag compile -name score_map; #run the job import -schema record(student_id:string[10];score:int32;) -file score.txt | transform -flag run -name score_map 0> -export record(student_id:string[10];score:int32;grade:string[1]; class:string[max=15]) -file beginner.out -overwrite 1> -export record(student_id:string[10];score:int32;grade:string[1]; class:string[max=15]) -filename intermediate.out -overwrite 2> -export record(student_id:string[10];score:int32;grade:string[1]; class:string[max=15]) -file advanced.out -overwrite
286
intermediate.out
I731347820 91 A Intermediate I327637289 94 A Intermediate I238967521 95 A Intermediate
advanced.out
A218925316 A619846201 A238950561 A763567100 98 85 97 96 A B A A Advanced Advanced Advanced Advanced
Example 4. student record distribution with null score values and a reject
Job logic
The job logic in this example is the same as in Example 3: Student-Score Distribution with a Class Field Added to Example 2 . The difference is that the input records contain null score fields, and records with null score fields are transferred to a reject data set. This example shows you how to specify and use a reject data set. The Transformation Language expression file is the same as that for Example 3.
transform
osh command
The osh command to run this job is:
osh -f score_reject
Chapter 7. Operators
287
osh script
The contents of score_reject are:
#compile the expression code transform -inputschema record(student_id:string[10]; score:nullable int32;) -outputschema record (student_id:string[10];score:nullable int32;grade:string[1]; class:string[max=15]) -outputschema record (student_id:string[10];score:nullable int32;grade:string[1]; class:string[max=15]) -outputschema record (student_id:string[10];score:nullable int32;grade:string[1]; class:string[max=15]) -expressionfile score_class_expr -flag compile -name score_map -reject; #run the job import -schema record(student_id:string[10];score:nullable int32 {null_field=NULL}) -file score_null.txt | transform -flag run -name score_map 0> -export -schema record(student_id:string[10]; score:nullable int32{null_field=NULL}; grade:string[1]; class:string[max=15]) -file beginner.out -overwrite 1> -export record(student_id:string[10]; score:nullable int32{null_field=NULL}; grade:string[1]; class:string[max=15]) -file intermediate.out -overwrite 2> -export record(student_id:string[10]; score:nullable int32{null_field=NULL}; grade:string[1]; class:string[max=15]) -file advanced.out -overwrite 3> -export record(student_id:string[10]; score:nullable int32{null_field=NULL};) -file reject.out -overwrite
intermediate.out
I218925316 98 A Intermediate I731347820 91 A Intermediate I238967521 95 A Intermediate
advanced.out
A619846201 85 B Advanced A238950561 97 A Advanced
288
reject.out
B112387567 NULL I327637289 NULL A763567100 NULL
transform
2. Use a function call to null() and the ternary operator. For example:
score_local = null(in0.score)?-100:in0.score;
3. Use a function call to notnull() and the ternary operator. For example:
score_local = notnull(in0.score)?in0.score:-100;
Setting a nullable field to null occurs when the record is written to output. In this example, after the statement out0.score = score_local executes, out0.score no longer contains null values, since the old null
Chapter 7. Operators
289
value has been replaced by -100. To reinstate the null field, the function make_null() is called to mark that any field containing -100 is a null field. When the score is -100, grade should be null; therefore, set_null() is called.
Transformation language
The record processing logic can be expressed in the Transformation Language as follows. The expression file name for this example is score_null_handling_expr.
inputname 0 in0; outputname 0 out0; outputname 1 out1; outputname 2 out2; mainloop { // define an int32 local variable to store the score int32 score_local; // handle the null score score_local = handle_null(in0.score,"-100"); // alternatives: // score_local = null(in0.score)?-100:in0.score; // score_local = notnull(in0.score)?in0.score:-100; // define a string local variable to store the grade string[1] grade_local; grade_local = "F"; if ( score_local < 60 && score_local >= 0 ) grade_local = "D"; if ( score_local < 75 && score_local >= 60 ) grade_local = "C"; if ( score_local >= 75 && score_local <= 90 ) grade_local = "B"; if ( score_local > 90 ) grade_local = "A"; // define string local variables to check the class level string[max=15] class_local; string[1] class_init; class_init = substring(in0.student_id,0,1); if ( class_init == "B" ) class_local = "Beginner"; if ( class_init == "I" ) class_local = "Intermediate"; if ( class_init == "A" ) class_local = "Advanced"; // outputs if ( class_local == "Beginner" ) { out0.score = score_local; out0.score = make_null(out0.score,"-100"); if ( grade_local == "F" ) out0.grade = set_null(); else out0.grade = grade_local; out0.class = class_local; writerecord 0; } if ( class_local == "Intermediate" ) { out1.score = score_local; out1.score = make_null(out1.score,"-100"); if ( grade_local == "F" ) out1.grade = set_null(); else out1.grade = grade_local; out1.class = class_local; writerecord 1; } if ( class_local == "Advanced" )
290
{ out2.score = score_local; out2.score = make_null(out2.score,"-100"); if ( grade_local == "F" ) Sout2.grade = set_null(); else out2.grade = grade_local; out2.class = class_local; writerecord 2; } }
osh command
The osh script to run this job is:
osh -f score_null_handling
osh script
The contents of score_null_handling are:
# compile the exppression code transform -inputschema record(student_id:string[10];score:nullable int32;) -outputschema record(student_id:string[10];score:nullable int32;grade:nullable string[1];class:string[max=15]) -outputschema record(student_id:string[10];score:nullable int32;grade:nullable string[1];class:string[max=15]) -outputschema record(student_id:string[10];score:nullable int32;grade:nullable string[1];class:string[max=15]) -expressionfile score_null_handling_expr -flag compile -name score_map; # run the job import -schema record(student_id:string[10];score:nullable int32{null_field=NULL}) -file score_null.txt | transform -flag run -name score_map 0> -export record(student_id:string[10];score:nullable int32{null_field=NULL};grade:nullable string[1]{null_field=FAILED};class:string[max=5];) -file beginner.out -overwrite 1> -export record(student_id:string[10];score:nullable int32{null_field=NULL};grade:nullable string[1]{null_field=FAILED};class:string[max=5];) -file intermediate.out -overwrite 2> -export record(student_id:string[10];score:nullable int32{null_field=NULL};grade:nullable string[1]{null_field=FAILED};class:string[max=5];) -file advanced.out -overwrite
291
intermediate.out
I218925316 I731347820 I327637289 I238967521 95 A 75 B NULL 87 B Intermediate Intermediate FAILED Intermediate Intermediate
advanced.out
A619846201 70 C Advanced A238950561 92 A Advanced A763567100 NULL FAILED Advanced
transform
292
v v v v
Vector variables with flow loops. For example, while and for loops. Using flow loops with controls. For example, continue statements. Using vector variables in expressions. For example, if statements and assignments. Using a schema variable for an implicit transfer. For example in -inputschema and -outputschema declarations, the field term is transferred from the up-stream operator to the transform operator and from the transform input to its output.
Transformation language
The record-processing logic can be expressed in the Transformation Language as follows. The expression file name for this example is score_vector_expr.
inputname 0 in0; outputname 0 out0; outputname 1 out1; outputname 2 out2; mainloop { // define an int32 local vector variable to store the scores int32 score_local[5]; int32 vecLen; vecLen = 5; // handle null score int32 i; i = 0; while ( i < vecLen ) { score_local[i] = handle_null(in0.score[i],"-100"); // alternatives // score_local[i] = null(in0.score[i])?-100:in0.score[i]; // score_local[i] = notnull(in0.score[i])?in0.score[i]:-100; i++; } // define a string local vector variable to store the grades string[1] grade_local[5]; // define sfloat local variables to calculate GPA. sfloat tGPA_local, GPA_local; tGPA_local = 0.0; GPA_local = 0.0; // define an int8 to count the number of courses taken. int8 numOfScore; numOfScore = 0; for ( i = 0; i < vecLen; i++) { // Null score means the course is not taken, // and will not be counted. if ( score_local[i] == -100) { grade_local[i] = "S"; continue; } numOfScore++; if ( score_local[i] < 60 && score_local[i] >= 0 ) { grade_local[i] = "D"; tGPA_local = tGPA_local + 1.0; } if ( score_local[i] < 75 && score_local[i] >= 60 ) { grade_local[i] = "C"; tGPA_local = tGPA_local + 2.0; } if ( score_local[i] >= 75 && score_local[i] <= 90 ) {
Chapter 7. Operators
293
grade_local[i] = "B"; tGPA_local = tGPA_local + 3.0; } if ( score_local[i] > 90 ) { grade_local[i] = "A"; tGPA_local = tGPA_local + 4.0; } } if ( numOfScore > 0 ) GPA_local = tGPA_local / numOfScore; // define string local variables to check the class level string[max=15] class_local; string[1] class_init; class_init = substring(in0.student_id,0,1); if ( class_init == "B" ) class_local = "Beginner"; if ( class_init == "I" ) class_local = "Intermediate"; if ( class_init == "A" ) class_local = "Advanced"; // outputs if (class_local == "Beginner") { for ( i = 0; i < vecLen; i++) { out0.score[i] = score_local[i]; out0.score[i] = make_null(out0.score[i],"-100"); out0.grade[i] = grade_local[i]; } out0.GPA = GPA_local; out0.class = class_local; writerecord 0; } if ( class_local == "Intermediate" ) { for ( i = 0; i < vecLen; i++) { out1.score[i] = score_local[i]; out1.score[i] = make_null(out1.score[i],"-100"); out1.grade[i] = grade_local[i]; } out1.GPA = GPA_local; out1.class = class_local; writerecord 1; } if ( class_local == "Advanced" ) { for ( i = 0; i < vecLen; i++) { out2.score[i] = score_local[i]; out2.score[i] = make_null(out2.score[i],"-100"); out2.grade[i] = grade_local[i]; } out2.GPA = GPA_local; out2.class = class_local; writerecord 2; }
osh command
The osh script to run this job is:
osh -f score_vector
294
osh script
The contents of score_vector are:
# compile the exppression code transform -inputschema record(student_id:string[10];score[5]:nullable int32;inRec:*) -outputschema record(student_id:string[10];score[5]:nullable int32; grade[5]:string[1];GPA:sfloat;class:string[max=15];outRec:*) -outputschema record(student_id:string[10];score[5]:nullable int32; grade[5]:string[1];GPA:sfloat;class:string[max=15];outRec:*) -outputschema record(student_id:string[10];score[5]:nullable int32; grade[5]:string[1];GPA:sfloat;class:string[max=15];outRec:*) -expressionfile score_vector_expr -flag compile -name score_map; # run the job import -schema record(student_id:string[10];score[5]:nullable int32{null_field=NULL};term:string) file score_vector.txt | transform -flag run -name score_map 0> -export record(student_id:string[10];score[5]:nullable int32{null_field=NULL};grade[5]:string[1];GPA:sfloat{out_format= %4.2g};class:string[max=15];term:string;) -file beginner.out -overwrite 1> -export record(student_id:string[10];score[5]:nullable int32{null_field=NULL};grade[5]:string[1];GPA:sfloat{out_format=%4.2g};class:string[max=15];ter m:string;) -file intermediate.out -overwrite 2> -export record(student_id:string[10];score[5]:nullable int32{null_field=NULL};grade[5]:string[1];GPA:sfloat{out_format=%4.2g};class:string[max=15];ter m:string;) -file advanced.out -overwrite
intermediate.out
I218925316 I731347820 I327637289 I238967521 95 NULL 91 88 NULL 75 NULL 89 93 95 B NULL NULL 88 92 76 87 NULL 86 NULL 82 A S S B S B S S A A B B B A A S S 3.7 Intermediate Midterm 3.5 Intermediate Final B 3.3 Intermediate Final B 3 Intermediate Midterm
advanced.out
A619846201 70 82 85 68 NULL C B B C S 2.5 Advanced Final A238950561 92 97 89 85 83 A A B B B 3.4 Advanced Final A763567100 NULL NULL 53 68 92 S S D C A 2.3 Advanced Final
Chapter 7. Operators
295
transform
Transformation language
The record-processing logic can be expressed in the Transformation Language as follows. The expression file name for this example is score_subrec_expr.
inputname 0 in0; outputname 0 out0; outputname 1 out1; outputname 2 out2; mainloop { // define an int32 local vector variable to store the scores int32 score_local[3]; // define an index to store vector or subrec length int32 vecLen, subrecLen; vecLen = 3; subrecLen = 2; // index int32 i, j;
296
i = 0; j = 0; // define a string local vector variable to store the grades string[1] grade_local[3]; // define sfloat local vairalbes to calculate GPA. sfloat tGPA_local, GPA_local; tGPA_local = 0.0; GPA_local = 0.0; // define string local variables to check the class level string[1] class_init; string[max=15] class_local; class_init = substring(in0.student_id,0,1); if ( class_init == "B" ) class_local = "Beginner"; if ( class_init == "I" ) class_local = "Intermediate"; if ( class_init == "A" ) class_local = "Advanced"; // calculate grade and GPA // The outer loop controls subrec // The inner loop controls sub-fields for ( j = 0; j < subrecLen; j++) { for ( i = 0; i < vecLen; i++) { score_local[i] = in0.score_report[j].score[i]; if ( score_local[i] < 60 && score_local[i] >= 0 ) { grade_local[i] = "D"; tGPA_local = tGPA_local + 1.0; } if ( score_local[i] < 75 && score_local[i] >= 60 ) { grade_local[i] = "C"; tGPA_local = tGPA_local + 2.0; } if ( score_local[i] >= 75 && score_local[i] <= 90 ) { grade_local[i] = "B"; tGPA_local = tGPA_local + 3.0; } if ( score_local[i] > 90 ) { grade_local[i] = "A"; tGPA_local = tGPA_local + 4.0; } } GPA_local = tGPA_local / vecLen; // outputs if ( class_local == "Beginner" ) { for ( i = 0; i < vecLen; i++) { out0.score_report[j].score[i] = score_local[i]; out0.score_report[j].grade[i] = grade_local[i]; } out0.score_report[j].GPA = GPA_local; } if ( class_local == "Intermediate" ) { for ( i = 0; i < vecLen; i++) { out1.score_report[j].score[i] = score_local[i]; out1.score_report[j].grade[i] = grade_local[i]; } out1.score_report[j].GPA = GPA_local; }
Chapter 7. Operators
297
if ( class_local == "Advanced" ) { for ( i = 0; i < vecLen; i++) { out2.score_report[j].score[i] = score_local[i]; out2.score_report[j].grade[i] = grade_local[i]; } out2.score_report[j].GPA = GPA_local; } // intialize these variables for next subrec GPA_local = 0; tGPA_local = 0; } // outputs if ( class_local == "Beginner" ) { out0.class = class_local; writerecord 0; } if ( class_local == "Intermediate" ) { out1.class = class_local; writerecord 1; } if ( class_local == "Advanced" ) { out2.class = class_local; writerecord 2; } }
osh command
osh -f score_subrec
osh script
The contents of score_subrec are:
# compile the exppression code transform -inputschemafile score_subrec_input.schema -outputschemafile score_subrec_output.schema -outputschemafile score_subrec_output.schema -outputschemafile score_subrec_output.schema -expressionfile score_subrec_expr -flag compile -name score_map; # run the job import -schemafile score_subrec_input.schema -file score_subrec.txt | transform -flag run -name score_map > a.v >b.v >c.v; 0> -export -schemafile score_subrec_output.schema -file beginner.out -overwrite < a.v; 1> -export -schemafile score_subrec_output.schema -file intermediate.out -overwrite < b.v; 2> -export -schemafile score_subrec_output.schema -file advanced.out -overwrite < c.v;
Input schema
The contents of score_subrec_input.schema are:
record( student_id:string[10]; score_report[2]:subrec(score[3]:nullable int32;term:string;) )
Output schema
The contents of score_subrec_output.schema are:
298
intermediate.out
I218925316 I731347820 I327637289 I238967521 95 75 88 87 91 89 92 86 88 93 76 82 A B B B A B A B B 3.7 Midterm 92 81 78 A 3.3 Final 85 79 92 B B 3.3 Final 82 96 86 B B 3 Midterm 97 96 92 A B A A B A B A B 3.3 Final Intermediate 3.3 Midterm Intermediate 3.3 Midterm Intermediate A 4 Final Intermediate
advanced.out
A619846201 70 82 85 C B B 2.7 Final 60 89 85 C B B A238950561 92 97 89 A A B 3.7 Final 90 87 91 B B A A763567100 53 68 92 D C A 2.3 Final 48 78 92 D B A 2.7 Midterm Advanced 3.3 Midterm Advanced 2.7 Midterm Advanced
Chapter 7. Operators
299
long my_square( long x , long y ); #else long long my_square( long long x , long long y ); #endif
Transformation language
The expression file name for this example is t_extern_func.
extern int32 my_times(int32 x, int32 y); extern uint32 my_sum(uint32 x, uint32 y); extern void my_print_message(string msg); extern int64 my_square(int64 x, int64 y); inputname 0 in0; outputname 0 out0; mainloop { out0.times= my_times(in0.a1,in0.a2); out0.sum= my_sum(in0.a1,in0.a2); out0.square= my_square(in0.a1,in0.a2); my_print_message("HELLO WORLD!"); writerecord 0; }
osh script
transform -inputschema record(a1:int32;a2:int32) -outputschema record(times:int32;sum:uint32;square:int64;) -expressionfile t_extern_func -flag compile
300
-name my_extern_func -staticobj /DIR/functions.o; generator -schema record(a1:int32;a2:int32) | transform -flag run -name my_extern_func | peek;
Writerangemap operator
The writerangemap operator takes an input data set produced by sampling and partition sorting a data set and writes it to a file in a form usable by the range partitioner. The range partitioner uses the sampled and sorted data set to determine partition boundaries.
writerangemap
newDS.ds
The operator takes a single data set as input. You specify the input interface schema of the operator using the -interface option. Only the fields of the input data set specified by -interface are copied to the output file.
Properties
Property Number of input data sets Number of output data sets Input interface schema: Output interface schema Transfer behavior Execution mode Partitioning method Preserve-partitioning flag in output set Composite operator Value 1 0 (produces a data file as output) specified by the interface arguments none inRec to outRec without modification sequential only range set no
Chapter 7. Operators
301
302
Option -overwrite
Use -overwrite Tells the operator to overwrite the output file, if it exists. By default, the operator does not overwrite the output file. Instead it generates an error and aborts the job if the file already exists.
-rangemap
-rangemap filename Specifies the pathname of the output file which will contain the sampled and sorted data.
Chapter 7. Operators
303
304
305
Record schemas
A record schema is an implicit or explicit description of the layout and properties of the record-oriented data contained in a WebSphere DataStage data set. Implicit (default) record schemas are discussed in The Default Import Schema and The Default Export Schema . When you invoke either the import or the export operator, you must explicitly specify a schema, as in the following two examples.
step import
statistics
306
step import
statistics
export
a:sfloat
b:int8
c:int8
d:dfloat
e:sfloat
f:decimal
g:decimal
h:int8
307
) If you wish to modify this example to specify that each record is to be delimited by a comma (,) you would add the record-level property delim = ,:
record {delim = ,} ( a:sfloat; b:int8; c:int8; d:dfloat; e:sfloat; f:decimal[1,0]; g:decimal[1,0]; h:int8;
) The same property delim = , could be used as a field-level property, for example:
record ( a:sfloat; b:int8 {delim = ,}; c:int8; d:dfloat; e:sfloat; f:decimal[1,0]; g:decimal[1,0]; h:int8;
) In this case, only field b would be delimited by a comma. For export, the other fields would be followed by the default delimiter, the ascii space (0x20). These brief examples only scratch the surface of schema definition. See Import/Export Properties for more information on record and field properties.
c:int8
f:decimal
The use of partial record schemas has advantages and disadvantages, which are summarized in the following table.
308
Advantages Partial record schemas are simpler than complete record schemas, because you define only the fields of interest in the record. The import operator reads these records faster than records with a complete schema because it does not have to interpret as many field definitions.
Disadvantages WebSphere DataStage treats the entire imported record as an atomic object; that is, WebSphere DataStage cannot add, remove, or modify the data storage within the record. (WebSphere DataStage can, however, add fields to the beginning or end of the record.)
complete
WebSphere DataStage can add fields The import operator takes longer to to the body of the record and remove read records with a complete schema or modify any existing field. than records with a partial schema. Removing fields from a record allows you to minimize its storage requirement.
The record schema defines an 82-byte record as specified by the record_length=82 property. The 82 bytes includes 80 bytes of data plus two bytes for the newline and carriage-return characters delimiting the record as specified by record_delim=\r\n. No information is provided about any field. On import, the two bytes for the carriage-return and line-feed characters are stripped from each record of the data set and each record contains only the 80 bytes of data. An imported record with no defined fields can be used only with keyless partitioners, collectors, and operators. The term keyless means that no individual fields of the record must be accessed in order for it to be processed. WebSphere DataStage supplies keyless operators to: v Copy a data set v Sample a data set to create one or more output data sets containing a random sample of records from the input data set v Combine multiple input data sets into a single output data set v Compress or decompress a data set. In addition, you can use keyless partitioners, such as random or same, and keyless collectors, such as round-robin, with this type of record. An imported record with no defined fields cannot be used for field-based processing such as: v Sorting the data based on one or more key fields, such as a name or zip code v Calculating statistics on one or more fields, such as income or credit card balance v Creating analytic models to evaluate your data A record with no field definitions may be passed to an operator that runs UNIX code. Such code typically has a built-in record and field processing ability. You can define fields in partial schemas so that field-based processing can be performed on them. To do so, define only the fields to be processed. For example, the following partial record schema defines two fields of a record, Name and Income, thereby making them available for use as inputs to partitioners, collectors, and other operators.
Chapter 8. The import/export library
309
record { intact, record_length=82, record_delim_string=\r\n } (Name: string[20] { position=12, delim=none }; Income: int32 { position=40, delim=,, text }; )
In this schema, the defined fields occur at fixed offsets from the beginning of the record. The Name field is a 20-byte string field starting at byte offset 12 and the Income field is a 32-bit integer, represented by an ASCII text string, that starts at byte position 40 and ends at the first comma encountered by the import operator. When variable-length fields occur in the record before any fields of interest, the variable-length fields must be described so that the import or export operator can determine the location of a field of interest. Note: When variable-length fields occur in the record before any fields of interest, the variable-length fields must be described so that the import and export operators can determine the location of a field of interest. For example, suppose that the record schema shown above is modified so that the Name and Income fields follow variable-length fields (V1, V2, and V3). Instead of fixed offsets, the Name and Income fields have relative offsets, based on the length of preceding variable-length fields. In this case, you specify the position of the Name and Income fields by defining the delimiters of the variable-length fields, as in the following example:
record { intact, record_delim_string=\r\n } ( v1: string { delim=, }; v2: string { delim=, }; Name: string[20] { delim=none }; v3: string { delim=, }; Income: int32 { delim=,, text }; )
In order to export this data set using the original record schema and properties, you specify an empty record schema, as follows:
record ()
310
This empty record schema causes the export operator to use the original record schema and properties. However, defining any record property in the export schema overrides all record-level properties specified at import. That is, all record-level properties are ignored by the export operator. For example, if you specify the following record schema to the export operator:
record { record_delim=\n } ()
the intact record is exported with a newline character as the delimiter. The carriage-return character (\r) is dropped. Each exported record is 81 bytes long: 80 bytes of data and one byte for the newline character. Intact record with additional fields: When a schema being exported consists of multiple intact records or one intact record together with other fields, consider each intact record to be a separate field of the exported record. For example, consider a data set with the following record schema:
record ( a: int32; b: string; x: record {intact, record_delim=\r\n, text, delim=,,} (name: string[20] { position=0 }; address: string[30] { position=44 }; ); y: record {intact, record_length=244, binary, delim=none } (v1: int32 { position=84 }; v2: decimal(10,0) { position=13 }; ); )
The data set contains two intact fields, x and y, and two other fields, a and b. The intact fields retain all properties specified at the time of the import. When this type of data set is exported, the record-level properties for each intact field (specified in braces after the key word record) are ignored and you must define new record-level properties for the entire record. For example, if you want to export records formatted as follows: v a two-byte prefix is written at the beginning of each record v v v v the fields are ordered x, y, and a; field b is omitted a comma is added after x y has no delimiter a is formatted as binary.
Note that you do not include the fields of the x and y intact records in the export schema because the entire intact record is always exported. However, this export schema does contain field-level properties for the intact records to control delimiter insertion.
311
No schema is specified, so WebSphere DataStage uses the default schema (See The Default Import Schema and The Default Export Schema ). The diagram shows the data flow model of this step. WebSphere DataStage automatically performs the import operation required to read the flat file.
312
pcompress
outDS1.ds
copy
pcompress
outDS1.ds
compressed.ds
Implicit operator insertion also works for export operations. The following example shows the tsort operator writing its results to a data file, again with no schema specified:
$ osh "tsort -key a -hash -key b < inDS.ds > result.dat"
The output file does not end in the extension .ds, so WebSphere DataStage inserts an export operator to write the output data set to the file. The examples of implicit import/export insertion shown so far all use the default record schemas. However, you can also insert your own record schema to override the defaults.
Chapter 8. The import/export library
313
The next sections discuss: v The Default Import Schema v The Default Export Schema v Overriding the Defaults
The following figure shows the record layout of the source data as defined by the default import schema:
default record layout of source data record contents \n
After the import operation, the destination data set contains a single variable-length string field named rec corresponding to the entire imported record, as follows:
variable-length string named rec
This record schema causes WebSphere DataStage to export all fields as follows: v Each field except the last field in the record is delimited by an ASCII space (0x20) v The end of the record (and thus the end of the last field) is marked by the newline character (\n) v All fields are represented as text (numeric data is converted to a text representation). For example, the following figure shows the layout of a data set record before and after export when the default export schema is applied:
record in the source data set: int16 string[8] string[2] int32
record after export as stored in data file: int16 as text 0x20 string[8] 0x20 string[2] 0x20 int32 as text \n
314
v A text file and a reference to the file in the command line, as in the following example:
$ osh "copy < [record @schema_file] user.dat > outDS1.ds | pcompress > compressed.ds"
where schema_file is the name of the text file containing the record schema definition. You can specify a schema anywhere on an osh command line by using this notation:
[record @schema_file].
A schema variable defined upstream of a command, and subsequently input to the command, as in the following example:
$ import_schema="record ( Name:string; Age:int8 {default = 127}; Income:dfloat {skip = 2}; Phone:string; )" $ osh "copy < [$import_schema] user.dat > outDS1.ds | pcompress > compressed.ds"
All implicit import/export operations in the command use that schema. However, you can override it for a particular data file by preceding the specification of a flat file with a different record schema. To define formatting properties of records as a whole rather than as individual fields in an export operation, use this form:
record {record_properties} ()
In this case, the export operator exports all the fields of the data set formatted according to the record properties specified in the braces.
Failure
A failure means that both: v The import or export operator failed to read or write the records value correctly. v The error makes it unlikely that the rest of the record can be interpreted. An example of such a failure occurs when the import operator encounters an invalid length value of a variable-length field. On import, by default, an uninterpretable field is not written to the destination data set and processing continues to the next record. On export, by default, an uninterpretable field is not written to the destination file and processing continues to the next record. However, you can configure the import and export operators to save records causing a failure in a reject data set. You can also configure the operators to terminate the job in the event of a failure. See Import Operator and Export Operator . WebSphere DataStage issues a message in the case of a failure. v The message appears for up to five records in a row, for each partition of the imported or exported data set, when the same field causes the failure. v After the fifth failure and message, messages no longer appear. v After a record is successfully processed, the message counter is reset to zero and up to five more error messages per partition can be generated for the same field.
Chapter 8. The import/export library
315
Note: No more than 25 failure messages can be output for the same failure condition during an import or export operation.
Warning
A warning means that the import operator or export operator failed to read or write the records value correctly but that the import or export of that record can continue. An example of a warning condition is a numeric field represented as ASCII text that contains all blanks. When such a condition occurs, the import or export operator does not issue a message and by default drops the record. To override this behavior, define a default value for the field that causes the warning. If you have defined a default value for the record field that causes the warning: v The import operator sets the field to its default value, writes the record to the destination data set, and continues with the next record. v The export operator sets the field to its default value, exports the record, and continues with the next record.
EBCDIC to ASCII
The following table is an EBCDIC-to-ASCII conversion table that translates 8-bit EBCDIC characters to 7-bit ASCII characters. All EBCDIC characters that cannot be represented in 7 bits are represented by the ASCII character 0x1A. This translation is not bidirectional. Some EBCDIC characters cannot be translated to ASCII and some conversion irregularities exist in the table. See Conversion Table Irregularities for more information.
EBCDIC 00 01 02 03 04 05 06 07 08 09 0A 0B ASCII 00 01 02 03 1A 09 1A 7F 1A 1A 1A 0B EBCDIC Meaning NUL SOH STX ETX SEL HT RNL DEL GE SPS RPT VT EBCDIC 80 81 82 83 84 85 86 87 88 89 8A 8B ASCII 1A 61 62 63 64 65 66 67 68 69 1A 1A a b c d e f g h i EBCDIC Meaning
316
EBCDIC 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33
ASCII 0C 0D 0E 0F 10 11 12 13 1A 1A 08 1A 18 19 1A 1A 1C 1D 1E 1F 1A 1A 1A 1A 1A 0A 17 1B 1A 1A 1A 1A 1A 05 06 07 1A 1A 16 1A
EBCDIC Meaning FF CR SO SI DLE DC1 DC2 DC3 RES/ENP NL BS POC CAN EM UBS CU1 IFS IGS IRS ITB/IUS DS SOS FS WUS BYP/INP LF ETB ESC SA SFE SM/SW CSP MFA ENQ ACK BEL
EBCDIC 8C 8D 8E 8F 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF B0 B1
ASCII 1A 1A 1A 1A 1A 6A 6B 6C 6D 6E 6F 70 71 72 1A 1A 1A 1A 1A 1A 1A 7E 73 74 75 76 77 78 79 7A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A
EBCDIC Meaning
j k l m n o p q r
s t u v w x y z
SYN IR
B2 B3
317
EBCDIC 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B
ASCII 1A 1A 1A 04 1A 1A 1A 1A 14 15 1A 1A 20 1A 1A 1A 1A 1A 1A 1A 1A 1A 5B 2E 3C 28 2B 21 26 1A 1A 1A 1A 1A 1A 1A 1A 1A 5D 24
EBCDIC Meaning PP TRN NBS EOT SBS IT RFF CU3 DC4 NAK
EBCDIC B4 B5 B6 B7 B8 B9 BA BB BC BD BE
ASCII 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 1A 7B 41 42 43 44 45 46 47 48 49 1A 1A 1A 1A 1A 1A 7D 4A 4B 4C 4D 4E 4F 50 51 52 1A 1A
EBCDIC Meaning
BF C0 C1 C2 C3 C4 C5 C6 C7 C8 C9
A B C D E F G H I
. < ( + | &
CA CB CC CD CE CF D0 D1 D2 D3 D4 D5 D6 D7 D8 D9
J K L M N O P Q R
! $
DA DB
318
EBCDIC 5C 5D 5E 5F 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
ASCII 2A 29 3B 5E 2D 1A 1A 1A 1A 1A 1A 1A 1A 1A 7C 2C 25 5F 3E 3F 1A 1A 1A 1A 1A 1A 1A 1A 1A 60 3A 23 40 27 3D 22
EBCDIC Meaning * ) ; .. _ /
EBCDIC DC DD DE DF E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA
ASCII 1A 1A 1A 1A 5C 1A 53 54 55 56 57 58 59 5A 1A 1A 1A 1A 1A 1A 30 31 32 33 34 35 36 37 38 39 1A 1A 1A 1A 1A 1A
EBCDIC Meaning
S T U V W X Y Z
EB EC
> ?
ED EE EF F0 F1 F2 F3 F4 F5 F6 F7 F8 F9
0 1 2 3 4 5 6 7 8 9
: # @ =
FA FB FC FD FE FF
319
ASCII to EBCDIC
ASCII to EBCDIC is an ASCII-to-EBCDIC conversion table that translates 7-bit ASCII characters to 8-bit EBCDIC characters. This translation is not bidirectional. Some EBCDIC characters cannot be translated to ASCII and some conversion irregularities exist in the table. For more information, see Conversion Table Irregularities .
Table 15. ASCII to EBCDIC Conversion ASCII 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 EBCDIC 00 01 02 03 1A 09 1A ASCII Meaning ASCII 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F 60 61 62
Parallel Job Advanced Developer Guide
EBCDIC
ASCII Meaning
320
Table 15. ASCII to EBCDIC Conversion (continued) ASCII 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F EBCDIC ASCII Meaning ASCII 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F EBCDIC ASCII Meaning
321
Import operator
The import operator reads one or more non-DataStage source files and converts the source data to a destination WebSphere DataStage data set.
import
user defined
reject:raw;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Preserve-partitioning flag in output data set(s) Composite operator Value 0 1, or 2 if you specify optional data sets none output data set 0: user defined reject data set: reject:raw; none parallel or sequential clear by default no
322
The import operator: v Takes one or more files or named pipes as input. You can import data from one or more sources, provided all the imported data has the same record layout. v Writes its results to a single output data set. v Allows you to specify an optional output data set to hold records that are not successfully imported. v Has an output interface schema corresponding to the import schema of the data files read by the operator. The import operator can import source files containing several types of data: v Data in variable-length blocked/spanned records: Imported records have a variable-length format. This format is equivalent to IBM format-V, format-VS, format-VB, and format-VBS files. v Data in fixed-length records: This format is equivalent to IBM format-F and format-FB files. v Data in prefixed records: Records fields are prefixed by a length indicator. Records can be of either fixed or variable length. v Delimited records: Each record in the input file is separated by one or more delimiter characters (such as the ASCII newline character \n). Records can be of either fixed or variable length. v Implicit: Data with no explicit record boundaries. WebSphere DataStage accepts a variety of record layouts. For example, a data file may represent integers as ASCII strings, contain variable-length records, or represent multi-byte data types (for example, 32-bit integer) in big-endian or little-endian format. See Import/Export Properties for more information on data representation. When the import operator imports a fixed-length string or ustring that is less-than or greater-than the declared schema length specification, an error is generated.
The following option values can contain multi-byte Unicode values: v the file names given to the -file, -schemafile, and -sourcelist options v the base file name for the -fileset option v -schema option schema v the program name and arguments for the -source option v the -filepattern pattern
Chapter 8. The import/export library
323
v the -filter command There are two types of required options. v You must include one of the following options to specify the imported files: -file, -filepattern, -fileset, -source, -sourcelist. v You must include either -schema or -schemafile to define the layout of the imported data unless you specify -fileset and it contains a schema. You can select only one of these three options. You can optionally include other arguments.
Option -checkpoint Use -checkpoint n Import n records per segment to the output data set. (A data segment contains all records written to a data set by a single WebSphere DataStage step.) By default, the value of n is 0, that is, the entire input is imported for each iteration of the step. If the step containing the import operator performs multiple iterations, the output data set of the import operator contains multiple copies of the input data. The source files of the import operation must all be data files or source programs, that is, no pipes or other input devices can be used. In addition, you cannot specify a filter on the input. An import operator that creates a segmented output data set must be contained in a checkpointed step. -dontUseOffsetsWith Sources -dontUseOffsetsWithSources Start the source programs output stream at 0. Do not use this option with checkpointing. -file -file nodeName :file0 ... -file nodeName :filen Specifies an input file or pipe. You can include multiple -file options to specify multiple input files. The file names may contain multi-byte Unicode characters. Note: You can specify a hyphen to signal that import takes its input from the stdin of osh. nodeName optionally specifies the name of the node on which the file is located. If you omit nodeName , the importer assumes that the file is located on the node on which the job is invoked. You cannot use -file with -filepattern, -fileset, -source, or -sourcelist.
324
Option -filepattern
Use -filepattern pattern Specifies a group of files to import. For example, you can use the statement: -filepattern data*.txt You cannot use -filepattern with the -file, -fileset, -source, -sourcelist or -readers options.
-fileset
-fileset file_set .fs Specifies file_set .fs, a file containing a list of files, one per line, used as input by the operator. The suffix .fs identifies the file to WebSphere DataStage as a file set. See File Sets . file_set may contain multi-byte Unicode characters. To delete a file set and the data files to which it points, invoke the WebSphere DataStage data set administration utility, orchadmin. You cannot use -fileset with -file, -filepattern, -source, or -sourcelist.
-filter
-filter command Specifies a UNIX command to process input files as the data is read from a file and before it is converted into the destination data set. The command may contain multi-byte Unicode characters. For example, you could specify the following filter: -filter grep 1997 to filter out all records that do not contain the string 1997. Note that the source data to the import operator for this example must be newline-delimited for grep to function properly. WebSphere DataStage checks the return value of the -filter process, and errors out when an exit status is not OK. You cannot use -filter with -source.
325
Option -first
Use [-first n ] This option imports the first n records of a file. This option does not work with multiple nodes, filesets, or file patterns. It does work with multiple files and with the -source and -sourcefile options when file patterns are specified. Here are some osh command examples: osh import -file file1 -file file2 -first 10 >| outputfile osh import -source cat file1 -first 10 >| outputfile osh import -sourcelist sourcefile -first 10 >| outputfile osh import -file file1 -first 5 >| outputfile
-firstLineColumnNames
[-firstLineColumnNames] Specifies that the first line of a source file should not be imported.
-keepPartitions
-keepPartitions Partitions the imported data set according to the organization of the input file(s). By default, record ordering is not preserved, because the number of partitions of the imported data set is determined by the configuration file and any constraints applied to the data set. However, if you specify -keepPartitions, record ordering is preserved, because the number of partitions of the imported data set equals the number of input files and the preserve-partitioning flag is set in the destination data set.
-missingFile
-missingFile error | okay Determines how the importer handles a missing input file. By default, the importer fails and the step terminates if an input file is missing (corresponding to -missingFile error). Specify -missingFile okay to override the default. However, if the input file name has a node name prefix of *, missing input files are ignored and the import operation continues. (This corresponds to -missingFile okay.)
-multinode
[ -multinode yes | no ] -multinode yes specifies the input file is to be read in sections from multiple nodes; -multinode no, the default, specifies the file is to be read by a single node.
326
Option -readers
Use -readers numReaders Specifies the number of instances of the import operator on each processing node. The default is one operator per node per input data file. If numReaders is greater than one, each instance of the import operator reads a contiguous range of records from the input file. The starting record location in the file for each operator (or seek location) is determined by the data file size, the record length, and the number of instances of the operator, as specified by numReaders , which must be greater than zero. All instances of the import operator for a data file run on the processing node specified by the file name. The output data set contains one partition per instance of the import operator, as determined by numReaders . The imported data file(s) must contain fixed-length records (as defined by the record_length=fixed property). The data source must be a file or files. No other devices are allowed. This option is mutually exclusive with the filepattern option.
-recordNumberField
-recordNumberField recordNumberFieldName Adds a field with field name recordNumberFieldName with the record number as its value.
-rejects
-rejects { continue | fail | save } Configures operator behavior if a record is rejected. The default behavior is to continue. Rejected records are counted but discarded. The number of rejected records is printed as a log message at the end of the step. However, you can configure the operator to either fail and terminate the job or save, that is, create output data set 1 to hold reject records. If -rejects fail is specified and a record is not successfully imported, the import operator issues an error and the step terminates. If -rejects fail is not specified and a record is not successfully imported, the import operator issues a warning and the step does not terminate.
-reportProgress
-reportProgress { yes | no } By default (yes) the operator displays a progress report at each 10% interval when the importer can ascertain file size. Reporting occurs only if: import reads a file as opposed to a named pipe, the file is greater than 100 KB, records are fixed length, and there is no filter on the file. Disable this reporting by specifying -reportProgress no.
327
Option -schema
Use -schema record_schema Specifies the import record schema. The value to this option may contain multi-byte Unicode characters. You can also specify a file containing the record schema using the syntax: -schema record @file_name where file_name is the path name of the file containing the record schema. You cannot use -schema with -schemafile.
-schemafile
-schemafile file_name Specifies the name of a file containing the import record schema. It may contain multi-byte Unicode characters. You cannot use -schemafile with -schema.
-sourceNameField
-sourceNameField sourceStringFieldName Adds a field named sourceStringFieldName with the import source string as its vaue
328
Option -source
Use -source prog_name args Specifies the name of a program providing the source data to the import operator. WebSphere DataStage calls prog_name and passes to it any arguments specified. prog_name and args may contain multi-byte Unicode characters. You can specify multiple -source arguments to the operator. WebSphere DataStage creates a pipe to read data from each specified prog_name . You can prefix prog_name with either a node name to explicitly specify the processing node that executes prog_name or a node name prefix of *, which causes WebSphere DataStage to run prog_name on all processing nodes executing the operator. If this import operator runs as part of a checkpointed step, as defined by -checkpoint, WebSphere DataStage calls prog_name once for each iteration of the step. WebSphere DataStage always appends three arguments to prog_name as shown below: prog_name args -s H L where H and L are 32-bit integers. H and L are set to 0 for the first step iteration or if the step is not checkpointed. For each subsequent iteration of a checkpointed step, H and L specify the (64-bit) byte offset ( H = upper 32 bits, L = lower 32 bits) at which the source programs output stream should be restarted. At the end of each step iteration, prog_name receives a signal indicating a broken pipe. The prog_name can recognize this signal and perform any cleanup before exiting. WebSphere DataStage checks the return value of the -source process, and errors out when an exit status is not OK. You cannot use -source with -filter, -file, -filepattern, or -fileset.
329
Option -sourcelist
Use -sourcelist file_name Specifies a file containing multiple program names to provide source data for the import. This file contains program command lines, where each command line is on a separate line of the file. file_name may contain multi-byte Unicode characters. WebSphere DataStage calls the programs just as if you specified multiple -source options. See the description of -source for more information. You cannot use -sourcelist with -filter, -file, -filepattern, or -fileset.
330
Note: For external sequential data files (as opposed to WebSphere DataStage file sets) that are to be processed by a UNIX custom operator that functions in parallel, first import the data sequentially and then export it in parallel using the file *.file_name option. The wild card ensures that the operator writes to the file on every node on which it executes. (See Export Operator.)
File sets
A file set is a text file containing a list of source files to import. The file set must contain one file name per line. The name of the file has the form file_name.fs, where .fs identifies the file to WebSphere DataStage as a file set. Specify the -fileset option and the path name of the file set. Shown below is a sample file set:
--Orchetsrate File Set v1 --LFile node0:/home/user1/files/file0 node0:/home/user1/files/file1 node0:/home/user1/files/file2 --LFile node1:/home/user1/files/file0 node1:/home/user1/files/file1 --Schema record {record_delim="\n"} ( a:int32; b:int32; c:int16; d:sfloat; e:string[10]; )
The first line of the file set must be specified exactly as shown above. The list of all files on each processing node must be preceded by the line --LFile and each file name must be prefixed by its node name. A file set can optionally contain the record schema of the source files as the last section, beginning with --Schema. If you omit this part of the file set, you must specify a schema to the operator by means of either the -schema or -schemafile option.
File patterns
A file pattern specifies a group of similarly named files from which to import data. The wild card character allows for variations in naming. For example, the file pattern inFile*.data imports files that begin with the inFile and end with .data. The file names can contain multi-byte Unicode characters. For example, to import the data from the files that match the file pattern state*.txt, use the statement:
-filepattern state*.txt
331
The operator assumes that path_name is relative to the working directory from which the job was invoked. You can also indicate one of these: v A specific processing node on which the operator runs. Do this by specifying the nodes name. When you do, WebSphere DataStage creates an instance of the operator on that node to read the path_name. The nodeName must correspond to a node or fastname parameter of the WebSphere DataStage configuration file. v All processing nodes on which the operator runs. Do this by specifying the asterisk wild card character (*). When you do, WebSphere DataStage reads path_name on every node on which the operator is running. For example, you can supply the following specification as the file pattern on the osh command line:
*:inFile*.data
This imports all files of the form inFile*.data residing on all processing nodes of the default node pool. You can include a relative or absolute path as part of inFile. If you do not supply an absolute path, import searches for the files on all nodes using the same current working directory as the one from which you invoked the job.
332
inFile.dat
step import
333
inFile0.dat
inFile1.dat
step import
The format of the source file and the import schema are the same as those in Example 1: Importing from a Single Data File and the step similarly contains a single instance of the import operator. However, this example differs from the first one in that it imports data from two flat files instead of one and does not save records that cause an error into a reject data set. Specify the data flow with the following osh code:
$ osh "import -file inFile0.data -file inFile1.data -schema $example1_schema > outDS.ds "
Export operator
The export operator exports a WebSphere DataStage data set to one or more UNIX data files or named pipes located on one or more disk drives.
334
inRec:*;
export
outRec:*;
Properties
Property Number of input data sets Number of output data sets Input interface schema Output interface schema Transfer behavior Execution mode Partitioning method Collection method Preserve-partitioning flag in output data set(s) Composite operator Value 1 0 or 1 inRec:*; plus user-supplied export schema output files: none reject data set: outRec:*; inRec -> outRec if you specify a reject data set parallel any any clear yes
The export operator: Takes a single WebSphere DataStage data set as input. Writes its results to one or more output files. Allows you to specify an optional output data set to hold records that cause a failure. Takes as its input interface schema the schema of the exported data. Generates an error and terminates if you try to write data to a file that is not empty. (This behavior can be overridden.) v Deletes files already written if the step of which it is a part fails. (This behavior can be overridden.) v v v v v The source data set may be persistent (stored on disk) or virtual (not stored on disk).
Chapter 8. The import/export library
335
The export operator writes several formats of exported data, including: v Fixed-length records: a fixed-length format equivalent to IBM format-F and format-FB files. v Data in prefixed records: Record fields are prefixed by a length indicator. Records can be of either fixed or variable length. v Delimited records: A delimiter such as the ASCII line feed character is inserted after every record. Records can be of either fixed or variable length. v Implicit: No explicit boundaries delimit the record. Note: The export operator does not support variable-length blocked records (IBM format-VB or format-VBS). WebSphere DataStage accepts a variety of record layouts for the exported file. For example, a data file may represent integers as ASCII strings, contain variable-length records, or represent multi-byte data types in big-endian or little-endian format. See Import/Export Properties for more information. Note: When your character setting if UTF-16, the export operator appends and prepends the byte-order mark OxfeOxff0x00 to every column value.
The following option values can contain multi-byte Unicode characters: -file and -destinationlist file names and the base name of the file for the -fileset option program name and arguments to the -destination option -schema option schema and the schema filename given to the -schemafile option prefix value given to the -prefix option, and the suffix value given to the -suffix option -filter option command value given to the -diskpool option
There are two types of required options: v You must include exactly one of the following to specify the exported files: -file, -fileset, -destination, or -destinationlist. v You must include exactly one of -schema or -schemafile to define the layout of the exported data.
336
Table 16. Export operator options Option -add_bom Use -add_bom { utf16be | utf16le | utf8 } With this option you can add a BOM to your exported file. The utf16be value specifies FE FF, utf16le specifies FF FE, and utf8 specifies EF BB BF. -append -append Append exported data to an existing file. By default the step terminates if you attempt to export data to a file that is not empty. This option overrides the default behavior. You cannot use this option with -overwrite. -destination -destination prog_name [args] In single quotation marks specify the name of a program that reads the data generated by the export operator. Specify the programs arguments, if any. WebSphere DataStage calls prog_name and passes to it any specified arguments. You can specify multiple -destination options to the operator: for each -destination, specify the option and supply the prog_name and args (if any). The prog_name and args values may contain multi-byte Unicode values. If this export operator runs as part of a checkpointed step, WebSphere DataStage calls prog_name once for each iteration of the step. WebSphere DataStage always appends three additional arguments to prog_name: prog_name [ args ] -s H L where H and L are 32-bit integers. For the first step iteration, or if the step is not checkpointed, H and L are set to 0. For each subsequent iteration of a checkpointed step, H and L specify the (64-bit) byte offset (H = upper 32 bits, L = lower 32 bits) of the exported data in the total export stream from the operator. After all data has been written to the program, prog_name is called once more with an appended switch of -e (corresponding to end of file) and is not passed the -s switch. On last call prog_name can perform any final operation, for example, write a trailing label to a tape. If the export operation fails, WebSphere DataStage calls prog_name once with the appended switch -c (cleanup) and no -s switch. This gives the program an opportunity to clean up. You cannot use this option with -filter. -destinationlist -destinationlist file_name Specifies in single quotation marks file_name, the name of a file containing the names of multiple destination programs, where each command line is listed on a separate line of the file. file_name may contain multi-byte Unicode characters. WebSphere DataStage calls the programs as if you specified multiple -destination options. See the description of -destination for more information. -dontUseOffsetsWith Destinations -dontUseOffsetsWithDestinations Do not supply the -s, H, L arguments to destination programs. This means that the byte offset is always 0. See the -destination option for more information.
337
Table 16. Export operator options (continued) Option -file Use -file [nodeName:]outFile0 Supply the name of an output file or pipe. The file or pipe must be empty unless you specify either the -append or -overwrite option. You can include multiple -file options to specify multiple input files. For each one, specify -file and supply the file name. The file name can contain multi-byte Unicode characters. Note: You can specify a hyphen to signal that export writes its output to the stdout for osh. You cannot use this option with -fileset.
338
Table 16. Export operator options (continued) Option -fileset Use -fileset filesetName.fs {-create | -replace | -discard_records |-discard_schema_and_records} [-diskpool diskpool] [-maxFileSize numMB] [-prefix prefix] [-single[FilePerPartition]] [-suffix suffix] [-writeSchema | -omitSchema] Specifies the name of the file set, filesetName, a file into which the operator writes the names of all data files that it creates. The suffix .fs identifies the file to WebSphere DataStage as a file set. filesetName can contain multi-byte Unicode characters. The name of each export file generated by the operator is written to filesetName.fs, one name per line. The suboptions are: -create: Create the file set. If it already exists, this option generates an error. -replace: Remove the existing fileset and replace it with a new one. -discard_records: Keep the existing files and schema listed in filesetName .fs but discard the records; create the file set if it does not exist. -discard_schema_and_records: Keep existing files listed in filesetName .fs but discard the schema and records; create the file set if it does not exist. The previous suboptions are mutually exclusive with each other and also with the -append option. -diskpool diskpool: Specify the name of the disk pool into which to write the file set. diskpool can contain multi-byte Unicode characters. -maxFileSize numMB: Specify the maximum file size in MB. Supply integers. The value of numMB must be equal to or greater than 1. -omitSchema: Omit the schema from filesetName .fs. The default is for the schema to be written to the file set. -prefix: Specify the prefix of the name of the file set components. It can contain multi-byte Unicode characters. If you do not specify a prefix, the system writes the following: export username, where username is your login. -replace: Remove the existing file set and create a new one. -singleFilePerPartition: Create one file per partition. The default is to create many files per partition. This can be shortened to -single. -suffix suffix: Specify the suffix of the name of the file set components. It can contain multi-byte Unicode characters. The operator omits the suffix by default. -writeSchema: Use only with -fileset. Write the schema to the file set. This is the default.9 You cannot use -fileset with -file or -filter. File Sets discusses file sets. -firstLineColumnNames [-firstLineColumnNames] Specifies that column names be written to the first line of the output file. -nocleanup -nocleanup Configures the operator to skip the normal data file deletion if the step fails. By default, the operator attempts to delete partial data files and perform other cleanup operations on step failure.
339
Table 16. Export operator options (continued) Option -overwrite Use -overwrite The default action of the operator is to issue an error if you attempt to export data to a file that is not empty. Select -overwrite to override the default behavior and overwrite the file. You cannot use this option with -append or -replace. -rejects -rejects continue | fail | save Configures operator behavior if a record is rejected. The default behavior is to continue. Rejected records are counted but discarded. The number of rejected records is printed as a log message at the end of the step. However, you can configure the operator to either fail and terminate the job or save, that is, create output data set 0 to hold reject records. If you use -rejects fail, osh generates an error upon encountering a record that cannot be successfully exported; otherwise osh generates a warning upon encountering a record that cannot be successfully exported. -schema -schema record_schema Specifies in single quotation marks the export record schema. You can also specify a file containing the record schema using the syntax: -schema record @file_name where file_name is the path name of the file containing the record schema. The file_name and record_schema can contain multi-byte Unicode characters. You cannot use this option with -schemafile. -schemafile -schemafile schema_file Specifies in single quotation marks the name of a file containing the export record schema. The file name can contain multi-byte Unicode characters. This is equivalent to: -schema record @ schema_file You cannot use this option with -schema. -filter -filter command Specifies a UNIX command to process all exported data after the data set is exported but before the data is written to a file. command can contain multi-byte Unicode characters. You cannot use this option with -fileset or -destination.
340
v The properties of exported fields v The order in which they are exported The export operator writes only those fields specified by the export schema and ignores other fields, as in the following example, where the schema of the source WebSphere DataStage data set differs from that of the exported data:
Table 17. Example: Data Set Schema Versus Export Schema Source WebSphere DataStage Data Set Schema record ( Name: string; Address: string; State: string[2]; Age: int8; Gender: string[1]; Income: dfloat; Phone: string; ) Export Schema record ( Gender: string[1]; State: string[2]; Age: int8; Income: dfloat; )
In the example shown above, the export schema drops the fields Name, Address, and Phone and moves the field Gender to the beginning of the record. Note: If you do not provide a schema, WebSphere DataStage assumes that exported data is formatted according to the default schema discussed in The Default Export Schema . Here is how you set up export schemas: v To export all fields of the source record and format them according to the default export schema, specify the following: v record ( ) v Refer to The Default Export Schema . v To export all fields of the source record but override one or more default record properties, add new properties, or do both, specify:
record {record_properties} ()
v Refer to Import/Export Properties to learn about setting up record and field properties. v To export selected fields of the source record, define them as part of the schema definition, as follows:
record ( field_definition0; ... field_definitionN;)
v where field_definition0; ... field_definitionN are the fields chosen for export. No record-level properties have been defined and the default export schema is applied. v You can define properties for records and for fields, as in the following example:
record {delim = none, binary} ( Name:string {delim = ,}; Age:int8 {default = 127}; Address:subrec ( Street:string[64]; City:string[24]; State:string[4]; ); Zip:string[12]; Phone:string[12]; )
Refer to Import/Export Properties to learn about setting up record and field properties. Refer to the following sections for a discussion of schemas as they pertain to import/export operations: Record Schemas andComplete and Partial Schemas .
341
v A programs input (see Destination programs input on page 343 ) v The input to several programs defined in a destination list (see List of destination programs on page 343 ). You can also explicitly specify the nodes and directories to which the operator exports data (see Nodes and directories on page 343 ).
File sets
The export operator can generate and name exported files, write them to their destination, and list the files it has generated in a file whose extension is .fs. The data files and the file that lists them are called a file set. They are established by means of the fileset option. This option is especially useful because some operating systems impose a 2 GB limit on the size of a file and you must distribute the exported files among nodes to prevent overruns. When you choose -fileset, the export operator runs on nodes that contain a disk in the export disk pool. If there is no export disk pool, the operator runs in the default disk pool, generating a warning when it does. However, if you have specified a disk pool other than export (by means of the -diskpool option), the operator does not fall back and the export operation fails. The export operator writes its results according to the same mechanism. However, you can override this behavior by means of the -diskpool option. The amount of data that may be stored in each destination data file is limited (typically to 2 GB) by the characteristics of the file system and the amount of free disk space available. The number of files created by a file set depends on: v The number of processing nodes in the default node pool v The number of disks in the export or default disk pool connected to each processing node in the default node pool v The size of the partitions of the data set You name the file set and can define some of its characteristics. The name of the file set has the form file_name.fs, where .fs identifies the file as a file set to WebSphere DataStage. Specify the -fileset option and the path name of the file set. Note: When you choose -fileset, the export operator names the files it generates and writes the name of each one to the file set. By contrast, you have to name the files when you choose the -file option. The names of the exported files created by the operator have the following form:
nodeName : dirName /prefixPXXXXXX_FYYYYsuffix
where:
342
v nodeName is the name of the node on which the file is stored and is written automatically by WebSphere DataStage. v dirName is the directory path and is written automatically by WebSphere DataStage. v prefix is by default export.userName, where userName is your login name, and is written automatically by WebSphere DataStage. However, you can either define your own prefix or suppress the writing of one by specifying as the prefix. v XXXXXX is a 6-digit hexadecimal string preceded by P specifying the partition number of the file written by export. The first partition is partition 000000. The partition numbers increase for every partition of the data set but might not be consecutive. v YYYY is a 4-digit hexadecimal string preceded by F specifying the number of the data file in a partition. The first file is 0000. The file numbers increase for every file but might not be consecutive. v WebSphere DataStage creates one file on every disk connected to each node used to store an exported partition. v suffix is a user-defined file-name suffix. By default, it is omitted. For example, if you specify a prefix of file and a suffix of _exported, the third file in the fourth partition would be named:
node1:dir_name/fileP000003_F0002_exported
Some data sets, such as sorted data sets, have a well-defined partitioning scheme. Because the files created by the export operator are numbered by partition and by data file within a partition, you can sort the exported files by partition number and file number to reconstruct your sorted data.
If you omit the optional node name, the operator exports files or named pipes only to the processing node on which the job was invoked. If you specify only the file name the operator assumes that path_name is relative to the working directory from which the job was invoked. You can also indicate one of these:
343
v A specific processing node to which the output is written. Do this by specifying the nodes name. The nodeName must correspond to a node or fastname parameter of the WebSphere DataStage configuration file. v All processing nodes on which the operator runs. Do this using the asterisk wild card character (*). When you do, WebSphere DataStage writes one file to every node on which the operator is running. For example, you can supply the following as the exported file name on the osh command line:
*:outFile.data
This exports data to files called outFile.data, which are created on all processing nodes on which the operator runs. The name outFile.data is a relative path name and the exporter writes files using the same current working directory as the one from which you invoked the job.
exported file
The following osh code specifies the layout of the destination data file:
$ exp_example_1="record {delim = none, binary} ( Name:string {delim = ,}; Age:int8 {default = 127}; Address:subrec ( Street:string[64]; City:string[24]; State:string[4]; ); Zip:string[12]; Phone:string[12]; )"
In this schema, the export operator automatically inserts a newline character at the end of each record according to the default. However, numeric data is exported in binary mode and no field delimiters are present in the exported data file, except for the comma delimiting the Name field. Both properties are non-default (see The Default Export Schema ). They have been established through the definition of
344
record and field properties. The record properties are delim = none and binary. The field Name is explicitly delimited by a comma (delim = ,) and this field property overrides the record-level property of delim = none. See Import/Export Properties for a full discussion of this subject. The following osh code uses the specified schema to export the data:
$ osh "export -file outFile.dat -schema $exp_example_1 -rejects save < inDS.ds > errDS.ds"
export
The following osh code specifies the layout of the destination data files:
$ exp_example_2="record {record_length = fixed, delim = none, binary} ( Name:string[64]; Age:int8; Income:dfloat; Zip:string[12]; Phone:string[12]; )"
In this example, all fields are of specified length and the schema defines the fixed record length property. The following osh code uses the specified schema to export the data:
$ osh "export -fileset listFile.fs -schema $exp_example_2 -rejects save < inDS.ds > errDS.ds"
Upon completion of the step, listFile.fs contains a list of every destination data file created by the operator, one file name per line, and contains the record schema used for the export.
Chapter 8. The import/export library
345
Import/export properties
You can add import/export properties to a schema when you import and export flat files. Properties define the layout of imported and exported data, including such things as how numbers, strings, times, and dates are represented. Properties can apply to records or to fields, and there are numerous default properties that you do not need to specify. The property determines how the data is represented in the file from which the data is imported or to which the data is exported. Note: Properties apply only when you import or export data. They are not part of the internal WebSphere DataStage representation of the data, which only needs to know the type of the data. WebSphere DataStage assumes that data to import or export is formatted according to default properties if: v You do not specify either record or field properties for imported or exported data. v WebSphere DataStage performs an unmodified implicit import or export operation (see Implicit Import/Export Operations with No Schemas Specified ). The defaults are discussed in The Default Import Schema and The Default Export Schema . You explicitly define properties to override these defaults.
Setting properties
You establish the properties of imported and exported data as part of defining the datas schema. Define record-level properties (which describe the format of the entire record) as follows:
record { prop1 [ = arg1 ], prop2 [ = arg2 ], ... propn [ = argn ] } (field_definitions ...;)
Define record properties after the word record and before the enumeration of field definitions. Enclose the definition in braces ( { } ). Define properties in a comma-separated list if there is more than one property. Attribute values to the properties with the attribution sign ( = ). If the attributed values are strings, enclose them in single quotes. v Specify special characters by starting with a backslash escape character. For example, \t represents an ASCII tab delimiter character. v v v v
346
For example, the following defines a record in which all fields are delimited by a comma except the final one, which is delimited by a comma followed by an ASCII space character:
record {delim_string = ,, final_delim_string = , } ( a:int32; b:string; c:int8; d:raw; )
Define field-level properties (which describe the format of a single field) as follows:
field_definition { prop1 [ = arg1 ], prop2 [ = arg2 ], ... propn [ = argn ] };
where field_definition is the name and data type of the field. v Define field properties after the field_definition and before its final semi-colon. v Enclose the definition of properties in braces ( { } ). v Define properties in a comma-separated list if there is more than one property. v Attribute values to the properties with the attribution sign ( = ). If the attributed values are strings, enclose them in single quotes. v Specify special characters by starting with a backslash escape character. For example, \t represents an ASCII tab delimiter character. For example, the following specifies that the width of a string field is 40 bytes and that the ASCII space pad character is used when it is exported:
record (a: string { width = 40, padchar = }; )
You can specify many default values for properties at the record level. If you do, the defined property applies to all fields of that data type in the record, except where locally overridden. For example, if numeric data of imported or exported records are represented in binary format, you can define the binary property at record level, as in the following example:
record {binary, delim = none} (a:int32; b:int16; c:int8;)
With one exception, properties set for an individual field can override the default properties set at record level. The exception is the fill property, which is defined at record level but cannot be overridden by an individual field or fields. For example, the following schema sets the record length as fixed with no field delimiters and the layout of all fields as binary. However, the definition of the properties of the purposeOfLoan field are as follows: the field is formatted as text, its length is 5 bytes (and not the 4 bytes of the int32 data type), and it is delimited by a comma:
record {record_length = fixed, delim = none, binary} ( checkingAccount Status:int32; durationOfAccount:sfloat; creditHistory:int32; purposeOfLoan:int32 {width = 5, text, delim = ,) creditAmount: sfloat; savingsAccountAmount:int32; yearsEmployed:int32; installmentRate:sfloat; )
347
Properties
Certain properties are associated with entire records, and other properties with fields of specific data types, but most can be used with fields of all data types and the records that contain them. This section contains the following topics: v Record-Level Properties v Numeric Field Properties v String Field Properties v v v v v v v v v Ustring Field Properties Decimal Field Properties Date Field Properties Time Field Properties Timestamp Field Properties Raw Field Properties Vector Properties Nullable Field Properties Tagged Subrecord Field Properties
Each property that is described in the following section is discussed in detail in Properties: Reference Listing .
Record-level properties
Some properties apply only to entire records. These properties, which establish the record layout of the imported or exported data or define partial schemas, can be specified only at the record level. If you include no properties, default import and export properties are used; see The Default Import Schema and The Default Export Schema . The following table lists the record-level properties that cannot be set at the field level.
Keyword intact check_intact record_length record_prefix record_format Use Defines a partial schema and optionally verifies it Defines the fixed length of a record Defines a fields length prefix as being 1, 2, or 4 bytes long With type = implicit, field length is determined by field content With type = varying, defines IBM blocked or spanned format record_delim record_delim_string fill Defines character(s) delimiting a record Defines the value used to fill gaps between fields of an exported record. This property applies to export only and cannot be set at the field level.
Field Properties
You can define properties of imported and exported fields. This section lists field properties according to the data types that they can be used with, under the following categories. v Numeric Field Properties on page 349
348
v v v v v v v
String Field Properties on page 350 Decimal Field Properties on page 350 Date Field Properties on page 351 Time Field Properties on page 351 Timestamp Field Properties on page 352 Raw Field Properties on page 353 Vector Properties on page 353
v Nullable Field Properties on page 353 v Subrecord Field Properties on page 353 v Tagged Subrecord Field Properties on page 354 There is some overlap in these tables. For example, a field might be both decimal and nullable, and so field properties in both the decimal and nullable categories would apply to the field. Furthermore many properties such as delim apply to fields of all (or many) data types, and to avoid tedious repetition are not listed in any of the categories. However, they all appear in Properties: Reference Listing .
349
Use Specifies the byte ordering as little-endian Defines the maximum width of the destination field Specifies the byte ordering as native-endian Format of numeric translation to text field Pad character of exported strings or numeric values Defines the exact width of the destination field
Defines the pad character of exported padchar strings or numeric values Defines the exact width of the destination field width
At the field level, it defines the charset character set to be used for ustring fields; at the record level it applies to the other import/export properties that support multi-byte Unicode character data. Defines the maximum width of the destination field max_width
Defines the pad character of exported padchar strings or numeric values Defines the exact width of the destination field width
fix_zero
Treat a packed decimal field fix_zero containing all zeros (normally illegal) as a valid representation of zero
350
Use Defines the maximum width of the destination field Defines the field as containing a packed decimal Defines the precision of a decimal Defines the rounding mode Defines the scale of a decimal Defines the field as containing an unpacked decimal with a separate sign byte Defines the exact width of the destination field Defines the field as containing an unpacked decimal in text format
width zoned
width zoned
Specifies the character set for the date charset Defines a text-string date format or uformat format other than the default; uformat can contain multi-byte Unicode characters The field stores the date as a signed integer containing the number of days since date_in_ISO_format or uformat. Provides support for international date components Defines the date as a binary numeric value containing the Julian day Specifies the byte ordering as little-endian Specifies the byte ordering as native-endian Specifies text as the data representation date_format
days_since
days_since
351
Use In this context, a synonym for the julian property Specifies the character set for the time field. Provides support for international time components Specifies the byte ordering as little_endian Specifies the byte ordering as native_endian.
Represent the time field as a binary midnight_seconds 32-bit integer containing the number of seconds elapsed from the previous midnight. Defines a text-string time format or time_format uformat format other than the default Defines the field as a binary 32-bit integer containing the number of seconds elapsed from the previous midnight; see midnight_seconds . Specifies the byte ordering as native-endian Specifies text as the data representation Defines a text-string date format or uformat other than the default; uformat can contain multi-byte Unicode characters midnight_seconds
time_format midnight_seconds
352
Vector Properties
WebSphere DataStage supports vector fields of any data type except subrecord and tagged subrecord. WebSphere DataStage vectors can be of either fixed or variable length. No special properties are required for fixed-length vectors. The import and export operators perform the number of import/export iterations defined by the number of elements in the vector. However, variable-length vectors can have the properties described in the following table.
Keyword link prefix vector_prefix Use This field holds the number of elements in a variable-length vector Defines the length of prefix data, which specifies the length in bytes Defines the length of vector prefix data, which specifies the number of elements See link prefix vector_prefix
null_field null_length
null_field null_length
353
Keyword fill
Use
See
Defines the value used to fill gaps fill between fields of an exported record. This property applies to export only and cannot be set at the field level Specifies a single ASCII or multi-byte record_delim Unicode character to delimit a record Specifies an string or ustring to delimit a record With type = implicit, field length is determined by field content. With type = varying, defines IBM blocked or spanned format. record_delim_string record_format
Defines the fixed length of a record Defines fields length prefix as being 1, 2, or 4 bytes long With type = implicit, field length is determined by field content. With type = varying, defines IBM blocked or spanned format.
354
ascii big_endian
Field value represented in binary binary format; decimal represented in packed decimal format; julian day format; time represented as number of seconds from midnight; timestamp formatted as two 32-bit integers Format of text-numeric translation format to and from numeric fields Specifies a character set Error checking of imported records with partial record schema (a suboption of intact) Defines a text-string date format or uformat format other than the default; uformat can contain multi-byte Unicode characters c_format charset check_intact
c_format charset record {text} ( a:int32; b:int16 {binary}; c:int8; ) check_intact date_format
date_format
days_since
The imported or exported field stores days_since the date as a signed integer containing the number of days since date_in_ISO_format or uformat. Specifies an ASCII character to separate the integer and fraction components of a decimal Default value for a field that causes an error Provides support for international date components in date fields Provides support for international time components in time fields Trailing delimiter of all fields decimal_separator
decimal_separator
One or more ASCII characters delim_string forming trailing delimiter of all fields Field dropped on import Character set of data is in EBCDIC format Exported field converted from EBCDIC to ASCII drop ebcdic export_ebcdic_as_ascii
355
Specifies Byte value to fill in gaps in exported record Delimiter character trailing last field of record Delimiter string trailing last field of record
A packed decimal field containing all fix_zero zeros (normally illegal) is treated as a valid representation of zero Creation of exported field Translation of imported string field from ASCII to EBCDIC Format of text translation to numeric field generate import_ascii_as_ebcdic in_format
The record definition defines a partial intact record schema The imported or exported field represents the date as a numeric value containing Julian day A field holds the length of a another, variable-length field of the record; field may be a vector Multi-byte data types are formatted as little endian Maximum width of the destination field. The field represents the time as a binary 32-bit integer containing the number of seconds elapsed from the previous midnight julian
link
link
native_endian
Multi-byte data types are formatted native_endian as defined by the native format of the machine; this is the default for import/export operations A packed decimal field containing all nofix_zero zeros generates an error (default) Value of null field in file to be imported; value to write to exported file if source field is null Imported length meaning a null value; exported field contains a null null_field
nofix_zero null_field
null_length overpunch
null_length
The field has a leading or ending overpunch byte that contains a character which specifies both the numeric value of that byte and whether the number as a whole is negatively or positively signed Format of numeric translation to text field out_format
out_format
356
Specifies The imported or exported field contains a packed decimal Pad character of exported strings or numeric values The byte offset of the field in the record The precision of the packed decimal
Prefix of all fields of record; also prefix length of prefix holding the length in bytes of a vector Each imported field generates message print_field
Field is enclosed in quotes or another quote ASCII character; useful for variable-length fields Record delimited by a single ASCII character Record delimited by one or more ASCII characters Variable-length blocked records or implicit records Fixed length records Records with a length prefix stored as binary data Name of field containing field length Rounding mode of source decimal The scale of the decimal record_delim record_delim_string record_format record_length record_prefix reference round scale
The imported or exported field separate contains an unpacked decimal with a separate sign byte Number of bytes skipped from the end of the previous field to the beginning of this one Defines the active field in a tagged subrecord Field represented as text-based data; decimal represented in string format; date, time, and timestamp representation is text-based The format of an imported or exported field representing a time as a string The format of an imported or exported field representing a timestamp as a string Prefix length for element count skip
skip
tagcase text
tagcase text
time_format
time_format
timestamp_format
timestamp_format
vector_prefix
vector_prefix
357
Specifies The exact width of the destination field The imported or exported field contains an unpacked decimal represented by either ASCII or EBCDIC text
The remainder of this chapter consists of an alphabetic listing of all properties. In presenting the syntax, field_definition is the name and data type of the field whose properties are defined.
actual_length
Used with null_length (null_length ). v On import, specifies the actual number of bytes to skip if the fields length equals the null_length v On export, specifies the number of bytes to fill with the null-field or specified pad character if the exported field contains a null.
Applies to
Nullable fields of all data types; cannot apply to record, subrec, or tagged.
Syntax
field_definition {actual_length = length};
where length is the number of bytes skipped by the import operator or filled with zeros by the export operator when a field has been identified as null.
See also
null_length .
Example
In this example: v On import, the import operator skips the next ten bytes of the imported data if the imported field has a length prefix of 255 v On export, the length prefix is set to 255 if source field a contains a null and the export operator fills the next ten bytes with one of these: zeros, the null-field specification, the pad-character specification for the field.
record {prefix = 2} ( a:nullable string {null_length = 255, actual_length = 10}; )
ascii
Specifies that the ASCII character set is used by text-format fields of imported or exported data. This property is equivalent to specifying the US_ASCII character set and is the default.
Applies to
All data types except raw, ustring; record, subrec, or tagged containing at least one non-raw field. For ustring, the same functionality is available using the charset property.
358
Syntax
record { ascii } field_definition { ascii };
See also
ebcdic .
Example
The following specification overrides the record-level property setting for field b:
record {ebcdic} ( a:int32; b:string {ascii}; )
big_endian
Specifies the byte ordering of multi-byte data types in imported or exported data as big-endian.
Applies to
Fields of the integer, date, time, or timestamp data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { big_endian } field_definition { big_endian };
Restrictions
WebSphere DataStage ignores the endian property of a data type that is not formatted as binary. This property is mutually exclusive with little_endian and native_endian.
Examples
The following specification defines a record schema using a big-endian representation:
record {big_endian, binary, delim = none} ( a:int32; b:int16; c:int8; )
binary
Specifies the data representation format of a field in imported or exported data as binary.
359
Applies to
Fields of all data types except string, ustring, and raw; record, subrec or tagged containing at least one field that is neither string nor raw.
Syntax
record { binary } field_definition { binary };
This option specifies binary data; data is formatted as text by default (see text ).
Meanings
The binary property has different meanings when applied to different data types: v For decimals, binary means packed (see packed ). v v v v For other numerical data types, binary means not text. For dates, binary is equivalent to specifying the julian property for the date field (see julian ). For time, binary is equivalent to midnight_seconds (see midnight_seconds ). For timestamp, binary specifies that the first integer contains a Julian day count for the date portion of the timestamp and the second integer specifies the time portion of the timestamp as the number of seconds from midnight; on export, binary specifies to export a timestamp to two 32-bit integers.
Restrictions
If you specify binary as a property of a numeric field, the data type of an imported or exported field must be the same as the corresponding field defined in a record schema. No type conversions are performed among the different numeric data types (as would be the case if text was specified instead). This property is mutually exclusive with text, c_format, in_format, and out_format.
Examples
For example, the following defines a schema using binary representation for the imported or exported numeric fields with no delimiter between fields:
record { binary, delim = none } ( a:int32; b:int16; c:int8; ) "record {text} ( "
c_format
Perform non-default conversion either of imported data from string to integer or floating-point data or of exported data from integer or floating-point data to a string. This property specifies a C-language format string used for both import and export. To specify separate import/export strings, see in_format and out_format .
360
Applies to
Imported or exported data of the integer or floating-point type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
field_definition { c_format= sscanf_or_sprintf_string };
sscanf_or_sprintf_string is a is a control string in single quotation marks containing formatting specification for both sscanf() to convert string data to floating-point or integer data and sprintf() to convert floating-point or integer data to strings. See the appropriate C language documentation for details of this formatting string.
Discussion
A UNIX data file can represent numeric values as strings. By default, on import WebSphere DataStage invokes the C strtol(), strtoll(), strtoul(), strtoull(), or strtod() function to convert a string to a numeric field. a WebSphere DataStage data file can represent numeric data in integer and floating-point data types. By default, on export WebSphere DataStage invokes the C sprintf() function to convert a numeric field formatted as either integer or floating point data to a string. If these functions do not output data in a satisfactory format, you can use the c_format property to specify a format that is used both by the sscanf() function to convert string data to integer or floating point data and by the sprintf() function to convert integral or floating point data to string data. The associated imported/exported field must represent numeric data as text. Int64 values map to long long integers on all supported platforms. For all platforms the c_format is:
%[ padding_character ][ integer ]lld
The integer component specifies a minimum field width. The output column is printed at least this wide, and wider if necessary. If the column has fewer digits than the field width, it is padded on the left with padding_character to make up the field width. The default padding character is a space.
Examples
v For this example c_format specification:
%09lld
the padding character is zero (0), and the integers 123456 and 12345678 are printed out as 000123456 and 123456789. v For this example:
record (a:int32 {c_format = %x, width = 8};)
the meaning of the expression varies: On import, the expression uses the c_format property to ensure that string data in the imported file is formatted in the WebSphere DataStage record as field a, a 32-bit integer formatted as an 8-byte hexadecimal string On export, the same expression ensures that the field a, consisting of a 32-bit integer, is exported from the WebSphere DataStage record as an 8-byte hexadecimal string.
361
charset
Specifies a character set defined by the International Components for Unicode (ICU).
Applies to
At the field level, this option applies only to ustrings. At the record level, this option applies to the fields that do not specify a character set and to these properties that support multi-byte Unicode character data:
delim delim_string record_delim record_delim_string final_delim final_delim_string quote default padchar null_field date_format time_format timestamp_format
Syntax
record { charset = charset } field_definition { charset = charset };
Example
record { charset=charset1 } (a:ustring { charset=ISO-8859-15 } {delim = xxx}, b:date { charset=ISO-8859-15 }, c:ustring)
Where the user defined record charset, charset1, applies to field c and to the delim specification for field a. ISO-8859-15 applies to field a and b. Notice that the field character setting for field a does not apply to its delim property.
check_intact
Used only with the intact property, performs error checking when records are imported with a partial record schema.
Applies to
record, if it is qualified by the intact record property. (See intact ).
Syntax
record { intact, check_intact }
By default, when WebSphere DataStage imports records with a partial schema, it does not perform error checking in order to maximize the import speed. This property overrides the default. Error-checking in this case verifies, during the import operation, that the record contents conform to the field description. In addition, downstream of this verification, the operator that acts on the input fields verifies their value.
Example
For example, the following statement uses intact to define a partial record schema and uses check_intact to direct WebSphere DataStage to perform error checking:
record {intact=rName, check_intact, record_length=82, record_delim_string=\r\n} ()
date_format
Specifies the format of an imported or exported text-format date.
Applies to
Field of date data type; record, subrec, or tagged if it contains at least one field of this type.
362
Syntax
record { date_format = format_string | uformat }
uformat is described in default_date_format . The format_string can contain one or a combination of the following elements:
Table 18. Date format tags Tag %d %dd %ddd %m %mm %mmm %mmmm %yy %yyyy %NNNNyy %e %E %eee %eeee %W %WW import/export import import/export with v option import Variable width availability import Description Day of month, variable width Day of month, fixed width Day of year Month of year, variable width Month of year, fixed width Month of year, short name, locale specific Month of year, full name, locale specific Year of century Four digit year Cutoff year plus year of century Day of week, Sunday = day 1 Day of week, Monday = day 1 Value range 1...31 01...31 1...366 1...12 01...12 Jan, Feb ... January, February ... 00...99 0001 ...9999 yy = 00...99 1...7 1...7 t, u, w t, u, w, -N, +N s s s Options s s s, v s s t, u, w t, u, w, -N, +N s
Weekday short name, Sun, Mon ... locale specific Weekday long name, locale specific Week of year (ISO 8601, Mon) Week of year (ISO 8601, Mon) Sunday, Monday ... 1...53 01...53
When you specify a date format string, prefix each component with the percent symbol (%) and separate the strings components with a suitable literal character. The default date_format is %yyyy-%mm-%dd. Where indicated the tags can represent variable-width data elements. Variable-width date elements can omit leading zeroes without causing errors. The following options can be used in the format string where indicated in the table: s Specify this option to allow leading spaces in date formats. The s option is specified in the form:
Chapter 8. The import/export library
363
%(tag,s) Where tag is the format string. For example: %(m,s) indicates a numeric month of year field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property: %(d,s)/%(m,s)/%yyyy Then the following dates would all be valid: 8/ 8/1958 08/08/1958 8/8/1958 v Use this option in conjunction with the %ddd tag to represent day of year in variable-width format. So the following date property: %(ddd,v) represents values in the range 1 to 366. (If you omit the v option then the range of values would be 001 to 366.) u w t Use this option to render uppercase text on output. Use this option to render lowercase text on output. Use this option to render titlecase text (initial capitals) on output.
The u, w, and t options are mutually exclusive. They affect how text is formatted for output. Input dates will still be correctly interpreted regardless of case. -N +N Specify this option to left justify long day or month names so that the other elements in the date will be aligned. Specify this option to right justify long day or month names so that the other elements in the date will be aligned.
Names are left justified or right justified within a fixed width field of N characters (where N is between 1 and 99). Names will be truncated if necessary. The following are examples of justification in use: %dd-%(mmmm,-5)-%yyyyy
21-Augus-2006
%dd-%(mmmm,-10)-%yyyyy
21-August -2005
%dd-%(mmmm,+10)-%yyyyy
21August-2005
The locale for determining the setting of the day and month names can be controlled through the locale tag. This has the format:
%(L,locale)
Where locale specifies the locale to be set using the language_COUNTRY.variant naming convention supported by ICU. See NLS Guide for a list of locales. The default locale for month names and weekday names markers is English unless overridden by a %L tag or the APT_IMPEXP_LOCALE environment variable (the tag takes precedence over the environment variable if both are set).
364
Use the locale tag in conjunction with your time format, for example the format string: %(L,es)%eeee, %dd %mmmm %yyyy Specifies the Spanish locale and would result in a date withe the following format: mircoles, 21 septembre 2005 The format string is subject to the restrictions laid out in the following table. A format string can contain at most one tag from each row. In addition some rows are mutually incompatible, as indicated in the incompatible with column. When some tags are used the format string requires that other tags are present too, as indicated in the requires column.
Table 19. Format tag restrictions Element year month Numeric format tags %yyyy, %yy, %[nnnn]yy %mm, %m Text format tags %mmm, %mmmm Requires year month year %eee, %eeee month, week of year year Incompatible with week of year day of week, week of year day of month, day of week, week of year day of year month, day of month, day of year
day of month %dd, %d day of year day of week week of year %ddd %e, %E %WW
When a numeric variable-width input tag such as %d or %m is used, the field to the immediate right of the tag (if any) in the format string cannot be either a numeric tag, or a literal substring that starts with a digit. For example, all of the following format strings are invalid because of this restriction: %d%m-%yyyy %d%mm-%yyyy %(d)%(mm)-%yyyy %h00 hours The year_cutoff is the year defining the beginning of the century in which all two-digit years fall. By default, the year cutoff is 1900; therefore, a two-digit year of 97 represents 1997. You can specify any four-digit year as the year cutoff. All two-digit years then specify the next possible year ending in the specified two digits that is the same or greater than the cutoff. For example, if you set the year cutoff to 1930, the two-digit year 30 corresponds to 1930, and the two-digit year 29 corresponds to 2029. On import and export, the year_cutoff is the base year. This property is mutually exclusive with days_since, text, and julian. You can include literal text in your date format. Any Unicode character other than null, backslash, or the percent sign can be used (although it is better to avoid control codes and other non-graphic characters). The following table lists special tags and escape sequences:
Chapter 8. The import/export library
365
Tag %% \% \n \t \\
Escape sequence literal percent sign literal percent sign newline horizontal tab single backslash
If the format string does not include a day, the day is set to the first of the month in the destination field. If the format string does not include the month and day, they default to January 1. Note that the format string must contain a month if it also contains a day; that is, you cannot omit only the month. When using variable-width tags, it is good practice to enclose the date string in quotes. For example, the following schema:
f1:int32; f2:date { date_format=%eeee %mmmm %d, %yyyy, quote=double }; f3:int32;
The quotes are required because the parallel engine assumes that variable-width fields are space delimited and so might interpret a legitimate space in the date string as the end of the date.
See also
See the section on WebSphere DataStage data types in the WebSphere DataStage Parallel Job Developer Guide for more information on date formats.
days_since
The imported or exported field stores the date as a signed integer containing the number of days since date_in_ISO_format or uformat.
Applies to
Fields of the date data type ; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { days_since = date_in_ISO_format | uformat }
where date_in_ISO_format is in the form %yyyy-%mm-%dd; and uformat is the default date format as described in default_date_format . The imported or exported field is always stored as binary data. This property is mutually exclusive with date_format, julian, and text.
decimal_separator
Specifies an ASCII character to separate the integer and fraction components of a decimal.
Applies to
record and decimal fields.
366
Syntax
record { decimal_separator = ASCII_character } field_definition { decimal_separator = ASCII_character };
Example
record { decimal_separator = , } (a:decimal, b:decimal { decimal_separator = - })
default
Sets the default value of an imported or exported field: v On import if the generate property is set v On both import and export if an error occurs
Applies to
Fields of integer, float, string, ustring, and decimal data types. Cannot apply to record, subrecord, or tagged.
Syntax
field_definition { default = field_value };
where field_value is the default value of an imported or exported field. For ustring fields, field_value may contain multi-byte Unicode characters. On import, if you specify a default value, the import operator sets the destination field in the data set to the default value instead of rejecting an erroneous record. On export, the export operator sets the field in the destination data file to the default value instead of rejecting an erroneous record. The property is mutually exclusive with link.
Example
The following defines the default value of field c as 127:
record (a:int32; b:int16; c:int8 {default = 127};)
default_date_format
This property provides support for international date components in date fields.
Applies to
record and date fields.
Syntax
record {default_date_format = String%macroString%macroString%macroString}
where %macro is a formatting macro such as %mmm for a 3-character English month. The section date_format lists the date formatting macros. The String components can be strings or ustrings.
Example
record ( { default_date_format = jeudi%ddaot%yyyy };)
367
default_time_format
This property provides support for international time components in time fields.
Applies to
record and time fields.
Syntax
record {default_time_format = String%macroString%macroString%macroString}
where %macro is a formatting macro such as %hh for a two-digit hour. The section time_format lists the time formatting macros. The String components can be strings or ustrings.
Example
record ( { default_time_format = %hh&nnA.M.};)
delim
Specifies the trailing delimiter of all fields in the record.
Applies to
record; any field of the record.
Syntax
record { delim = delim_char } field_definition { delim = delim_char };
where delim_char can be one of the following: v ws to have the import operator skip all standard whitespace characters (space, tab, and newline) trailing after a field. v end to specify that the last field in the record is composed of all remaining bytes until the end of the record. v none to specify that fields have no delimiter. v null to specify that the delimiter is the null character. v You can specify an ASCII or multi-byte Unicode character enclosed in single quotation marks. To specify multiple characters, use delim_string (see delim_string ).
Discussion
By default, the import operator assumes that all fields but the last are whitespace delimited. By default, the export operator inserts a space after every exported field except the last. On export, you can use delim to specify the trailing delimiter that the export operator writes after each field in the destination data file. Specify: v ws to have the export operator insert an ASCII space (0x20) after each field v none to write a field with no delimiter and no length prefix. You can use a backslash (\) as an escape character to specify special characters. For example, \t represents an ASCII tab delimiter character. You can use final_delim to specify a different delimiter for the last field of the record. See final_delim .
368
Examples
The following statement specifies that all fields have no delimiter:
record {delim = none} ( a:int32; b:string; c:int8; d:raw; )
The following statement specifies a comma as a delimiter at record-level but overrides this setting for field d, which is composed entirely of bytes until the end of the record:
record {delim = ,} ( a:int32; b:string; c:int8; d:raw{delim = end}; ) "record {delim = ,} ( "
Note that in this example, the record uses the default record delimiter of a newline character. This means that: v On import, field d contains all the bytes to the newline character. v On export, a newline character is inserted at the end of each record.
delim_string
Like delim, but specifies a string of one or more ASCII or multi-byte Unicode characters forming a trailing delimiter.
Applies to
record; any field of the record.
Syntax
record {delim_string = ASCII_string | multi_byte_Unicode_string } field_definition { delim_string = ASCII_string | multi_byte_Unicode_string };
You can use a backslash (\) as an escape character to specify special characters within a string. For example, \t represents an ASCII tab delimiter character. Enclose the string in single quotation marks. This property is mutually exclusive with prefix, delim, and reference. Note: Even if you have specified the character set as EBCDIC, ASCII_string is always interpreted as ASCII character(s).
Examples
The following statement specifies that all fields are delimited by a comma followed by a space:
Chapter 8. The import/export library
369
In the following example, the delimiter setting of one comma is overridden for field b, which will be delimited by a comma followed by an ASCII space character, and for field d, which will be delimited by the end of the record:
record {delim = ,} ( a:int32; b:string {delim_string = , }; c:int8; d:raw {delim = end}; )
Note that in this example, the record uses the default record delimiter of a newline character. This means that: v On import field d contains all the bytes to the newline character. v On export a newline character is inserted at the end of each record.
drop
Specifies a field to be dropped on import and not stored in the WebSphere DataStage data set.
Applies to
Fields of all data types. Cannot apply to record, subrec, or tagged.
Syntax
field_definition { drop };
You can use this property when you must fully define the layout of your imported data in order to specify field locations and boundaries but do not want to use all the data in the WebSphere DataStage job.
Restrictions
This property is valid for import only and is ignored on export. This property is mutually exclusive with link.
See also
padchar .
Example
In this example, the variable-length string field, b, is skipped as the record is imported.
record (a:int32; b:string {drop}; c:int16;)
In the following example, all fields are written as strings to the WebSphere DataStage data set on import and are delimited by a comma except the last field; records are delimited by the default newline character. The last four fields are dropped from every record on import, and generated on export. This technique is useful when fields of the source data are not be processed in an WebSphere DataStage job but place holders for those fields must be retained in the resultant file containing the exported results. In addition, all bytes of the generated fields in the exported data file will be filled with ASCII spaces, as defined by the padchar property:
370
record { delim =,} ( first_name :string[20]; middle_init :string[1]; last_name :string[40]; street :string[40]; apt_num :string[4]; city :string[30]; state :string[2]; prev_street :string[40] {drop, generate, padchar= }; prev_apt_num :string[4] {drop, generate, padchar= }; prev_city :string[30] {drop, generate, padchar= }; prev_state :string[2] {delim = end, drop, generate, padchar= }; )
ebcdic
Specifies that the EBCDIC character set is used by text-format fields of imported or exported data. Setting this property is equivalent to specifying the EBCDIC equivalent of the US_ASCII character set.
Applies to
All data types except raw and ustring; record, subrec, or tagged if it contains at least one field of this type. For ustring, the same functionality is available through the charset property.
Syntax
record { ebcdic } field_definition { ebcdic };
This property is mutually exclusive with ascii. WebSphere DataStages default character set is ASCII-formatted. (WebSphere DataStage supplies lookup tables for converting between ASCII and EBCDIC. See ASCII and EBCDIC Conversion Tables for more information.)
See also
ascii .
export_ebcdic_as_ascii
Export a string formatted in the EBCDIC character set as an ASCII string.
Applies to
Fields of the string data type and records; record, subrec, or tagged if it contains at least one field of this type. This property does not apply to ustring; you can obtain the same functionality using the charset property.
Syntax
record { export_ebcdic_as_ascii } field_definition { export_ebcdic_as_ascii };
fill
Specifies the byte value used to fill the gaps between fields of an exported record caused by field positioning.
Chapter 8. The import/export library
371
Applies to
record; cannot be specified for individual fields.
Syntax
record {fill [ = fill_value ] }
where fill_value specifies a byte value that fills in gaps. By default the fill value is 0. The fill_value can also be one of these: v a character or string in single quotation marks v an integer between 0 and 255.
Restriction
You cannot override the record-level fill property with an individual field definition.
Examples
In the following example, the two-byte gap between fields a and b are to be filled with ASCII spaces:
record {fill = } (a:int32; b:int16 {skip = 2};)
In the following example, the gaps are to be filled with the value 127:
record { fill = 127} (a:int32; b:int16 {skip = 2};)
final_delim
Specifies a delimiter for the last field. If specified, final_delim precedes the record_delim if both are defined.
Applies To
The last field of a record. When the last field in a record is a subrec, a space is added after the subrec instead of your non-space delim_value.
Syntax
record {final_delim = delim_value} where delim_value is one of the following: v ws (a white space) v end (end of record, the default) v none (no delimiter, field length is used) v null (0x00 character) v a (specified ASCII or multi-byte Unicode character, enclosed in single quotation marks)
Example
In this example, commas delimit all fields except the last. Since end is specified as the final_delim, the record delimiter serves as the delimiter of the final field. This is the newline character. Note that it is not specified as the record_delim, because newline-delimited records are the default.
record {delim = ,, final_delim = end} ( checkingAccountStatus :int32; durationOfAccount :sfloat; creditHistory :int32;
372
purposeOfLoan :int32; creditAmount :sfloat; savingsAccountAmount :int32; yearsPresentlyEmployed :int32; installmentRate :sfloat; )
By default, on export a space is now inserted after every field except the last field in the record. Previous to this release, a space was inserted after every field, including the last field; or, when delim property was set, its value was used instead of the final_delim value. Now when you specify the final_delim property for records that have a tagged or subrec field as the last field, your specification is correctly applied unless the subrec is a vector. By default, a space is added to the last field when it is a subrec vector. You can set the APT_PREVIOUS_FINAL_DELIM_COMPATIBLE environment variable to obtain the final_delim behavior prior to this release.
final_delim_string
Like final_delim, but specifies a string of one or more ASCII or multi-byte Unicode characters that are the delimiter string of the last field of the record. The final_delim_string property precedes the record_delim property, if both are used.
Applies to
The last field of a record.
Syntax
record {final_delim_string = ASCII_string | multi_byte_Unicode_string }
Example
For example, the following statement specifies that all fields are delimited by a comma, except the final field, which is delimited by a comma followed by an ASCII space character:
record {delim_string = ,, final_delim_string = , } ( a:int32; b:string; c:int8; d:raw; )
fix_zero
Treat a packed decimal field containing all zeros (normally illegal) as a valid representation of zero.
Chapter 8. The import/export library
373
Applies to
Fields of the packed decimal data type on import; all decimal fields on export (exported decimals are always packed); record, subrec, or tagged if it contains at least one field of these types.
Syntax
field_definition { fix_zero };
Note: Omitting fix_zero causes the job to generate an error if it encounters a decimal containing all zeros. This property overrides the nocheck option to packed.
See also
packed and nofix_zero . The latter option restores default behavior.
generate
On export, creates a field and sets it to the default value.
Applies to
Fields of all data types. Cannot apply to record, subrec, or tagged.
Syntax
field_definition { generate, default = default_value };
where: v default is the ordinary default property (see default ) and not a sub-option of generate v default_value is the optional default value of the field that is generated; if you do not specify a default_value, WebSphere DataStage writes the default value associated with that data type.
Discussion
You can specify both the drop property and the generate property in the same property list. When the schema is used for import it drops the field, and when it is used for export, it generates the field. This type of statement is useful if the field is not important when the data set is processed but you must maintain a place holder for the dropped field in the exported data.
Restriction
This property is valid for export only and is ignored on import.
Examples
The following statement creates a new field in an exported data set:
record ( a:int32; b:int16 {generate, default=0}; c:int8; )
The following statement causes field b to be: v dropped on import v generated as a 16-bit integer field, which is initialized to 0, on export.
record ( a:int32; b:int16 {drop, generate, default =0}; c:int8;)
374
import_ascii_as_ebcdic
Translate a string field from ASCII to EBCDIC as part of an import operation. This property makes it possible to import EBCDIC data into WebSphere DataStage from ASCII text.
Applies to
Fields of the string data type; record, subrec, or tagged if it contains at least one field of this type. This property does not apply to ustring; you can obtain the same functionality using the charset property.
Syntax
field_definition { import_ascii_as_ebcdic };
Restriction
Use only in import operations. On export, you can use export_ebcdic_as_ascii to export the EBCDIC field back to ASCII. See export_ebcdic_as_ascii .
Example
In the following example, the string field x contains an ASCII string that is converted to EBCDIC on import:
record (x:string[20] {import_ascii_as_ebcdic};)
in_format
On import, perform non-default conversion of an input string to an integer or floating-point data. This property specifies a C-language format string used for import. See also out_format .
Applies to
Imported data of integer or floating-point type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
field_definition { in_format = sscanf_string };
where sscanf_string is a control string in single quotation marks interpreted by the C scanf() function to convert character data to numeric data. See the appropriate C language documentation for details of this formatting string.
Discussion
A UNIX data file can represent numeric values as strings. By default, on import WebSphere DataStage invokes the C strtol(), strtoll(), strtoul(), strtoull(), or strtod() function to convert a string to a numeric field. If these functions do not output data in a satisfactory format, you can specify the out_format property. When you do, WebSphere DataStage invokes the sprintf() function to convert the string to numeric data. You pass formatting arguments to the function. When strings are converted to 8-, 16-, or 32-bit signed integers, the sscanf_string must specify options as if the generated field were a 32-bit signed integer. WebSphere DataStage converts the 32-bit integer to the proper destination format.
375
Restrictions
The export operator ignores this property; use it only for import operations. This property is mutually exclusive with binary.
Example
The following statement assumes that the data to be converted is represented as a string in the input flat file. The data is imported as field a, a 32-bit integer formatted as an 8-byte hexadecimal string:
record (a:int32 {in_format = %x, width=8};)
intact
Define a partial record schema.
Applies to
record
Syntax
record {intact[= rName ] ... } ( field_definitions ; )
See also
check_intact .
Example
For example, the following statement uses intact to define a partial record schema:
record {intact=rName, record_length=82, record_delim_string=\r\n} ()
In this example, the record schema defines an 82-byte record (80 bytes of data, plus one byte each for the carriage return and line feed characters delimiting the record). On import, the two bytes for the carriage return and line feed characters are removed from the record and not saved; therefore, each record of the data set contains only the 80 bytes of data.
julian
Specifies that the imported or exported field represents the date as a binary numeric value denoting the Julian day.
Applies to
Fields of the date data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { binary, julian } field_definition { binary, julian };
376
A Julian day specifies the date as the number of days from 4713 BCE January 1, 12:00 hours (noon) GMT. For example, January 1, 1998 is Julian day count 2,450,815. In this context, binary has the same meaning as julian. This property is mutually exclusive with days_since, date_format, and text.
link
Specifies that a field holds either the length of another (variable-length) field in the record or the length of the tag value of a tagged.
Applies to
Numeric or string fields; cannot apply to a record, subrec, or tagged.
Syntax
field_definition { link };
Discussion
A variable-length field must specify the number of elements it contains by means either of a prefix of the vector (see vector_prefix ) or a link to another field. v On import, the link field is dropped and does not appear in the schema of the imported data set. v On export, the link field is not exported from the data set, but is generated from the length of the field referencing it and then exported. The data type of a field defined by the link import/export property must: v Be a uint32 or data type that can be converted to uint32; see Modify Operator for information on data type conversions. v Have a fixed-length external format on export. v Not be a vector. This property is mutually exclusive with drop.
Examples
In this example, field a contains the element length of field c, a variable-length vector field.
record (a:uint32 {link}; b:int16; c[]:int16 {reference = a};) "record (a:uint32 {link}; b:int16; c:string {reference = a};)"
In this example, field a contains the length of field c, a variable-length string field.
record (a:uint32 {link}; b:int16; c:string {reference = a};)
little_endian
Specify the byte ordering of multi-byte data types as little-endian. The default mode is native-endian.
Applies to
Fields of the integer, date, time, or timestamp data type; record, subrec, or tagged if it contains at least one field of this type.
377
Syntax
record { little_endian } field_definition { little_endian };
This property is mutually exclusive with big_endian and native_endian. Note: WebSphere DataStage ignores the endian property if a data type is not formatted as binary.
Examples
The following specification defines a schema using a little-endian representation:
record {little_endian, binary, delim = none} ( a:int32; b:int16; c:int8; )
The following declaration overrides the big_endian record-level property in a definition of field b:
record {big_endian, binary, delim = none} ( a:int32; b:int16 {little_endian}; c:int8; )
max_width
Specifies the maximum number of 8-bit bytes of an imported or exported text-format field. Base your width specification on the value of your -impexp_charset option setting. If its a fixed-width charset, you can calculate the maximum number of bytes exactly. If its a variable length encoding, calculate an adequate maximum width for your fields.
Applies to
Fields of all data types except date, time, timestamp, and raw; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { max_width = n } field_definition { max_width = n };
where n is the maximum number of bytes in the field; you can specify a maximum width of 255 bytes. This property is useful for a numeric field stored in the source or destination file in a text representation. If you specify neither width nor max_width, numeric fields exported as text have the following number of bytes as their maximum width: v 8-bit signed or unsigned integers: 4 bytes v v v v v 16-bit signed or unsigned integers: 6 bytes 32-bit signed or unsigned integers: 11 bytes 64-bit signed or unsigned integers: 21 bytes. single-precision float: 14 bytes (sign, digit, decimal point, 7 fraction, E, sign, 2 exponent) double-precision float: 24 bytes (sign, digit, decimal point, 16 fraction, E, sign, 3 exponent)
Restriction
On export, if you specify the max_width property with a dfloat field, the max_width must be at least eight characters long.
378
midnight_seconds
Represent the imported or exported time field as a binary 32-bit integer containing the number of seconds elapsed from the previous midnight.
Applies to
The time data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { binary, midnight_seconds }; field_definition { binary, midnight_seconds };
Note: The imported or exported integer is always stored as binary data. This property is mutually exclusive with time_format and text.
native_endian
Specify the byte ordering of multi-byte data types as native-endian. This is the default mode for import/export operations.
Applies to
Fields of the integer, date, time, or timestamp data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { native_endian } field_definition { native_endian };
where native_endian specifies that all multi-byte data types are formatted as defined by the native format of the machine. This property is mutually exclusive with big_endian and little_endian. Note: WebSphere DataStage ignores the endian property of a data type that is not formatted as binary.
Examples
The following defines a schema using a native-endian representation:
record {native_endian, binary, delim = none} ( a:int32; b:int16; c:int8; )
nofix_zero
Generate an error when a packed decimal field containing all zeros is encountered. This is the default behavior of import and export.
Applies to
Import behavior and export behavior differ: v Fields of the packed decimal data type on import
379
v All decimal fields on export (exported decimals are always packed); record, subrec, or tagged if it contains at least one field of this type.
Syntax
field_definition { nofix_zero };
null_field
Specifies the value representing null.
Applies to
Fields whose data type is nullable; cannot apply to record, subrec, or tagged.
Syntax
field_definition { null_field = byte_value | multi_byte_Unicode_value};
where byte_value or multi_byte_Unicode_value is: v On import, the value given to a field containing a null; v On export, the value given to an exported field if the source field is set to null. The byte_value or multi_byte_Unicode_value can take one of these forms: v A number or string that defines the value to be written if the field contains a null. Enclose the string or ustring in single quotation marks. v A standard C-style string literal escape character. For example, you can represent a byte value by \ooo, where each o is an octal digit 0 - 7 and the first o is < 4, or by \xhh, where each h is a hexadecimal digit 0 - F. You must use this form to encode non-printable byte values. When you are specifying the null_field property at the record level, it is important to also specify the field-level null_field property to any nullable fields not covered by the record-level property. For example:
record { null_field = ( field1:nullable field2:nullable field3:nullable field4:nullable aaaa } int8 { null_field = -127 }; string[4]; string; ustring[8] {null_field = }; )
The record-level property above applies only to variable-length strings and fixed-length strings of four characters, field2 and field3; field1 and field4 are given field-level null_field properties because they are not covered by the record property. This property is mutually exclusive with null_length and actual_length. The null_field parameter can be used for imported or exported data. For a fixed-width data representation, you can use padchar to specify a repeated trailing character if byte_value is shorter than the fixed width of the field.
null_length
Specifies the value of the length prefix of a variable-length field that contains a null.
Applies to
Fields whose data type is nullable; cannot apply to record, subrec, or tagged.
380
Syntax
field_definition { null_length= length }
where length is the length in bytes of a variable-length field that contains a null. When a variable-length field is imported, a length of null_length in the source field indicates that it contains a null. When a variable-length field is exported, the export operator writes a length value of null_length if it contains a null. This property is mutually exclusive with null_field.
Restriction
Specifying null_length with a non-nullable WebSphere DataStage field generates an error.
See also
actual_length
Example
For example, the following schema defines a nullable, variable-length string field, prefixed by a two-byte length:
record {prefix = 2} ( a:nullable string {null_length = 255}; )
Import and export results differ: v On import, the imported field is assumed to be zero length and to contain a null if the length prefix contains 255; field a of the imported data is set to null. v On export, the length prefix is set to 255 and the length of the actual destination is zero if field a contains null.
out_format
On export, perform non-default conversion of an integer or floating-point data type to a string. This property specifies a C-language format string used for export of a text field. See also in_format .
Applies to
Integer or floating-point data to be exported to numeric strings.
Syntax
field_definition { out_format = sprintf_string };
where sprintf_string is a control string in single quotation marks containing formatting specification for sprintf() to convert floating-point or integer data to strings. See the appropriate C language documentation for details of this formatting string. When 8-, 16-, or 32-bit signed integers are converted to strings, the sprintf_string must specify options as if the source field were a 32-bit integer. WebSphere DataStage converts the source field to a 32-bit signed integer before passing the value to sprintf(). For 8-, 16-, and 32-bit unsigned integers, specify options as if the source field were a 32-bit unsigned integer.
381
Discussion
An WebSphere DataStage data file can represent numeric data in integer and floating-point data types. By default, on export WebSphere DataStage invokes the C sprintf() function to convert a numeric field formatted as either integer or floating point data to a string. If this function does not output data in a satisfactory format, you can specify the out_format property. When you do, WebSphere DataStage invokes the sprintf() function to convert the numeric data to a string. You pass formatting arguments to the function.
Restrictions
The import operator ignores this property; use it only for export operations. The property is mutually exclusive with binary.
Example
The following statement defines an exported record containing two integer values written to the exported data file as a string:
record ( a:int32 {out_format = %x, width = 8}; b:int16 {out_format = %x, width = 4}; )
overpunch
Specifies that the imported or exported decimal field has a leading or ending byte that contains a character which specifies both the numeric value of that byte and whether the number as a whole is negatively or positively signed. This representation eliminated the need to add a minus or plus sign to the beginning or end of a number. All the digits besides the overpunched byte represent normal numbers. Use one of these formats: v To indicate that the overpunched value is in the leading byte, use this syntax: {overpunch} For example, in the overpunched number B567, B indicates that the leading byte has a value of 2 and that the decimal is positively signed. It is imported as 2567. v To indicate that the overpunched value is in the last byte, use this syntax: {trailing, overpunch} For example, in the overpunched number 567K, K indicates that the last byte has a value of 2 and that the number is negatively signed. It is imported as -5672.
Applies to
Decimal fields.
Syntax
record { { overpunch | trailing, overpunch} option_1 .... option_n } field_definition { { overpunch | trailing, overpunch} option_1 ,... option_n };
packed
Specifies that the imported or exported field contains a packed decimal.
382
Applies to
Fields of the decimal, string, and ustring data types; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { packed option_1 .... option_n} field_definition { packed option_1 ,...option_n};
where option_1 ... option_n is a list of one or more options; separate options with a comma if there are more than one. The options are: v check. (default) perform the WebSphere DataStage data verification process on import/export. Note that this property is ignored if you specify fix_zero. v nocheck. bypass the WebSphere DataStage data verification process on import/export. Note that this property is ignored if you specify fix_zero. The options check and nocheck are mutually exclusive. v signed (default) use the sign of the source decimal on import or export. v unsigned generate a sign nibble of 0xf, meaning a positive value, regardless of the imported or exported fields actual sign. This format corresponds to the COBOL PICTURE 999 format (as opposed to S999). The options signed and unsigned are mutually exclusive.
Discussion
The precision and scale of either the source decimal on import or the destination decimal on export defaults to the precision and scale of the WebSphere DataStage decimal field. Use the precision and scale properties to override these defaults. For example, the following schema specifies the WebSphere DataStage decimal field has a precision of 5 and a scale of 2:
record {packed} ( a:decimal[5,2]; )
Import and export results differ: v On import, field a is imported from a packed decimal representation three bytes long. v On export, the field is written to three bytes in the destination.
padchar
Specifies a pad character used when WebSphere DataStage strings or numeric values are exported to an external string representation.
Applies to
string, ustring, and numeric data types on export; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { padchar = ` char(s) ` } field_ definition { padchar = ` char(s) ` }
where char(s) is one or more pad characters, single byte for string fields and multi-byte Unicode for ustring fields. You can specify null to set the pad character to 0x00; the default pad character is 0x20 (ASCII space). Enclose the pad character in single quotation marks if it is not the value null.
Chapter 8. The import/export library
383
The pad character is used when the external string representation is larger than required to hold the exported field. In this case, the external string is filled with the pad character to its full length.
Restrictions
This property is ignored on import.
Example
In the following example, the destination string will be padded with spaces to the full length, if the string field a is less than 40 bytes long.
record (a:string {width = 40, padchar = };)
Notes
WebSphere DataStage fixed-length strings also have a padchar property, which is part of a schema rather than an import/export property, as in the following example. Here the exported fixed-length string is also padded with spaces to the length of the external field:
record (a:string[20, padchar = ] {width = 40};)
You can globally override the default pad character using the WebSphere DataStage environment variable APT_STRING_PADCHAR. The Option and Syntax of this environment variable is shown below:
export APT_STRING_PADCHAR= character setenv APT_STRING_PADCHAR character # ksh # csh
where character is the default pad character enclosed in single quotation marks.
position
Specifies the starting position of a field in the imported source record or exported destination record. The starting position can be either an absolute byte offset from the first record position (0) or the starting position of another field.
Applies to
Fields of all data types; cannot apply to record, subrec, or tagged.
Syntax
field_definition { position = byte_offset | field_name };
where: v byte_offset is an integer value that is greater than or equal to 0 and less than the record length and that indicates the absolute byte offset of the field from position 0 in the record v field_name specifies the name of another field in the record at whose beginning boundary the defined field also starts, as in the example below.
Discussion
Specifies the byte offset of a field in the imported source record or exported destination record, where the offset of the first byte is 0. If you omit this property, a field starts immediately after the preceding field. Note that a field can start at a position preceding the end of the previous field.
384
Examples
For example, the following defines a schema using this property:
record {binary, delim = none} (a:int32; b:int16 {position = 6};)
Import and export results differ: v On import, field b starts at absolute byte offset 6 in the source record, that is, there is a 2-byte gap between fields a and b. Note that numeric values are represented in a binary format in this example. The default numeric format is text. v On export, the export operator skips two bytes after field a, then writes field b. By default on export, any skipped bytes are set to zero in the destination record. You can use the record-level fill property (fill ) to specify a value for the skipped bytes. You can specify a field_name as a position, as in the following example:
record {binary, delim = none} ( a:string {delim = ws}; b:int16; c:raw[2] {position = b}; ) "record {binary, delim = none} ( "
Field c starts at field b. Import behavior and export behavior differ: v On import, the schema creates two fields from field b of the imported record, interpreting the same external value using two different field types. v On export, the schema first writes the contents of field b to destination field b and then to destination field c.
precision
Import behavior and export behavior differ: v On import, specifies the precision of a source packed decimal. v On export, specifies the precision of a destination string when a decimal is exported in text format.
Applies to
Imported strings representing packed decimals; exported packed decimals to be written as strings; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { precision= p } field_definition { precision= p };
where p is the precision of the source packed decimal on import and the precision of the destination string on export; p has no limit.
Discussion
When a source decimal is exported to a string representation, the export operator uses the precision and scale defined for the source decimal field to determine the length of the destination string. The precision and scale properties override this default (precision and scale ). When they are defined, the export operator truncates or pads the source decimal to fit the size of the destination string. If you include the width property (width ), the export operator truncates or pads the source decimal to fit the size specified by width.
385
Restriction
The precision property is ignored on export if you also specify text.
Example
The following example shows a schema used to import a source field with the same precision and scale as the destination decimal:
record ( a:decimal[6,2]; )
WebSphere DataStage imports the source field to a decimal representation with a 6-digit precision. The following example shows a schema that overrides the default to import a source field with a 4-digit precision:
record ( a:decimal[6,2] {precision = 4}; )
prefix
Specifies that each imported/exported field in the data file is prefixed by 1, 2, or 4 bytes containing, as a binary value, either the fields length or the tag value for a tagged subrecord.
Applies to
All fields and record.
Syntax
record { prefix = field_definition prefix } { prefix = prefix };
where prefix is the integer 1, 2, or 4, which denotes a 1-, 2-, or 4-byte prefix containing the field length or a character enclosed in single quotes.
Discussion
You can use this option with variable-length fields. Variable-length fields can be either delimited by a character or preceded by a 1-, 2-, or 4-byte prefix containing the field length. Import behavior and export behavior differ: v On import, the import operator reads the length prefix but does not include the prefix as a separate field in the imported data set. v On export, the export operator inserts the prefix before each field. You can use this option with variable-length fields. Variable-length fields can be either delimited by a character or preceded by a 1-, 2-, or 4-byte prefix containing the field length. This property is mutually exclusive with delim, delim_string, quote, final_delim, and reference.
Example
In the following example, fields a and b are both variable-length string fields preceded by a 2-byte string length:
record {prefix = 2} ( a:string; b:string; c:int32; )
In the following example, the 2-byte prefix is overridden for field b, where the prefix is a single byte:
386
For tagged subrecords, the tag field may be either a prefix of the tagged aggregate or another field in the record associated with the tagged aggregate by the link property. Shown below is an example in which the tagged aggregate is preceded by a one-byte unsigned integer containing the tag:
record ( ... tagField:tagged {prefix=1} ( aField:string; bField:int32; cField:sfloat; ); )
print_field
For debugging purposes only; causes the import operator to display each value imported for the field.
Applies to
Fields of all data types and record.
Syntax
record { print_field } field_definition { print_field };
Discussion
This property causes import to write out a message for either selected imported fields or all imported fields, in the form:
Importing N: D
where: v N is the field name. v D is the imported data of the field. Non-printable characters contained in D are prefixed with an escape character and written as C string literals; if the field contains binary data, it is output in octal format.
Restrictions
This property is ignored on export.
Example
For example, the following schema uses print_field:
record {print_field} (a:string; b:int32;)
By default, imported numeric fields represent data as text. In this case, the import operator issues the following message:
Importing a: "the string" Importing b: "4660"
The following schema specifies that the numeric data is represented in binary form:
record {binary, print_field} (a:string; b:int32;)
387
In this case, the import operator prints the binary data in an octal format as shown below:
Importing a: "a string" Importing b: "\000\000\022\064"
quote
Specifies that a field is enclosed in single quotes, double quotes, or another ASCII or multi-byte Unicode character or pair of ASCII or multi-byte Unicode characters.
Applies to
Fields of any data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { quote = quotechar | quotechars } field_definition { quote = quotechar | quotechars };
where quotechar is one of the following: single, double, an ASCII or Unicode character, and quotechars is a pair of ASCII or multi-byte Unicode characters, for example, [ ]. Enclose quotechar or quotechars in single quotation marks. This property is mutually exclusive with prefix and reference.
Discussion
This property is useful for variable-length fields contained either in quotes or in other characters marking the start and end of a field. v On import, the leading quote character is ignored and all bytes up to but not including the trailing quote character are imported. v On export, the export operator inserts the leading quote character, the data, and a trailing quote character. Quote characters are not counted as part of a fields length.
Example
The following example specifies that the data imported into the variable-length string field b is contained in double quotes:
record ( a:int32; b:string {quote = double}; c:int8; d:raw; )
record_delim
Specifies a single ASCII or multi-byte Unicode character to delimit a record.
Applies to
record; cannot be a field property.
Syntax
record {record_delim [= delim_char ]}
388
where delim_char can be a newline character, a null, or one ASCII or multi-byte Unicode character. If no argument is specified, the default is a newline character. This property is mutually exclusive with record_delim_string, record_prefix, and record_format.
record_delim_string
Specifies an ASCII or multi-byte Unicode string to delimit a record.
Applies to
record; cannot be a field property.
Syntax
record { record_delim_string = ASCII_string | multi_byte_Unicode_string }
Restrictions
You cannot specify special characters by starting with a backslash escape character. For example, specifying \t, which represents an ASCII tab delimiter character, generates an error. This property is mutually exclusive with record_delim, record_prefix, and record_format.
record_format
Specifies that data consists of variable-length blocked records or implicit records.
Applies to
record; cannot be a field property.
Syntax
record { record_format = { type = type [, format = format ]}}
where type is either implicit or varying. If you choose the implicit property, data is imported or exported as a stream with no explicit record boundaries. You may not use the property delim = end with this format. On import, the import operator converts the input into records using schema information passed to it. Field boundaries are implied by the record schema passed to the operator. You cannot save rejected records with this record format. On export, the records are written with no length specifications or delimiters marking record boundaries. The end of the record is inferred when all of the fields defined by the schema have been parsed. The varying property is allows you to specify one of the following IBM blocked or spanned formats: V, VB, VS, VBS, or VR. Data is imported using that format. This property is mutually exclusive with record_length, record_delim, record_delim_string, and record_prefix.
389
record_length
Import or export fixed-length records.
Applies to
record; cannot be a field property.
Syntax
record { record_length = fixed | nbytes }
where: v fixed specifies fixed-length records; the record schema must contain only fixed-length elements so that WebSphere DataStage can calculate the record length. v nbytes explicitly specifies the record length in bytes if the record contains variable-length elements. On export, the export operator pads the records to the specified length with either zeros or the fill character if one has been specified. This property is mutually exclusive with record_format.
record_prefix
Specifies that a variable-length record is prefixed by a 1-, 2-, or 4-byte length prefix.
Applies to
record; cannot apply to fields.
Syntax
record {record_prefix [ = prefix ]}
where prefix is 1, 2, or 4. If you do not specify a value for prefix, the variable defaults to 1. This property is mutually exclusive with record_delim, record_delim_string, and record_format.
reference
Points to a link field containing the length of an imported/exported field.
Applies to
Variable-length vectors of all data types; cannot apply to record, subrec, or tagged.
Syntax
field_definition { reference = link_field};
where link_field is the name of a field of the same record that holds the length of the field defined by field_definition. Variable-length fields can specify the number of elements they contain by means of a link to another field that contains their length or the tag of a tagged subrecord. This property is mutually exclusive with prefix, delim_string, quote, and delim.
390
Example
The following statement specifies that the link field a contains the length of the variable-length string field c:
record {delim = none, binary} (a:int32 {link}; b:int16; c:string {reference = a};)
round
Round decimals on import or export.
Applies to
Fields of the decimal data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { round = rounding_type } field_definition { round = rounding_type }
where rounding_type can be one of the following: v ceil: Round the source field toward positive infinity. This mode corresponds to the IEEE 754 Round Up mode. Examples: 1.4 -> 2, -1.6 -> -1 v floor: Round the source field toward negative infinity. This mode corresponds to the IEEE 754 Round Down mode. Examples: 1.6 -> 1, -1.4 -> -2 v round_inf: Round the source field toward the nearest representable value, breaking ties by rounding toward positive infinity or negative infinity. This mode corresponds to the COBOL ROUNDED mode. Examples: 1.4 -> 1, 1.5 -> 2, -1.4 -> -1, -1.5 -> -2 v trunc_zero (default): Truncate the source field toward zero. Discard fractional digits to the right of the right-most 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, truncate to the scale size of the destination decimal. This mode corresponds to the COBOL INTEGER-PART function. Examples: 1.6 -> 1, -1.6 -> -1
scale
Specifies the scale of a packed decimal.
Applies to
Imported strings representing packed decimals; exported packed decimals to be written as strings; record, subrec, or tagged if it contains at least one field of this type.
391
Syntax
record { scale = s } field_definition { scale = s };
Discussion
By default, the import operator uses the scale defined for the WebSphere DataStage decimal field to import the source field. You can change this. On import, the scale property specifies the scale of the source packed decimal. By default, when the export operator exports a source decimal to a string representation, it uses the precision and scale defined for the source decimal field to determine the length of the destination string. You can override the default by means of the precision and scale properties. When you do, the export operator truncates or pads the source decimal to fit the size of the destination string. If you include the width property, the export operator truncates or pads the source decimal to fit the size specified by width. See width .
Restrictions
The scale property is ignored on export if you also specify text. The value of scale must be less than the precision and greater than 0. The precision is specified by the precision property. See precision .
Example
The following example is a schema used to import a source field with the same precision and scale as the destination decimal:
record ( a:decimal[6,2]; )
WebSphere DataStage imports the source field to a decimal representation with a 2-digit scale. The following schema overrides this default to import a source field with a 4-digit precision and a 1-digit scale:
record ( a:decimal[6,2] {precision = 4, scale = 1}; )
separate
Specifies that the imported or exported field contains an unpacked decimal with a separate sign byte.
Applies to
Fields of the decimal data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
field_definition { separate[, option] };
where option can be one of these: v leading (default)-the sign is contained in the first byte v trailing-the sign is contained in the last byte
392
Discussion
By default, the sign of an unpacked decimal is contained in the first byte of the imported string. The following table defines the legal values for the sign byte for both ASCII and EBCDIC:
Sign positive negative ASCII 0x2B (ASCII +) 0x2D (ASCII -) EBCDIC 0x43 (EBCDIC +) 0x60 (EBCDIC -)
Example
For example, the following schema specifies that the WebSphere DataStage decimal field contains a leading sign and has a precision of 5 and a scale of 2:
record ( a:decimal[5,2] {separate}; )
Import and export results differ: v On import, field a is imported from a decimal representation six bytes long with the sign in the first byte. v On export, the field is written to six bytes in the destination: the five contained by the decimal and one byte to contain the sign.
skip
Skip a number of bytes from the end of the previous imported/exported field to the beginning of the field.
Applies to
Fields of all data types. Cannot apply to record, subrec, or tagged .
Syntax
field_definition { skip = nbytes };
where nbytes is the number of bytes to skip after the previous record. The value of nbytes can be negative but the absolute record offset computed from this and the previous field position must always be greater than or equal to 0. On export, any skipped bytes are set to zero by default. The record-level fill property specifies an explicit value for the skipped bytes.
Example
For example, the following statement defines a record schema for the import or export operator:
record (a:int32 {position = 4}; b:int16 {skip = 2};)
Import and export results differ: v On import, this schema creates each record from an input data file by importing a 32-bit integer, beginning at byte 4 in each input record, skipping the next 2 bytes of the data file, and importing the next two bytes as a 16-bit integer. v On export, the export operator fills in the first four bytes with zeros, writes out the 32-bit integer, fills the next two bytes with zeroes, and writes the 16-bit integer.
393
tagcase
Explicitly specifies the tag value corresponding to a subfield in a tagged. By default the fields are numbered 0 to N-1, where N is the number of fields.
Applies to
Fields within tagged.
Syntax
field_definition { tagcase = n }
text
Specifies the data representation type of a field as being text rather than binary. Data is formatted as text by default.
Applies to
Fields of all data types except ustring; record. For ustring, the same functionality is available through the charset property.
Syntax
record { text } field_definition { text [, ascii | edcdic] [,import_ebcdic_as_ascii] [, export_ebcdic_as_ascii] }
Discussion
Data is formatted as text by default, as follows: v For the date data type, text specifies that the source data on import or the destination data on export, contains a text-based date in the form %yyyy-%mm-%dd or uformat. See default_date_format for a description of uformat. v For the decimal data type: an imported or exported field represents a decimal in a string format with a leading space or - followed by decimal digits with an embedded decimal point if the scale is not zero. For import, the source string format is: [+ | -]ddd[.ddd] For export, the destination string format is: [+ | -]ddd.[ddd] Any precision and scale arguments are ignored on export if you specify text. v For numeric fields (int8, int16, int32, uint8, uint16, uint32, sfloat, and dfloat): the import and export operators assume by default that numeric fields are represented as text; the import operator converts the text representation to a numeric format by means of C functions to. (See c_format , in_format , and out_format .) v For the time data type: text specifies that the imported or exported field represents time in the text-based form %hh:%nn:%ss or uformat. See default_time_format for a description of uformat. v For the timestamp data type: text specifies a text-based timestamp in the form %yyyy-%mm-%dd %hh:%nn:%ss or uformat, which is default_date_format and default_time_format concatenated. Refer to default_date_format and default_time_format .
394
Example
If you specify the following record schema:
record {text} (a:decimal[5,2];)
import and export results are as follows: v On import, the source decimal is read from a 7-byte string (five bytes for the precision, one for the sign and one for the decimal point). v On export, the field is written out as a 7-byte string.
time_format
Specifies the format of an imported or exported field representing a time as a string or ustring.
Applies to
Fields of the time data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
field_definition { time_format = time_format | uformat};
uformat is described in default_time_format . The possible components of the time_format string are given in the following table:
Table 20. Time format tags Tag %h %hh %H %HH %n %nn %s %ss %s.N %ss.N %SSS %SSSSSS %aa with v option with v option German import import import import Variable width availability import Description Hour (24), variable width Hour (24), fixed width Hour (12), variable width Hour (12), fixed width Minutes, variable width Minutes, fixed width Seconds, variable width Seconds, fixed width Value range 0...23 0...23 1...12 01...12 0...59 0...59 0...59 0...59 Options s s s s s s s s s, c, C s, c, C s, v s, v u, w
Seconds + fraction (N = 0...6) Seconds + fraction (N = 0...6) Milliseconds Microseconds am/pm marker, locale specific 0...999 0...999999 am, pm
395
By default, the format of the time contained in the string is %hh:%nn:%ss. However, you can specify a format string defining the format of the string field. You must prefix each component of the format string with the percent symbol. Separate the strings components with any character except the percent sign (%). Where indicated the tags can represent variable-fields on import, export, or both. Variable-width date elements can omit leading zeroes without causing errors. The following options can be used in the format string where indicated: s Specify this option to allow leading spaces in time formats. The s option is specified in the form: %(tag,s) Where tag is the format string. For example: %(n,s) indicates a minute field in which values can contain leading spaces or zeroes and be one or two characters wide. If you specified the following date format property: %(h,s):$(n,s):$(s,s) Then the following times would all be valid: 20: 6:58 20:06:58 20:6:58 v Use this option in conjunction with the %SSS or %SSSSSS tags to represent milliseconds or microseconds in variable-width format. So the time property: %(SSS,v) represents values in the range 0 to 999. (If you omit the v option then the range of values would be 000 to 999.) u w c C Use this option to render the am/pm text in uppercase on output. Use this option to render the am/pm text in lowercase on output. Specify this option to use a comma as the decimal separator in the %ss.N tag. Specify this option to use a period as the decimal separator in the %ss.N tag.
The c and C options override the default setting of the locale. The locale for determining the setting of the am/pm string and the default decimal separator can be controlled through the locale tag. This has the format:
%(L,locale)
Where locale specifies the locale to be set using the language_COUNTRY.variant naming convention supported by ICU. See NLS Guide for a list of locales. The default locale for am/pm string and separators markers is English unless overridden by a %L tag or the APT_IMPEXP_LOCALE environment variable (the tag takes precedence over the environment variable if both are set). Use the locale tag in conjunction with your time format, for example: %L(es)%HH:%nn %aa Specifies the Spanish locale.
396
The format string is subject to the restrictions laid out in the following table. A format string can contain at most one tag from each row. In addition some rows are mutually incompatible, as indicated in the incompatible with column. When some tags are used the format string requires that other tags are present too, as indicated in the requires column.
Table 21. Format tag restrictions Element hour am/pm marker minute second fraction of a second Numeric format tags %hh, %h, %HH, %H %nn, %n %ss, %s %ss.N, %s.N, %SSS, %SSSSSS Text format tags %aa Requires hour (%HH) Incompatible with hour (%hh) -
You can include literal text in your date format. Any Unicode character other than null, backslash, or the percent sign can be used (although it is better to avoid control codes and other non-graphic characters). The following table lists special tags and escape sequences:
Tag %% \% \n \t \\ Escape sequence literal percent sign literal percent sign newline horizontal tab single backslash
When using variable-width tags, it is good practice to enclose the time string in quotes. For example, the following schema:
f1:int32; f2:time { time_format=%h:%n:%s,, quote=double }; f3:int32;
The quotes are required because the parallel engine assumes that variable-width fields are space delimited and so might interpret a legitimate space in the time string as the end of the time.
Restrictions
You cannot specify time_format with either of the following: midnight_seconds and text. That is, you can specify only one of these options.
Example
For example, you define a format string as %hh:%nn:%ss.3 to specify that the string contains the seconds to three decimal places, that is, to milliseconds. Alternatively you could define this as %hh:%nn:%SSS.
timestamp_format
Specifies the format of an imported or exported field representing a timestamp as a string.
397
Applies to
Fields of the timestamp data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record ( {timestamp_format = timestamp_format | uformat } ) field_definition { timestamp_format = timestamp_format |uformat };
uformat is default_date_format and default_time_format concatenated. The two formats can be in any order and date and time elements can be mixed. The uformat formats are described in default_date_format and default_time_format . The timestamp_format is the date format and the time format. Again the two formats can be in any order and their elements can be mixed. The formats are described in date_format on page 362 and time_format on page 395. You must prefix each component of the format string with the percent symbol (%). Enclose timestamp_format in single quotation marks.
Default
If you do not specify the format of the timestamp it defaults to the string %yyyy-%mm-%dd %hh:%nn:%ss.
vector_prefix
Specifies 1-, 2-, or 4-byte prefix containing the number of elements in the vector.
Applies to
Fields that are variable-length vectors, which are formatted accordingly.
Syntax
record { vector_prefix [= n ] } field_definition { vector_prefix [= n ] };
where n is the optional byte size of the prefix containing the number of elements in the vector; n can be 1 (the default), 2, or 4. If a vector_prefix is defined for the entire record, you can override the definition for individual vectors.
Discussion
Variable-length vectors must use either a prefix on the vector or a link to another field in order to specify the number of elements in the vector. If the variable-length vector has a prefix, you use the property vector_prefix to indicate the prefix length. By default, the prefix length is assumed to be one byte. Behavior on import differs from that on export: v On import, the source data file must contain a prefix of each vector containing the element count. The import operator reads the length prefix but does not include the prefix as a separate field in the imported data set. v On export, the export operator inserts the element count as a prefix of each variable-length vector field. For multi-byte prefixes, the byte ordering is determined by the setting of the little_endian (little_endian), big_endian (big_endian ), or native_endian (native_endian ) properties.
398
Examples
The following schema specifies that all variable-length vectors are prefixed by a one-byte element count:
record {vector_prefix} (a[]:int32; b[]:int32; )
In the following record schema, the vector_prefix of the record (1 byte long by default) is overridden for field b, whose vector_prefix is two bytes long:
record {vector_prefix} (a[]:int32; b[]:int32 {vector_prefix = 2} )
The schema shown below specifies that the variable-length vector a is prefixed by a one-byte element count, and vector b is prefixed by a two-byte element count:
record (a[]:int32 {vector_prefix}; b[]:int32 {vector_prefix = 2};)
Import and export results differ: v On import, the source data file must contain a prefix of each vector containing the element count. v On export, the export operator inserts the element count as a prefix of each vector.
width
Specifies the number of 8-bit bytes of an imported or exported text-format field. Base your width specification on the value of your -impexp_charset option setting. If its a fixed-width charset, you can calculate the number of bytes exactly. If its a variable length encoding, base your calculation on the width and frequency of your variable-width characters.
Applies to
Fields of all data types except date, time, timestamp, and raw; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { width = n } field_definition { width = n };
where n is the number of bytes in the field; you can specify a maximum width of 255 bytes.
Discussion
This property is useful for numeric fields stored in the source or destination file in a text representation. If no width is specified and you do not use max_width to specify a maximum width, numeric fields exported as text have the following number of bytes of maximum width: v 8-bit signed or unsigned integers: 4 bytes v 16-bit signed or unsigned integers: 6 bytes v 32-bit signed or unsigned integers: 11 bytes v 64-bit signed or unsigned integers: 21 bytes v single-precision float: 14 bytes (sign, digit, decimal point, 7 fraction, E, sign, 2 exponent) v double-precision float: 24 bytes (sign, digit, decimal point, 16 fraction, E, sign, 3 exponent)
Restriction
On export, if you specify the width property with a dfloat field, the width must be at least eight bytes long.
399
zoned
Specifies that the field contains an unpacked decimal using either ASCII or EBCDIC text.
Applies to
Fields of the decimal data type; record, subrec, or tagged if it contains at least one field of this type.
Syntax
record { zoned[, option ] } field_definition { zoned[, option ]};
where option can be either trailing or leading: v trailing (default) specifies that the sign nibble is in the last byte v leading specifies that the sign nibble is in the first byte
Discussion
Import and export behavior differ: v On import, the file is read from a zoned representation of the same length, with zoning as defined by the property. v On export the field is written to the destination. The following table defines how the sign is represented in both the ASCII and EBCDIC formats:
Sign positive negative ASCII Indicated by representing the sign digit normally. Indicated by setting the 0x40 bit in the sign digits byte. This turns 0 through 9 into p through y. EBCDIC Upper nibble equal to: 0xA, 0xC, 0xE, 0xF Upper nibble equal to: 0xB, 0xD
Example
For example, the following schema specifies that the WebSphere DataStage decimal field has a precision of 5 and a scale of 2 and that its sign nibble is found in the last byte of the field:
record ( a:decimal[5,2]{zoned}; )
The precision and scale of the source decimal on import, or the destination decimal on export, defaults to the precision and scale of the WebSphere DataStage decimal field. You can use the precision (precision ) and scale (scale ) properties to override these defaults.
400
401
For example, the following figure shows an operator that uses the any partitioning method.
entire
operator
To override the any partitioning method of the operator and replace it by the entire partitioning method, you place the entire partitioner into the step as shown. The osh command for this example is:
$ osh "... | entire | op ... "
entire
Properties
Table 22. entire Partitioner Properties Property Number of input data sets Number of output data sets Input interface schema: Output interface schema Transfer behavior Execution mode Value 1 1 inRec:* outRec:* inRec to outRec without modification parallel
402
Table 22. entire Partitioner Properties (continued) Property Partitioning method Preserve-partitioning flag in output set Composite operator Value entire set no
Syntax
The entire partitioner has no options. its syntax is simply:
entire