datastage guide

637
WebSphere  ®  DataStageand Qua lit ySt age Parallel Job Devel oper Guide Version8SC18-9891-00

Upload: bharathraj765749842

Post on 02-Mar-2016

250 views

Category:

Documents


3 download

DESCRIPTION

Datastage Guide, Datastage Guide

TRANSCRIPT

  • WebSphere DataStage and QualityStage

    Parallel Job Developer Guide

    Version 8

    SC18-9891-00

  • WebSphere DataStage and QualityStage

    Parallel Job Developer Guide

    Version 8

    SC18-9891-00

  • Note Before using this information and the product that it supports, be sure to read the general information under Notices and trademarks on page 615.

    Ascential Software Corporation 2000, 2005.

    Copyright International Business Machines Corporation 2006. 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 WebSphere DataStage parallel jobs . . . . . . . 1

    Chapter 2. Designing parallel jobs . . . 3 Parallel processing . . . . . . . . . . . . 3

    Pipeline parallelism . . . . . . . . . . . 3 Partition parallelism . . . . . . . . . . . 4 Combining pipeline and partition parallelism . . 5 Repartitioning data . . . . . . . . . . . 5

    Parallel processing environments . . . . . . . 6 The configuration file . . . . . . . . . . . 7 Partitioning, repartitioning, and collecting data . . . 8

    Partitioning . . . . . . . . . . . . . . 8 Collecting . . . . . . . . . . . . . . 17 Repartitioning data . . . . . . . . . . . 21 The mechanics of partitioning and collecting . . 22

    Sorting data . . . . . . . . . . . . . . 24 Data sets . . . . . . . . . . . . . . . 24 Metadata . . . . . . . . . . . . . . . 25

    Runtime column propagation . . . . . . . 25 Table definitions . . . . . . . . . . . . 25 Schema files and partial schemas . . . . . . 26 Data types . . . . . . . . . . . . . . 26 Strings and ustrings . . . . . . . . . . 29 Complex data types . . . . . . . . . . 29 Date and time formats . . . . . . . . . . 30

    Incorporating server job functionality . . . . . . 36

    Chapter 3. Stage editors . . . . . . . 37 Showing stage validation errors . . . . . . . 41 The stage page . . . . . . . . . . . . . 41

    General tab . . . . . . . . . . . . . 41 Properties tab . . . . . . . . . . . . . 42 Advanced tab . . . . . . . . . . . . 43 Link ordering tab . . . . . . . . . . . 44 NLS Map tab . . . . . . . . . . . . . 46 NLS Locale tab . . . . . . . . . . . . 46

    Inputs page . . . . . . . . . . . . . . 47 General tab . . . . . . . . . . . . . 47 Properties tab . . . . . . . . . . . . . 47 Partitioning tab . . . . . . . . . . . . 47 Format tab . . . . . . . . . . . . . . 49 Columns Tab . . . . . . . . . . . . . 50 Advanced tab . . . . . . . . . . . . 61

    Output page . . . . . . . . . . . . . . 62 General tab . . . . . . . . . . . . . 62 Properties tab . . . . . . . . . . . . . 62 Format tab . . . . . . . . . . . . . . 62 Columns tab . . . . . . . . . . . . . 63 Mapping tab . . . . . . . . . . . . . 64 Advanced tab . . . . . . . . . . . . 65

    Chapter 4. Data set stage . . . . . . . 67 Must dos . . . . . . . . . . . . . . . 67

    Writing to a data set . . . . . . . . . . 68

    Reading from a data set . . . . . . . . . 68 Stage page . . . . . . . . . . . . . . . 68

    Advanced tab . . . . . . . . . . . . 68 Input page . . . . . . . . . . . . . . . 68

    Input link properties tab . . . . . . . . . 69 Partitioning tab . . . . . . . . . . . . 69

    Output page . . . . . . . . . . . . . . 71 Output link properties tab . . . . . . . . 71

    Chapter 5. Sequential file stage . . . . 73 Example of writing a sequential file . . . . . . 74 Example of reading a sequential file . . . . . . 75 Must dos . . . . . . . . . . . . . . . 77

    Writing to a file . . . . . . . . . . . . 77 Reading from a file . . . . . . . . . . . 77

    Stage page . . . . . . . . . . . . . . . 77 Advanced tab . . . . . . . . . . . . 77 NLS Map tab . . . . . . . . . . . . . 78

    Input page . . . . . . . . . . . . . . . 78 Input link properties tab . . . . . . . . . 78 Partitioning tab . . . . . . . . . . . . 80 Input link format tab . . . . . . . . . . 81

    Output page . . . . . . . . . . . . . . 88 Output link properties tab . . . . . . . . 88

    Chapter 6. File set stage . . . . . . . 99 Must dos . . . . . . . . . . . . . . 100

    Writing to a file . . . . . . . . . . . 100 Reading from a file . . . . . . . . . . 100

    Stage page . . . . . . . . . . . . . . 100 Advanced tab . . . . . . . . . . . . 100 NLS Map tab . . . . . . . . . . . . 101

    Input page . . . . . . . . . . . . . . 101 Input link properties tab . . . . . . . . . 101 Partitioning tab . . . . . . . . . . . . 103 Input link format tab . . . . . . . . . . 105

    Output page . . . . . . . . . . . . . . 111 Output link properties tab . . . . . . . . 112 Reject link properties . . . . . . . . . . 113 Output link Format tab . . . . . . . . . 113 Using RCP With file set stages . . . . . . . 119

    Chapter 7. Lookup file set stage . . . 121 Must dos . . . . . . . . . . . . . . 123

    Creating a lookup file set . . . . . . . . 123 Looking up a lookup file set . . . . . . . 123

    Stage page . . . . . . . . . . . . . . 123 Advanced tab . . . . . . . . . . . . 123 NLS Map tab . . . . . . . . . . . . 124

    Input page . . . . . . . . . . . . . . 124 Input link properties tab . . . . . . . . . 124 Partitioning tab . . . . . . . . . . . . 127

    Output page . . . . . . . . . . . . . . 128 Output link properties tab . . . . . . . . 128

    Copyright IBM Corp. 2006 iii

  • Chapter 8. External source stage . . . 131 Must dos . . . . . . . . . . . . . . 132 Stage page . . . . . . . . . . . . . . 132

    Advanced tab . . . . . . . . . . . . 132 NLS Map tab . . . . . . . . . . . . 133

    Output page . . . . . . . . . . . . . . 133 Output link properties tab . . . . . . . . 133 Output link Format tab . . . . . . . . . 134 Using RCP With External Source Stages . . . 141

    Chapter 9. External Target stage . . . 143 Must dos . . . . . . . . . . . . . . 144 Stage page . . . . . . . . . . . . . . 144

    Advanced tab . . . . . . . . . . . . 144 NLS Map tab . . . . . . . . . . . . 145

    Input page . . . . . . . . . . . . . . 145 Input link properties tab . . . . . . . . . 145 Partitioning tab . . . . . . . . . . . . 146 Format tab . . . . . . . . . . . . . 147

    Using RCP with External Target stages . . . . . 155

    Chapter 10. Complex Flat File stage 157 Editing a Complex Flat File stage as a source . . . 157

    Creating record definitions . . . . . . . . 158 Column definitions . . . . . . . . . . 158 Defining record ID constraints . . . . . . . 160 Selecting output columns . . . . . . . . 161 Defining output link constraints . . . . . . 164

    Editing a Complex Flat File stage as a target . . . 164 Reject links . . . . . . . . . . . . . . 165

    Chapter 11. Transformer stage . . . . 167 Must dos . . . . . . . . . . . . . . 167 Transformer editor components . . . . . . . 168

    Toolbar . . . . . . . . . . . . . . 168 Link area . . . . . . . . . . . . . . 168 Metadata area . . . . . . . . . . . . 169 Shortcut menus . . . . . . . . . . . . 169

    Transformer stage basic concepts . . . . . . . 170 Input link . . . . . . . . . . . . . 170 Output links . . . . . . . . . . . . . 170

    Editing Transformer stages . . . . . . . . . 171 Using drag and drop . . . . . . . . . . 171 Find and replace facilities . . . . . . . . 171 Select facilities . . . . . . . . . . . . 172 Creating and deleting columns . . . . . . 172 Moving columns within a link . . . . . . . 173 Editing column meta data . . . . . . . . 173 Defining output column derivations . . . . . 173 Editing multiple derivations . . . . . . . 174 Handling null values in input columns . . . . 176 Defining constraints and handling otherwise links . . . . . . . . . . . . . . . 176 Specifying link order . . . . . . . . . . 177 Defining local stage variables . . . . . . . 177

    The WebSphere DataStage expression editor . . . 178 Expression format . . . . . . . . . . . 178 Entering expressions . . . . . . . . . . 179 Completing variable names . . . . . . . . 179 Validating the expression . . . . . . . . 180

    Exiting the expression editor . . . . . . . 180 Configuring the expression editor . . . . . 180 System variables . . . . . . . . . . . 180 Guide to using transformer expressions and stage variables . . . . . . . . . . . . 181

    Transformer stage properties . . . . . . . . 182 Stage page . . . . . . . . . . . . . 182 Input page . . . . . . . . . . . . . 185 Output page . . . . . . . . . . . . . 186

    Chapter 12. BASIC Transformer stages . . . . . . . . . . . . . . 187 Must dos . . . . . . . . . . . . . . 187 BASIC Transformer editor components . . . . . 187

    Toolbar . . . . . . . . . . . . . . 187 Link area . . . . . . . . . . . . . . 188 Metadata area . . . . . . . . . . . . 188 Shortcut menus . . . . . . . . . . . . 188

    BASIC Transformer stage basic concepts . . . . 189 Input link . . . . . . . . . . . . . 189 Output links . . . . . . . . . . . . . 189 Before-stage and after-stage routines . . . . . 190

    Editing BASIC transformer stages . . . . . . 190 Using drag and drop . . . . . . . . . . 190 Find and replace facilities . . . . . . . . 191 Select facilities . . . . . . . . . . . . 191 Creating and deleting columns . . . . . . 192 Moving columns within a link . . . . . . . 192 Editing column meta data . . . . . . . . 192 Defining output column derivations . . . . . 193 Editing multiple derivations . . . . . . . 194 Specifying before-stage and after-stage subroutines . . . . . . . . . . . . . 195 Defining constraints and handling reject links 196 Specifying link order . . . . . . . . . . 197 Defining local stage variables . . . . . . . 197

    The WebSphere DataStage expression editor . . . 198 Expression format . . . . . . . . . . . 198 Entering expressions . . . . . . . . . . 199 Completing variable names . . . . . . . . 200 Validating the expression . . . . . . . . 200 Exiting the expression editor . . . . . . . 200 Configuring the expression editor . . . . . 200

    BASIC Transformer stage properties . . . . . . 200 Stage page . . . . . . . . . . . . . 200 Input page . . . . . . . . . . . . . 201 Output page . . . . . . . . . . . . . 203

    Chapter 13. Aggregator stage . . . . 205 Example . . . . . . . . . . . . . . . 206 Must dos . . . . . . . . . . . . . . 208 Stage page . . . . . . . . . . . . . . 209

    Properties tab . . . . . . . . . . . . 209 Advanced tab . . . . . . . . . . . . 214 NLS Locale tab . . . . . . . . . . . . 215

    Input page . . . . . . . . . . . . . . 215 Partitioning tab . . . . . . . . . . . . 215

    Output page . . . . . . . . . . . . . . 216 Mapping tab . . . . . . . . . . . . 217

    iv Parallel Job Developer Guide

  • Chapter 14. Join stage . . . . . . . 219 Join versus lookup . . . . . . . . . . . 220 Example joins . . . . . . . . . . . . . 220

    Inner join . . . . . . . . . . . . . . 221 Left outer join . . . . . . . . . . . . 221 Right outer join . . . . . . . . . . . 221 Full outer join . . . . . . . . . . . . 222

    Must dos . . . . . . . . . . . . . . 222 Stage page . . . . . . . . . . . . . . 223

    Properties tab . . . . . . . . . . . . 223 Advanced tab . . . . . . . . . . . . 224 Link ordering tab . . . . . . . . . . . 224 NLS Locale tab . . . . . . . . . . . . 224

    Input page . . . . . . . . . . . . . . 224 Partitioning on input links . . . . . . . . 225

    Output page . . . . . . . . . . . . . . 226 Mapping tab . . . . . . . . . . . . 226

    Chapter 15. Merge Stage . . . . . . 227 Example merge . . . . . . . . . . . . . 228 Must dos . . . . . . . . . . . . . . 229 Stage page . . . . . . . . . . . . . . 229

    Properties tab . . . . . . . . . . . . 229 Advanced Tab . . . . . . . . . . . . 231 Link Ordering tab . . . . . . . . . . . 231 NLS Locale tab . . . . . . . . . . . . 231

    Input page . . . . . . . . . . . . . . 231 Partitioning tab . . . . . . . . . . . . 232

    Output page . . . . . . . . . . . . . . 233 Reject links . . . . . . . . . . . . . 233 Mapping tab . . . . . . . . . . . . 234

    Chapter 16. Lookup Stage . . . . . . 235 Lookup Versus Join . . . . . . . . . . . 236 Example Look Up . . . . . . . . . . . . 236 Must Dos . . . . . . . . . . . . . . 237

    Using In-Memory Lookup tables . . . . . . 238 Using Oracle or DB2 Databases Directly . . . 239 Using Lookup File Set . . . . . . . . . 240

    Lookup Editor Components . . . . . . . . 240 Toolbar . . . . . . . . . . . . . . 240 Link Area . . . . . . . . . . . . . 241 Meta Data Area . . . . . . . . . . . 241 Shortcut Menus . . . . . . . . . . . 241

    Editing Lookup Stages . . . . . . . . . . 242 Using Drag and Drop . . . . . . . . . 242 Find and Replace Facilities . . . . . . . . 243 Select Facilities . . . . . . . . . . . . 243 Creating and Deleting Columns . . . . . . 244 Moving Columns Within a Link . . . . . . 244 Editing Column Meta Data . . . . . . . . 244 Defining Output Column Derivations . . . . 244 Defining Input Column Key Expressions . . . 245

    Lookup Stage Properties . . . . . . . . . . 245 Stage Page . . . . . . . . . . . . . 246 Input Page . . . . . . . . . . . . . 247 Output Page . . . . . . . . . . . . . 249

    Lookup Stage Conditions . . . . . . . . . 249 Range lookups . . . . . . . . . . . . . 250 The WebSphere DataStage Expression Editor . . . 250

    Expression Format . . . . . . . . . . . 250 Entering Expressions . . . . . . . . . . 251 Completing Variable Names . . . . . . . 251 Validating the Expression . . . . . . . . 252 Exiting the Expression Editor . . . . . . . 252 Configuring the Expression Editor . . . . . 252

    Chapter 17. Sort stage . . . . . . . 253 Examples . . . . . . . . . . . . . . . 255

    Sequential Sort . . . . . . . . . . . . 255 Parallel sort . . . . . . . . . . . . . 257 Total sort . . . . . . . . . . . . . . 258

    Must dos . . . . . . . . . . . . . . 259 Stage page . . . . . . . . . . . . . . 259

    Properties tab . . . . . . . . . . . . 259 Advanced tab . . . . . . . . . . . . 262 NLS Locale tab . . . . . . . . . . . . 262

    Input page . . . . . . . . . . . . . . 263 Partitioning tab . . . . . . . . . . . . 263

    Output page . . . . . . . . . . . . . . 264 Mapping tab . . . . . . . . . . . . 265

    Chapter 18. Funnel Stage . . . . . . 267 Examples . . . . . . . . . . . . . . . 268

    Continuous funnel example . . . . . . . 268 Sort Funnel Example . . . . . . . . . . 269 Sequence funnel example . . . . . . . . 270

    Must dos . . . . . . . . . . . . . . 271 Stage page . . . . . . . . . . . . . . 271

    Properties tab . . . . . . . . . . . . 271 Advanced tab . . . . . . . . . . . . 272 Link Ordering tab . . . . . . . . . . . 273 NLS Locale tab . . . . . . . . . . . . 273

    Input page . . . . . . . . . . . . . . 273 Partitioning on input links . . . . . . . . 273

    Output page . . . . . . . . . . . . . . 275 Mapping tab . . . . . . . . . . . . 275

    Chapter 19. Remove Duplicates Stage 277 Example . . . . . . . . . . . . . . . 277 Must dos . . . . . . . . . . . . . . 278 Stage page . . . . . . . . . . . . . . 278

    Properties tab . . . . . . . . . . . . 279 Advanced tab . . . . . . . . . . . . 279 NLS Locale tab . . . . . . . . . . . . 280

    Input page . . . . . . . . . . . . . . 280 Partitioning on input links . . . . . . . . 280

    Output page . . . . . . . . . . . . . . 282 Mapping tab . . . . . . . . . . . . 282

    Chapter 20. Compress stage . . . . . 283 Must dos . . . . . . . . . . . . . . 284 Stage page . . . . . . . . . . . . . . 284

    Properties tab . . . . . . . . . . . . 284 Advanced tab . . . . . . . . . . . . 284

    Input page . . . . . . . . . . . . . . 285 Partitioning on input links . . . . . . . . 285

    Output page . . . . . . . . . . . . . . 286

    Chapter 21. Expand Stage . . . . . . 287

    Contents v

  • Must dos . . . . . . . . . . . . . . 287 Stage page . . . . . . . . . . . . . . 287

    Properties tab . . . . . . . . . . . . 287 Advanced tab . . . . . . . . . . . . 288

    Input page . . . . . . . . . . . . . . 288 Partitioning on input Llinks . . . . . . . 288

    Output page . . . . . . . . . . . . . . 289

    Chapter 22. Copy stage . . . . . . . 291 Example . . . . . . . . . . . . . . . 291 Must dos . . . . . . . . . . . . . . 296 Stage page . . . . . . . . . . . . . . 297

    Properties tab . . . . . . . . . . . . 297 Advanced tab . . . . . . . . . . . . 297

    Input page . . . . . . . . . . . . . . 297 Partitioning on input links . . . . . . . . 298

    Output page . . . . . . . . . . . . . . 299 Mapping tab . . . . . . . . . . . . 299

    Chapter 23. Modify stage . . . . . . 301 Examples . . . . . . . . . . . . . . . 301

    Dropping and keeping columns . . . . . . 301 Changing data type . . . . . . . . . . 302 Null handling . . . . . . . . . . . . 302

    Must dos . . . . . . . . . . . . . . 303 Stage page . . . . . . . . . . . . . . 303

    Properties tab . . . . . . . . . . . . 303 Advanced tab . . . . . . . . . . . . 315

    Input page . . . . . . . . . . . . . . 316 Partitioning on input links . . . . . . . . 316

    Output page . . . . . . . . . . . . . . 317

    Chapter 24. Filter Stage . . . . . . . 319 Specifying the filter . . . . . . . . . . . 319

    Input data columns . . . . . . . . . . 320 Supported Boolean expressions and operators 320 String comparison . . . . . . . . . . . 320 Examples . . . . . . . . . . . . . . 321

    Must dos . . . . . . . . . . . . . . 321 Stage page . . . . . . . . . . . . . . 322

    Properties tab . . . . . . . . . . . . 322 Advanced tab . . . . . . . . . . . . 323 Link Ordering tab . . . . . . . . . . . 323 NLS Locale tab . . . . . . . . . . . . 323

    Input page . . . . . . . . . . . . . . 324 Partitioning on input links . . . . . . . . 324

    Output page . . . . . . . . . . . . . . 325 Mapping tab . . . . . . . . . . . . 325

    Chapter 25. External Filter stage . . . 327 Must dos . . . . . . . . . . . . . . 327 Stage page . . . . . . . . . . . . . . 327

    Properties tab . . . . . . . . . . . . 327 Advanced tab . . . . . . . . . . . . 328

    Input page . . . . . . . . . . . . . . 328 Partitioning on input links . . . . . . . . 329

    Output page . . . . . . . . . . . . . . 330

    Chapter 26. Change Capture stage 331 Example Data . . . . . . . . . . . . . 332

    Must dos . . . . . . . . . . . . . . 333 Stage page . . . . . . . . . . . . . . 333

    Properties tab . . . . . . . . . . . . 333 Advanced tab . . . . . . . . . . . . 336 Link Ordering tab . . . . . . . . . . . 336 NLS Locale tab . . . . . . . . . . . . 336

    Input page . . . . . . . . . . . . . . 337 Partitioning tab . . . . . . . . . . . . 337

    Output page . . . . . . . . . . . . . . 338 Mapping tab . . . . . . . . . . . . 338

    Chapter 27. Change Apply stage . . . 341 Example Data . . . . . . . . . . . . . 342 Must dos . . . . . . . . . . . . . . 343 Stage page . . . . . . . . . . . . . . 344

    Properties tab . . . . . . . . . . . . 344 Advanced tab . . . . . . . . . . . . 346 Link Ordering tab . . . . . . . . . . . 346 NLS Locale tab . . . . . . . . . . . . 346

    Input page . . . . . . . . . . . . . . 347 Partitioning tab . . . . . . . . . . . . 347

    Output page . . . . . . . . . . . . . . 348 Mapping tab . . . . . . . . . . . . 348

    Chapter 28. Difference stage . . . . . 351 Example data . . . . . . . . . . . . . 351 Must dos . . . . . . . . . . . . . . 353 Stage page . . . . . . . . . . . . . . 353

    Properties tab . . . . . . . . . . . . 353 Advanced tab . . . . . . . . . . . . 355 Link Ordering tab . . . . . . . . . . . 356 NLS Locale tab . . . . . . . . . . . . 356

    Input page . . . . . . . . . . . . . . 356 Partitioning tab . . . . . . . . . . . . 356

    Output page . . . . . . . . . . . . . . 358 Mapping tab . . . . . . . . . . . . 358

    Chapter 29. Compare stage . . . . . 359 Example Data . . . . . . . . . . . . . 359 Must dos . . . . . . . . . . . . . . 361 Stage page . . . . . . . . . . . . . . 361

    Properties tab . . . . . . . . . . . . 361 Advanced tab . . . . . . . . . . . . 362 Link Ordering tab . . . . . . . . . . . 363 NLS Locale tab . . . . . . . . . . . . 363

    Input page . . . . . . . . . . . . . . 363 Partitioning tab . . . . . . . . . . . . 363

    Output page . . . . . . . . . . . . . . 365

    Chapter 30. Encode Stage . . . . . . 367 Must dos . . . . . . . . . . . . . . 367 Stage page . . . . . . . . . . . . . . 367

    Properties tab . . . . . . . . . . . . 368 Advanced tab . . . . . . . . . . . . 368

    Input page . . . . . . . . . . . . . . 368 Partitioning tab . . . . . . . . . . . . 369

    Output page . . . . . . . . . . . . . . 370

    Chapter 31. Decode stage . . . . . . 371 Must dos . . . . . . . . . . . . . . 371

    vi Parallel Job Developer Guide

  • Stage page . . . . . . . . . . . . . . 371 Properties tab . . . . . . . . . . . . 371 Advanced tab . . . . . . . . . . . . 372

    Input page . . . . . . . . . . . . . . 372 Partitioning tab . . . . . . . . . . . . 372

    Output page . . . . . . . . . . . . . . 373

    Chapter 32. Switch stage . . . . . . 375 Example . . . . . . . . . . . . . . . 375 Must dos . . . . . . . . . . . . . . 376 Stage page . . . . . . . . . . . . . . 377

    Properties tab . . . . . . . . . . . . 377 Advanced tab . . . . . . . . . . . . 379 Link Ordering tab . . . . . . . . . . . 379 NLS Locale tab . . . . . . . . . . . . 379

    Input page . . . . . . . . . . . . . . 379 Partitioning tab . . . . . . . . . . . . 380

    Output page . . . . . . . . . . . . . . 381 Mapping tab . . . . . . . . . . . . 381 Reject link . . . . . . . . . . . . . 382

    Chapter 33. FTP Enterprise Stage . . . 383 Restartability . . . . . . . . . . . . . 383 Must Dos . . . . . . . . . . . . . . 384

    Transferring Data to a Remote Host Using the FTP Enterprise Stage . . . . . . . . . . 384 Accessing Data from a Remote Host Using the FTP Enterprise Stage . . . . . . . . . . 384

    Stage Page . . . . . . . . . . . . . . 384 Advanced tab . . . . . . . . . . . . 385 NLS Map Tab . . . . . . . . . . . . 385

    Input Page . . . . . . . . . . . . . . 385 Properties Tab . . . . . . . . . . . . 385 Partitioning Tab . . . . . . . . . . . 388

    Output Page . . . . . . . . . . . . . . 390 Properties Tab . . . . . . . . . . . . 390

    Chapter 34. Generic stage . . . . . . 395 Must dos . . . . . . . . . . . . . . 395 Stage page . . . . . . . . . . . . . . 396

    Properties tab . . . . . . . . . . . . 396 Advanced tab . . . . . . . . . . . . 396 Link Ordering tab . . . . . . . . . . . 397

    Input page . . . . . . . . . . . . . . 397 Partitioning tab . . . . . . . . . . . . 397

    Output page . . . . . . . . . . . . . . 398

    Chapter 35. Surrogate Key Generator stage . . . . . . . . . . . . . . . 401 Creating the key source . . . . . . . . . . 401 Deleting the key source . . . . . . . . . . 402 Updating the state file . . . . . . . . . . 402 Generating surrogate keys . . . . . . . . . 402

    Chapter 36. Slowly Changing Dimension stage . . . . . . . . . . 405 Job design using a Slowly Changing Dimension stage . . . . . . . . . . . . . . . . 405

    Purpose codes in a Slowly Changing Dimension stage . . . . . . . . . . . . . . . . 408 Surrogate keys in a Slowly Changing Dimension stage . . . . . . . . . . . . . . . . 408 Editing a Slowly Changing Dimension stage . . . 409

    Defining the match condition . . . . . . . 410 Selecting purpose codes . . . . . . . . . 410 Specifying information about a key source . . . 411 Creating derivations for dimension columns . . 411 Mapping data to the output link . . . . . . 412

    Dimension update action . . . . . . . . . 412

    Chapter 37. Column Import stage . . . 415 Examples . . . . . . . . . . . . . . . 415 Must dos . . . . . . . . . . . . . . 418 Stage page . . . . . . . . . . . . . . 418

    Properties tab . . . . . . . . . . . . 418 Advanced tab . . . . . . . . . . . . 420

    Input page . . . . . . . . . . . . . . 420 Partitioning tab . . . . . . . . . . . . 420

    Output page . . . . . . . . . . . . . . 422 Mapping tab . . . . . . . . . . . . 422 Mapping tab . . . . . . . . . . . . 422 Reject link . . . . . . . . . . . . . 422

    Using RCP With Column Import Stages . . . . 423

    Chapter 38. Column Export stage . . . 425 Examples . . . . . . . . . . . . . . . 425 Must dos . . . . . . . . . . . . . . 428 Stage page . . . . . . . . . . . . . . 428

    Properties tab . . . . . . . . . . . . 429 Advanced tab . . . . . . . . . . . . 430

    Input page . . . . . . . . . . . . . . 430 Partitioning tab . . . . . . . . . . . . 430 Format tab . . . . . . . . . . . . . 432 Mapping tab . . . . . . . . . . . . 439 Reject link . . . . . . . . . . . . . 439

    Using RCP with Column Export stages . . . . . 439

    Chapter 39. Make Subrecord stage 441 Examples . . . . . . . . . . . . . . . 442 Must dos . . . . . . . . . . . . . . 445 Stage page . . . . . . . . . . . . . . 445

    Properties tab . . . . . . . . . . . . 445 Advanced tab . . . . . . . . . . . . 446

    Input page . . . . . . . . . . . . . . 446 Partitioning tab . . . . . . . . . . . . 447

    Output page . . . . . . . . . . . . . . 448

    Chapter 40. Split Subrecord Stage 449 Examples . . . . . . . . . . . . . . . 450 Must dos . . . . . . . . . . . . . . 451 Stage page . . . . . . . . . . . . . . 452

    Properties tab . . . . . . . . . . . . 452 Advanced tab . . . . . . . . . . . . 452

    Input page . . . . . . . . . . . . . . 452 Partitioning tab . . . . . . . . . . . . 453

    Output page . . . . . . . . . . . . . . 454

    Chapter 41. Combine Records stage 455

    Contents vii

  • Examples . . . . . . . . . . . . . . . 456 Example 1 . . . . . . . . . . . . . 456 Example 2 . . . . . . . . . . . . . 458

    Must dos . . . . . . . . . . . . . . 460 Stage page . . . . . . . . . . . . . . 460

    Properties tab . . . . . . . . . . . . 460 Advanced tab . . . . . . . . . . . . 461 NLS Locale tab . . . . . . . . . . . . 461

    Input page . . . . . . . . . . . . . . 462 Partitioning tab . . . . . . . . . . . . 462

    Output page . . . . . . . . . . . . . . 463

    Chapter 42. Promote Subrecord sStage . . . . . . . . . . . . . . 465 Examples . . . . . . . . . . . . . . . 466

    Example 1 . . . . . . . . . . . . . 466 Example 2 . . . . . . . . . . . . . 467

    Must dos . . . . . . . . . . . . . . 469 Stage page . . . . . . . . . . . . . . 469

    Properties tab . . . . . . . . . . . . 469 Advanced tab . . . . . . . . . . . . 469

    Input page . . . . . . . . . . . . . . 470 Partitioning tab . . . . . . . . . . . . 470

    Output page . . . . . . . . . . . . . . 471

    Chapter 43. Make Vector stage . . . . 473 Examples . . . . . . . . . . . . . . . 474

    Example 1 . . . . . . . . . . . . . 474 Example 2 . . . . . . . . . . . . . 475

    Must dos . . . . . . . . . . . . . . 476 Stage page . . . . . . . . . . . . . . 476

    Properties tab . . . . . . . . . . . . 477 Advanced tab . . . . . . . . . . . . 477

    Input page . . . . . . . . . . . . . . 477 Partitioning tab . . . . . . . . . . . . 478

    Output page . . . . . . . . . . . . . . 479

    Chapter 44. Split Vector Stage . . . . 481 Examples . . . . . . . . . . . . . . . 481

    Example 1 . . . . . . . . . . . . . 482 Example 2 . . . . . . . . . . . . . 483

    Must dos . . . . . . . . . . . . . . 484 Stage page . . . . . . . . . . . . . . 484

    Properties tab . . . . . . . . . . . . 484 Advanced tab . . . . . . . . . . . . 484

    Input page . . . . . . . . . . . . . . 485 Partitioning tab . . . . . . . . . . . . 485

    Output page . . . . . . . . . . . . . . 487

    Chapter 45. Head stage . . . . . . . 489 Examples . . . . . . . . . . . . . . . 489

    Head stage default behavior . . . . . . . 489 Skipping Data . . . . . . . . . . . . 490

    Must dos . . . . . . . . . . . . . . 491 Stage page . . . . . . . . . . . . . . 492

    Properties tab . . . . . . . . . . . . 492 Advanced tab . . . . . . . . . . . . 493

    Input page . . . . . . . . . . . . . . 493 Partitioning tab . . . . . . . . . . . . 493

    Output page . . . . . . . . . . . . . . 495

    Mapping tab . . . . . . . . . . . . 495

    Chapter 46. Tail stage . . . . . . . . 497 Examples . . . . . . . . . . . . . . . 497 Must dos . . . . . . . . . . . . . . 498 Stage page . . . . . . . . . . . . . . 499

    Properties tab . . . . . . . . . . . . 499 Advanced tab . . . . . . . . . . . . 499

    Input page . . . . . . . . . . . . . . 500 Partitioning tab . . . . . . . . . . . . 500

    Output page . . . . . . . . . . . . . . 501 Mapping tab . . . . . . . . . . . . 502

    Chapter 47. Sample stage . . . . . . 503 Examples . . . . . . . . . . . . . . . 504

    Sampling in percent mode . . . . . . . . 504 Sampling in Period Mode . . . . . . . . 506

    Must dos . . . . . . . . . . . . . . 508 Stage page . . . . . . . . . . . . . . 508

    Properties tab . . . . . . . . . . . . 508 Advanced tab . . . . . . . . . . . . 509 Link Ordering tab . . . . . . . . . . . 510

    Input page . . . . . . . . . . . . . . 510 Partitioning on input links . . . . . . . . 510

    Output page . . . . . . . . . . . . . . 511 Mapping tab . . . . . . . . . . . . 512

    Chapter 48. Peek stage . . . . . . . 513 Must dos . . . . . . . . . . . . . . 513 Stage page . . . . . . . . . . . . . . 513

    Properties tab . . . . . . . . . . . . 514 Advanced tab . . . . . . . . . . . . 515 Link Ordering tab . . . . . . . . . . . 516

    Input page . . . . . . . . . . . . . . 516 Partitioning tab . . . . . . . . . . . . 516

    Output page . . . . . . . . . . . . . . 518 Mapping tab . . . . . . . . . . . . 518

    Chapter 49. Row Generator stage . . . 519 Examples . . . . . . . . . . . . . . . 519

    Using a Row Generator Stage in Default Mode 519 Example of specifying data to be generated . . 520 Example of generating data in parallel . . . . 521

    Must dos . . . . . . . . . . . . . . 523 Stage page . . . . . . . . . . . . . . 523

    Advanced tab . . . . . . . . . . . . 523 Output page . . . . . . . . . . . . . . 523

    Properties tab . . . . . . . . . . . . 524

    Chapter 50. Column Generator stage 525 Example . . . . . . . . . . . . . . . 525 Must dos . . . . . . . . . . . . . . 527 Stage page . . . . . . . . . . . . . . 528

    Properties tab . . . . . . . . . . . . 528 Advanced tab . . . . . . . . . . . . 529

    Input page . . . . . . . . . . . . . . 529 Partitioning on input links . . . . . . . . 529

    Output page . . . . . . . . . . . . . . 531 Mapping tab . . . . . . . . . . . . 531

    viii Parallel Job Developer Guide

  • Chapter 51. Write Range Map stage 533 Example . . . . . . . . . . . . . . . 533 Must dos . . . . . . . . . . . . . . 534 Stage page . . . . . . . . . . . . . . 534

    Advanced tab . . . . . . . . . . . . 535 NLS Locale tab . . . . . . . . . . . . 535

    Input page . . . . . . . . . . . . . . 535 Input Link Properties tab . . . . . . . . 535 Partitioning tab . . . . . . . . . . . . 536

    Chapter 52. Parallel jobs on USS . . . 539 Set up . . . . . . . . . . . . . . . . 539 Deployment options . . . . . . . . . . . 539

    Deploy under control of WebSphere DataStage 539 Deploy standalone . . . . . . . . . . 541

    Implementation details . . . . . . . . . . 542 Directory structure . . . . . . . . . . 542 Generated files . . . . . . . . . . . . 543 Configuration files . . . . . . . . . . . 544

    Running jobs on the USS machine . . . . . . 544 Deploying and running from WebSphere DataStage . . . . . . . . . . . . . 544 Deploying from WebSphere DataStage, running manually . . . . . . . . . . . . . . 545 Deploying and running manually . . . . . 545

    Chapter 53. Managing data sets . . . 547 Structure of data sets . . . . . . . . . . . 547 Starting the data set manager . . . . . . . . 548 Data set viewer . . . . . . . . . . . . . 548

    Viewing the schema . . . . . . . . . . 548 Viewing the data . . . . . . . . . . . 548 Copying data sets . . . . . . . . . . . 549 Deleting data sets . . . . . . . . . . . 549

    Chapter 54. The Parallel engine configuration file . . . . . . . . . . 551 Configurations editor . . . . . . . . . . . 551 Configuration considerations . . . . . . . . 551

    Logical processing nodes . . . . . . . . 552 Optimizing parallelism . . . . . . . . . 552 Configuration options for an SMP . . . . . 553 Example Configuration File for an SMP . . . 555 Configuration options for an MPP system . . . 556 An Example of a four-node MPP system configuration . . . . . . . . . . . . 557 Configuration options for an SMP cluster . . . 558 An example of an SMP cluster configuration 559 Options for a cluster with the conductor unconnected to the high-speed switch . . . . 560 Diagram of a cluster environment . . . . . 562

    Configuration files . . . . . . . . . . . . 563 The default path name and the APT_CONFIG_FILE . . . . . . . . . . 564 Syntax . . . . . . . . . . . . . . . 564 Node names . . . . . . . . . . . . . 565 Options . . . . . . . . . . . . . . 565 Node pools and the default node pool . . . . 568 Disk and scratch disk pools and their defaults 569 Buffer scratch disk pools . . . . . . . . 570

    The resource DB2 option . . . . . . . . . 570 The resource INFORMIX option . . . . . . . 571 The resource ORACLE option . . . . . . . . 572 The SAS resources . . . . . . . . . . . . 573

    Adding SAS information to your configuration file . . . . . . . . . . . . . . . . 573 Example . . . . . . . . . . . . . . 573

    Sort configuration . . . . . . . . . . . . 573 Allocation of resources . . . . . . . . . . 574 Selective configuration with startup scripts . . . 574 Hints and tips . . . . . . . . . . . . . 575

    Chapter 55. Remote deployment . . . 579 Enabling a project for job deployment . . . . . 580 Deployment package . . . . . . . . . . . 581

    Command shell script - pxrun.sh . . . . . . 581 Environment variable setting source script - evdepfile . . . . . . . . . . . . . . 581 Main parallel (OSH) program script - OshScript.osh . . . . . . . . . . . . 581 Script parameter file - jpdepfile . . . . . . 581 XML report file - .xml . . . . . . 582 Compiled transformer binary files - .trx.so . . . . . . . 582 Self-contained transformer compilation . . . . 582

    Deploying a job . . . . . . . . . . . . 582 Server side plug-ins . . . . . . . . . . . 583

    Appendix A. Schemas . . . . . . . . 585 Schema format . . . . . . . . . . . . . 585

    Date columns . . . . . . . . . . . . 586 Decimal columns . . . . . . . . . . . 586 Floating-point columns . . . . . . . . . 587 Integer columns . . . . . . . . . . . 587 Raw columns . . . . . . . . . . . . 587 String columns . . . . . . . . . . . . 587 Time columns . . . . . . . . . . . . 588 Timestamp columns . . . . . . . . . . 588 Vectors . . . . . . . . . . . . . . 588 Subrecords . . . . . . . . . . . . . 588 Tagged columns . . . . . . . . . . . 589

    Partial schemas . . . . . . . . . . . . . 590

    Appendix B. Functions . . . . . . . 593 Date and time functions . . . . . . . . . . 593 Logical Functions . . . . . . . . . . . . 595 Mathematical Functions . . . . . . . . . . 595 Null handling functions . . . . . . . . . . 597 Number functions . . . . . . . . . . . . 598 Raw functions . . . . . . . . . . . . . 598 String functions . . . . . . . . . . . . 598 Vector function . . . . . . . . . . . . . 600 Type Conversion Functions . . . . . . . . . 601 Type `casting functions . . . . . . . . . . 602 Utility functions . . . . . . . . . . . . 603

    Appendix C. Fillers . . . . . . . . . 605 Creating fillers . . . . . . . . . . . . . 605

    Filler creation rules . . . . . . . . . . 605 Filler creation examples . . . . . . . . . 606

    Contents ix

  • Expanding fillers . . . . . . . . . . . . 611

    Accessing information about IBM . . 613 Contacting IBM . . . . . . . . . . . . 613 Accessible documentation . . . . . . . . . 613 Providing comments on the documentation . . . 614

    Notices and trademarks . . . . . . . 615 Notices . . . . . . . . . . . . . . . 615 Trademarks . . . . . . . . . . . . . . 617

    Index . . . . . . . . . . . . . . . 619

    x Parallel Job Developer Guide

  • Chapter 1. Introduction This chapter gives an overview of parallel jobs. Parallel jobs are developed using the WebSphere

    DataStage Designer and compiled and run on the WebSphere DataStage server. Such jobs commonly connect to a data source, extract, and transform data and write it to a data warehouse.

    WebSphere DataStage allows you to concentrate on designing your job sequentially, without worrying too much about how parallel processing will be implemented. You specify the logic of the job, WebSphere DataStage specifies the best implementation on the available hardware. If required, however, you can exert more exact control on job implementation.

    Once designed, parallel jobs can run on SMP, MPP, or cluster systems. Jobs are scaleable. The more processors you have, the faster the job will run.

    Parallel jobs can also be run on a USS system, special instructions for this are given in Chapter 52, Parallel jobs on USS, on page 539.

    Note: You must choose to either run parallel jobs on standard UNIX systems or on USS systems in the WebSphere DataStage Administrator. You cannot run both types of job at the same time. See WebSphere DataStage Administrator Client Guide.

    WebSphere DataStage also supports server jobs and mainframe jobs. Server jobs are compiled and run on the server. These are for use on non-parallel systems and SMP systems with up to 64 processors. Server jobs are described in WebSphere DataStage Server Job Developer Guide. Mainframe jobs are available if have Enterprise MVS Edition installed. These are loaded onto a mainframe and compiled and run there. Mainframe jobs are described in WebSphere DataStage Mainframe Job Developer Guide.

    WebSphere DataStage parallel jobs WebSphere DataStage jobs consist of individual stages. Each stage describes a particular process, this may be accessing a database or transforming data in some way. For example, one stage may extract data from a data source, while another transforms it. Stages are added to a job and linked together using the Designer.

    The following diagram represents one of the simplest jobs you could have: a data source, a Transformer (conversion) stage, and the final database. The links between the stages represent the flow of data into or out of a stage. In a parallel job each stage would correspond to a process. You can have multiple instances of each process to run on the available processors in your system.

    datasource

    transformer datatarget

    Copyright IBM Corp. 2006 1

  • You must specify the data you want at each stage, and how it is handled. For example, do you want all the columns in the source data, or only a select few? Are you going to rename any of the columns? How are they going to be transformed?

    You lay down these stages and links on the canvas of the WebSphere DataStage Designer. You specify the design as if it was sequential, WebSphere DataStage determines how the stages will become processes and how many instances of these will actually be run.

    WebSphere DataStage also allows you to store reuseable components in the Repository which can be incorporated into different job designs. You can import these components, or entire jobs, from other WebSphere DataStage Projects using the Designer. You can also import meta data directly from data sources and data targets.

    Guidance on how to construct your job and define the required meta data using the Designer is in the WebSphere DataStage Designer Client Guide. Chapter 4 onwards of this manual describe the individual stage editors that you may use when developing parallel jobs.

    2 Parallel Job Developer Guide

  • Chapter 2. Designing parallel jobs Parallel jobs brings the power of parallel processing to your data extraction and transformation applications. This chapter gives a basic introduction to parallel processing, and describes some of the key concepts in designing parallel jobs for WebSphere DataStage. If you are new to WebSphere DataStage, you should read the introductory chapters of the WebSphere DataStage Designer Client Guide first so that you are familiar with the WebSphere DataStage Designer client interface and the way jobs are built from stages and links.

    Parallel processing There are two basic types of parallel processing; pipeline and partitioning. WebSphere DataStage allows you to use both of these methods. The following sections illustrate these methods using a simple parallel job which extracts data from a data source, transforms it in some way, then writes it to another data source. In all cases this job would appear the same on your Designer canvas, but you can configure it to behave in different ways (which are shown diagrammatically).

    Pipeline parallelism If you ran the example job on a system with at least three processors, the stage reading would start on one processor and start filling a pipeline with the data it had read. The transformer stage would start running on another processor as soon as there was data in the pipeline, process it and start filling another pipeline. The stage writing the transformed data to the target database would similarly start writing as soon as there was data available. Thus all three stages are operating simultaneously. If you were running sequentially, there would only be one instance of each stage. If you were running in parallel, there would be as many instances as you had partitions (see next section).

    Copyright IBM Corp. 2006 3

  • time taken

    time taken

    conceptual representation of job running with no parallelism

    conceptual representation of same job using pipeline parallelism

    Partition parallelism Imagine you have the same simple job as described above, but that it is handling very large quantities of data. In this scenario you could use the power of parallel processing to your best advantage by partitioning the data into a number of separate sets, with each partition being handled by a separate instance of the job stages.

    Using partition parallelism the same job would effectively be run simultaneously by several processors, each handling a separate subset of the total data.

    At the end of the job the data partitions can be collected back together again and written to a single data source.

    4 Parallel Job Developer Guide

  • Conceptual representation of job using partition parallelism

    Combining pipeline and partition parallelism In practice you will be combining pipeline and partition parallel processing to achieve even greater performance gains. In this scenario you would have stages processing partitioned data and filling pipelines so the next one could start on that partition before the previous one had finished.

    Conceptual representation of job using pipeline and partition parallelism

    Repartitioning data In some circumstances you may want to actually repartition your data between stages. This might happen, for example, where you want to group data differently. Say you have initially processed data based on customer last name, but now want to process on data grouped by zip code. You will need to repartition to ensure that all customers sharing the same zip code are in the same group. WebSphere

    Chapter 2. Designing parallel jobs 5

  • DataStage allows you to repartition between stages as and when needed (although note there are performance implications if you do this and you may affect the balance of your partitions see Parallel Job Advanced Developer Guide).

    Conceptual representation of data repartitioning

    Further details about how WebSphere DataStage actually partitions data, and collects it together again, is given in Partitioning, Repartitioning, and Collecting Data.

    Parallel processing environments The environment in which you run your parallel jobs is defined by your systems architecture and hardware resources. All parallel processing environments are categorized as one of: v SMP (symmetric multiprocessing), in which some hardware resources may be shared among processors. The processors communicate via shared memory and have a single operating system.

    v Cluster or MPP (massively parallel processing), also known as shared-nothing, in which each processor has exclusive access to hardware resources. MPP systems are physically housed in the same box, whereas cluster systems can be physically dispersed. The processors each have their own operating system, and communicate via a high-speed network.

    SMP systems allow you to scale up the number of processors, which may improve performance of your jobs. The improvement gained depends on how your job is limited: v CPU-limited jobs. In these jobs the memory, memory bus, and disk I/O spend a disproportionate amount of time waiting for the processor to finish its work. Running a CPU-limited application on more processors can shorten this waiting time so speed up overall performance.

    6 Parallel Job Developer Guide

  • v Memory-limited jobs. In these jobs CPU and disk I/O wait for the memory or the memory bus. SMP systems share memory resources, so it may be harder to improve performance on SMP systems without hardware upgrade.

    v Disk I/O limited jobs. In these jobs CPU, memory and memory bus wait for disk I/O operations to complete. Some SMP systems allow scalability of disk I/O, so that throughput improves as the number of processors increases. A number of factors contribute to the I/O scalability of an SMP, including the number of disk spindles, the presence or absence of RAID, and the number of I/O controllers.

    In a cluster or MPP environment, you can use the multiple processors and their associated memory and disk resources in concert to tackle a single job. In this environment, each processor has its own dedicated memory, memory bus, disk, and disk access. In a shared-nothing environment, parallelization of your job is likely to improve the performance of CPU-limited, memory-limited, or disk I/O-limited applications.

    The configuration file One of the great strengths of the WebSphere DataStage Enterprise Edition is that, when designing jobs, you dont have to worry too much about the underlying structure of your system, beyond appreciating its parallel processing capabilities. If your system changes, is upgraded or improved, or if you develop a job on one platform and implement it on another, you dont necessarily have to change your job design.

    WebSphere DataStage learns about the shape and size of the system from the configuration file. It organizes the resources needed for a job according to what is defined in the configuration file. When your system changes, you change the file not the jobs.

    The configuration file describes available processing power in terms of processing nodes. These may, or may not, correspond to the actual number of processors in your system. You may, for example, want to always leave a couple of processors free to deal with other activities on your system. The number of nodes you define in the configuration file determines how many instances of a process will be produced when you compile a parallel job.

    Every MPP, cluster, or SMP environment has characteristics that define the system overall as well as the individual processors. These characteristics include node names, disk storage locations, and other distinguishing attributes. For example, certain processors might have a direct connection to a mainframe for performing high-speed data transfers, while others have access to a tape drive, and still others are dedicated to running an RDBMS application. You can use the configuration file to set up node pools and resource pools. A pool defines a group of related nodes or resources, and when you design a parallel job you can specify that execution be confined to a particular pool.

    The configuration file describes every processing node that WebSphere DataStage will use to run your application. When you run a parallel job, WebSphere DataStage first reads the configuration file to determine the available system resources.

    When you modify your system by adding or removing processing nodes or by reconfiguring nodes, you do not need to alter or even recompile your parallel job. Just edit the configuration file.

    The configuration file also gives you control over parallelization of your job during the development cycle. For example, by editing the configuration file, you can first run your job on a single processing node, then on two nodes, then four, then eight, and so on. The configuration file lets you measure system performance and scalability without actually modifying your job.

    You can define and edit the configuration file using the Designer client.

    Chapter 2. Designing parallel jobs 7

  • Partitioning, repartitioning, and collecting data We have already described how you can use partitioning of data to implement parallel processing in your job . This section takes a closer look at how you can partition data in your jobs, and collect it together again.

    Partitioning In the simplest scenario you probably wont be bothered how your data is partitioned. It is enough that it is partitioned and that the job runs faster. In these circumstances you can safely delegate responsibility for partitioning to WebSphere DataStage. Once you have identified where you want to partition data, WebSphere DataStage will work out the best method for doing it and implement it.

    The aim of most partitioning operations is to end up with a set of partitions that are as near equal size as possible, ensuring an even load across your processors.

    When performing some operations however, you will need to take control of partitioning to ensure that you get consistent results. A good example of this would be where you are using an aggregator stage to summarize your data. To get the answers you want (and need) you must ensure that related data is grouped together in the same partition before the summary operation is performed on that partition. WebSphere DataStage lets you do this.

    There are a number of different partitioning methods available, note that all these descriptions assume you are starting with sequential data. If you are repartitioning already partitioned data then there are some specific considerations:

    Round robin partitioner

    The first record goes to the first processing node, the second to the second processing node, and so on. When WebSphere DataStage reaches the last processing node in the system, it starts over. This method is useful for resizing partitions of an input data set that are not equal in size. The round robin method always creates approximately equal-sized partitions. This method is the one normally used when WebSphere DataStage initially partitions data.

    8 Parallel Job Developer Guide

  • 12

    4

    5

    6

    78

    9

    1011

    12

    13

    14

    15

    16

    3

    Node 1

    Node 2

    Node 3

    Node 4

    Round RobinPartioner

    1

    5

    9

    13

    2

    6

    10

    14

    3

    711

    15

    4

    812

    16

    Input data

    Random partitioner

    Records are randomly distributed across all processing nodes. Like round robin, random partitioning can rebalance the partitions of an input data set to guarantee that each processing node receives an approximately equal-sized partition. The random partitioning has a slightly higher overhead than round robin because of the extra processing required to calculate a random value for each record.

    Chapter 2. Designing parallel jobs 9

  • 12

    4

    5

    6

    78

    9

    1011

    12

    13

    14

    15

    16

    3

    Node 1

    Node 2

    Node 3

    Node 4

    RandomPartioner

    2

    5

    15

    14

    9

    6

    10

    13

    1

    711

    3

    84

    4

    16

    Input data

    Same partitioner

    The stage using the data set as input performs no repartitioning and takes as input the partitions output by the preceding stage. With this partitioning method, records stay on the same processing node; that is, they are not redistributed. Same is the fastest partitioning method. This is normally the method WebSphere DataStage uses when passing data between stages in your job.

    10 Parallel Job Developer Guide

  • Node 1

    Node 2

    Node 3

    Node 4

    1

    5

    9

    13

    2

    6

    10

    14

    3

    711

    15

    4

    812

    16

    Node 1

    Node 2

    Node 3

    Node 4

    1

    5

    9

    13

    2

    6

    10

    14

    3

    711

    15

    4

    812

    16

    SamePartioner

    Entire partitioner

    Every instance of a stage on every processing node receives the complete data set as input. It is useful when you want the benefits of parallel execution, but every instance of the operator needs access to the entire input data set. You are most likely to use this partitioning method with stages that create lookup tables from their input.

    Chapter 2. Designing parallel jobs 11

  • Node 1

    Node 2

    Node 3

    Node 4

    EntirePartioner

    Input data

    1

    2

    4

    5

    3

    1

    2

    4

    5

    3

    1

    2

    4

    5

    3

    1

    2

    4

    5

    3

    1

    2

    4

    5

    3

    Hash partitioner

    Partitioning is based on a function of one or more columns (the hash partitioning keys) in each record. The hash partitioner examines one or more fields of each input record (the hash key fields). Records with the same values for all hash key fields are assigned to the same processing node.

    This method is useful for ensuring that related records are in the same partition, which may be a prerequisite for a processing operation. For example, for a remove duplicates operation, you can hash partition records so that records with the same partitioning key values are on the same node. You can then sort the records on each node using the hash key fields as sorting key fields, then remove

    12 Parallel Job Developer Guide

  • duplicates, again using the same keys. Although the data is distributed across partitions, the hash partitioner ensures that records with identical keys are in the same partition, allowing duplicates to be found.

    Hash partitioning does not necessarily result in an even distribution of data between partitions. For example, if you hash partition a data set based on a zip code field, where a large percentage of your records are from one or two zip codes, you can end up with a few partitions containing most of your records. This behavior can lead to bottlenecks because some nodes are required to process more records than other nodes.

    For example, the diagram shows the possible results of hash partitioning a data set using the field age as the partitioning key. Each record with a given age is assigned to the same partition, so for example records with age 36, 40, or 22 are assigned to partition 0. The height of each bar represents the number of records in the partition.

    Partition number

    Age values

    Partition size(in records)

    0 1 2 3 N

    36 40 22

    12 18 27

    35 5 60

    15 44 39

    10 54 17

    As you can see, the key values are randomly distributed among the different partitions. The partition sizes resulting from a hash partitioner are dependent on the distribution of records in the data set so even though there are three keys per partition, the number of records per partition varies widely, because the distribution of ages in the population is non-uniform.

    When hash partitioning, you should select hashing keys that create a large number of partitions. For example, hashing by the first two digits of a zip code produces a maximum of 100 partitions. This is not a large number for a parallel processing system. Instead, you could hash by five digits of the zip code to create up to 10,000 partitions. You also could combine a zip code hash with an age hash (assuming a maximum age of 190), to yield 1,500,000 possible partitions.

    Chapter 2. Designing parallel jobs 13

  • Fields that can only assume two values, such as yes/no, true/false, male/female, are particularly poor choices as hash keys.

    You must define a single primary partitioning key for the hash partitioner, and you may define as many secondary keys as are required by your job. Note, however, that each column 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 columns in the row.

    You specify which columns are to act as hash keys on the Partitioning tab of the stage editor The data type of a partitioning key may be any data type except raw, subrecord, tagged aggregate, or vector. By default, the hash partitioner does case-sensitive comparison. This means that uppercase strings appear before lowercase strings in a partitioned data set. You can override this default if you want to perform case insensitive partitioning on string fields.

    Modulus partitioner

    Partitioning is based on a key column modulo the number of partitions. This method is similar to hash by field, but involves simpler computation.

    In data mining, data is often arranged in buckets, that is, each record has a tag containing its bucket number. You can use the modulus partitioner to partition the records according to this number. The modulus partitioner assigns each record of an input data set to a partition of its output data set as determined by a specified key field in the input data set. This field can be the tag field.

    The partition number of each record is calculated as follows: partition_number = fieldname mod number_of_partitions

    where: v fieldname is a numeric field of the input data set. v number_of_partitions is the number of processing nodes on which the partitioner executes. If a partitioner is executed on three processing nodes it has three partitions.

    In this example, the modulus partitioner partitions a data set containing ten records. Four processing nodes run the partitioner, and the modulus partitioner divides the data among four partitions. The input data is as follows:

    Column name SQL type

    bucket Integer

    date Date

    The bucket is specified as the key field, on which the modulus operation is calculated.

    Here is the input data set. Each line represents a row:

    bucket date

    64123 1960-03-30

    61821 1960-06-27

    44919 1961-06-18

    22677 1960-09-24

    90746 1961-09-15

    21870 1960-01-01

    87702 1960-12-22

    14 Parallel Job Developer Guide

  • bucket date

    4705 1961-12-13

    47330 1961-03-21

    88193 1962-03-12

    The following table shows the output data set divided among four partitions by the modulus partitioner.

    Partition 0 Partition 1 Partition 2 Partition 3

    61821 1960-06-27 21870 1960-01-01 64123 1960-03-30

    22677 1960-09-24 87702 1960-12-22 44919 1961-06-18

    47051961-12-13 47330 1961-03-21

    88193 1962-03-12 90746 1961-09-15

    Here are three sample modulus operations corresponding to the values of three of the key fields: v 22677 mod 4 = 1; the data is written to Partition 1. v 47330 mod 4 = 2; the data is written to Partition 2. v 64123 mod 4 = 3; the data is written to Partition 3.

    None of the key fields can be divided evenly by 4, so no data is written to Partition 0.

    Range partitioner Divides a data set into approximately equal-sized partitions, each of which contains records with key columns within a specified range. This method is also useful for ensuring that related records are in the same partition.

    A range partitioner divides a data set into approximately equal size partitions based on one or more partitioning keys. Range partitioning is often a preprocessing step to performing a total sort on a data set.

    In order to use a range partitioner, you have to make a range map. You can do this using the Write Range Map stage, which is described in Chapter 55.

    The range partitioner guarantees that all records with the same partitioning key values are assigned to the same partition and that the partitions are approximately equal in size so all nodes perform an equal amount of work when processing the data set.

    An example of the results of a range partition is shown below. The partitioning is based on the age key, and the age range for each partition is indicated by the numbers in each bar. The height of the bar shows the size of the partition.

    Chapter 2. Designing parallel jobs 15

  • Age values

    Partition

    Partition size(in records) 0-2 3-17 18-25

    26-4466-71

    All partitions are of approximately the same size. In an ideal distribution, every partition would be exactly the same size.

    However, you typically observe small differences in partition size. In order to size the partitions, the range partitioner uses a range map to calculate partition boundaries. As shown above, the distribution of partitioning keys is often not even; that is, some partitions contain many partitioning keys, and others contain relatively few. However, based on the calculated partition boundaries, the number of records in each partition is approximately the same.

    Range partitioning is not the only partitioning method that guarantees equivalent-sized partitions. The random and round robin partitioning methods also guarantee that the partitions of a data set are equivalent in size. However, these partitioning methods are keyless; that is, they do not allow you to control how records of a data set are grouped together within a partition.

    In order to perform range partitioning your job requires a write range map stage to calculate the range partition boundaries in addition to the stage that actually uses the range partitioner. The write range map stage uses a probabilistic splitting technique to range partition a data set. This technique is described in Parallel Sorting on a Shared- Nothing Architecture Using Probabilistic Splitting by DeWitt, Naughton, and Schneider in Query Processing in Parallel Relational Database Systems by Lu, Ooi, and Tan, IEEE Computer Society Press, 1994. In order for the stage to determine the partition boundaries, you pass it a sorted sample of the data set to be range partitioned. From this sample, the stage can determine the appropriate partition boundaries for the entire data set.

    When you come to actually partition your data, you specify the range map to be used by clicking on the property icon, next to the Partition type field, the Partitioning/Collection properties dialog box appears and allows you to specify a range map.

    DB2 partitioner

    Partitions an input data set in the same way that DB2 would partition it. For example, if you use this method to partition an input data set containing update information for an existing DB2 table, records are assigned to the processing node containing the corresponding DB2 record. Then, during the execution of the parallel operator, both the input record and the DB2 table record are local to the processing node. Any reads and writes of the DB2 table would entail no network activity.

    See theDB2 Parallel Edition for AIX, Administration Guide and Reference for more information on DB2 partitioning.

    16 Parallel Job Developer Guide

  • To use DB2 partitioning on a stage, select a Partition type of DB2 on the Partitioning tab, then click the Properties button to the right. In the Partitioning/Collection properties dialog box, specify the details of the DB2 table whose partitioning you want to replicate ).

    Auto partitioner

    The most common method you will see on the WebSphere DataStage stages is Auto. This just means that you are leaving it to WebSphere DataStage to determine the best partitioning method to use depending on the type of stage, and what the previous stage in the job has done. Typically WebSphere DataStage would use round robin when initially partitioning data, and same for the intermediate stages of a job.

    Collecting Collecting is the process of joining the multiple partitions of a single data set back together again into a single partition. There are various situations where you may want to do this. There may be a stage in your job that you want to run sequentially rather than in parallel, in which case you will need to collect all your partitioned data at this stage to make sure it is operating on the whole data set.

    Similarly, at the end of a job, you might want to write all your data to a single database, in which case you need to collect it before you write it.

    There might be other cases where you do not want to collect the data at all. For example, you may want to write each partition to a separate flat file.

    Just as for partitioning, in many situations you can leave DataStage to work out the best collecting method to use. There are situations, however, where you will want to explicitly specify the collection method.

    Note that collecting methods are mostly non-deterministic. That is, if you run the same job twice with the same data, you are unlikely to get data collected in the same order each time. If order matters, you need to use the sorted merge collection method.

    Round robin collector

    Reads a record from the first input partition, then from the second partition, and so on. After reaching the last partition, starts over. After reaching the final record in any partition, skips that partition in the remaining rounds.

    Chapter 2. Designing parallel jobs 17

  • 12

    4

    5

    6

    78

    9

    1011

    12

    13

    14

    15

    16

    3

    Node 1

    Node 2

    Node 3

    Node 4

    Round RobinCollector

    1

    5

    9

    132

    6

    10

    143

    711

    154

    812

    16

    Input data

    Ordered collector

    Reads all records from the first partition, then all records from the second partition, and so on. This collection method preserves the order of totally sorted input data sets. In a totally sorted data set, both the records in each partition and the partitions themselves are ordered. This may be useful as a preprocessing action before exporting a sorted data set to a single data file.

    18 Parallel Job Developer Guide

  • 12

    4

    5

    6

    78

    9

    1011

    12

    13

    14

    15

    16

    3

    Node 1

    Node 2

    Node 3

    Node 4

    OrderedCollector

    Input data

    1

    2

    4

    5

    6

    78

    9

    1011

    12

    13

    14

    15

    16

    3

    Sorted merge collector Read records in an order based on one or more columns of the record. The columns used to define record order are called collecting keys. Typically, you use the sorted merge collector with a partition-sorted data set (as created by a sort stage). In this case, you specify as the collecting key fields those fields you specified as sorting key fields to the sort stage. For example, the figure below shows the current record in each of three partitions of an input data set to the collector:

    Chapter 2. Designing parallel jobs 19

  • Paul Smith 34 Mary Davis 4242SmithJane

    Partition 0 Partition 1 Partition 2

    Current record

    In this example, the records consist of three fields. The first-name and last-name fields are strings, and the age field is an integer. The following figure shows the order of the three records read by the sort merge collector, based on different combinations of collecting keys.

    34

    Jane Smith 42

    SmithPaul

    Mary Davis 42

    order read:

    1

    2

    3

    34

    Jane Smith 42

    SmithPaul

    Mary Davis 42

    order read:

    1

    2

    3

    34

    Jane Smith 42

    SmithPaul

    Mary Davis 42

    order read:

    1

    2

    3

    primary collecting key

    secondary collecting key

    primary collecting key

    secondary collecting key

    20 Parallel Job Developer Guide

  • You must define a single primary collecting key for the sort merge collector, and you may define as many secondary keys as are required by your job. Note, however, that each column can be used only once as a collecting key. Therefore, the total number of primary and secondary collecting keys must be less than or equal to the total number of columns in the row. You define the keys on the Partitioning tab, and the key you define first is the primary key.

    The data type of a collecting key can be any type except raw, subrec, tagged, or vector.

    By default, the sort merge collector uses ascending sort order and case-sensitive comparisons. Ascending order means that records with smaller values for a collecting field are processed before records with larger values. You also can specify descending sorting order, so records with larger values are processed first.

    With a case-sensitive algorithm, records with uppercase strings are processed before records with lowercase strings. You can override this default to perform case-insensitive comparisons of string fields.

    Auto collector

    The most common method you will see on the parallel stages is Auto. This normally means that WebSphere DataStage will eagerly read any row from any input partition as it becomes available, but if it detects that, for example, the data needs sorting as it is collected, it will do that. This is the fastest collecting method.

    Repartitioning data If you decide you need to repartition data within your parallel job there are some particular considerations as repartitioning can affect the balance of data partitions.

    For example, if you start with four perfectly balanced partitions and then subsequently repartition into three partitions, you will lose the perfect balance and be left with, at best, near perfect balance. This is true even for the round robin method; this only produces perfectly balanced partitions from a sequential data source. The reason for this is illustrated below. Each node partitions as if it were a single processor with a single data set, and will always start writing to the first target partition. In the case of four partitions repartitioning to three, more rows are written to the first target partition. With a very small data set the effect is pronounced; with a large data set the partitions tend to be more balanced.

    Chapter 2. Designing parallel jobs 21

  • Data repartitioned from fourpartitions to three partitions

    The mechanics of partitioning and collecting This section gives a quick guide to how partitioning and collecting is represented in a parallel job.

    Partitioning icons Each parallel stage in a job can partition or repartition incoming data before it operates on it. Equally it can just accept the partitions that the data comes in. There is an icon on the input link to a stage which shows how the stage handles partitioning.

    22 Parallel Job Developer Guide

  • In most cases, if you just lay down a series of parallel stages in a DataStage job and join them together, the auto method will determine partitioning. This is shown on the canvas by the auto partitioning icon:

    In some cases, stages have a specific partitioning method associated with them that cannot be overridden. It always uses this method to organize incoming data before it processes it. In this case an icon on the input link tells you that the stage is repartitioning data:

    If you have a data link from a stage running sequentially to one running in parallel the following icon is shown to indicate that the data is being partitioned:

    You can specify that you want to accept the existing data partitions by choosing a partitioning method of same. This is shown by the following icon on the input link:

    Partitioning methods are set on the Partitioning tab of the Inputs pages on a stage editor.

    Preserve partitioning flag A stage can also request that the next stage in the job preserves whatever partitioning it has implemented. It does this by setting the preserve partitioning flag for its output link. Note, however, that the next stage may ignore this request.

    In most cases you are best leaving the preserve partitioning flag in its default state. The exception to this is where preserving existing partitioning is important. The flag will not prevent repartitioning, but it will warn you that it has happened when you run the job. If the Preserve Partitioning flag is cleared, this means that the current stage doesnt care what the next stage in the job does about partitioning. On some

    Chapter 2. Designing parallel jobs 23

  • stages, the Preserve Partitioning flag can be set to Propagate. In this case the stage sets the flag on its output link according to what the previous stage in the job has set. If the previous job is also set to Propagate, the setting from the stage before is used and so on until a Set or Clear flag is encountered earlier in the job. If the stage has multiple inputs and has a flag set to Propagate, its Preserve Partitioning flag is set if it is set on any of the inputs, or cleared if all the inputs are clear.

    Collector icon

    A stage in the job which is set to run sequentially will need to collect partitioned data before it operates on it. There is an icon on the input link to a stage which shows that it is collecting data:

    Sorting data You will probably have requirements in your parallel jobs to sort data. WebSphere DataStage has a sort stage, which allows you to perform complex sorting operations. There are situations, however, where you require a fairly simple sort as a precursor to a processing operation. For these purposes, WebSphere DataStage allows you to insert a sort operation in most stage types for incoming data. You do this by selecting the Sorting option on the Input page Partitioning tab . When you do this you can specify: v Sorting keys. The field(s) on which data is sorted. You must specify a primary key, but you can also specify any number of secondary keys. The first key you define is taken as the primary.

    v Stable sort (this is the default and specifies that previously sorted data sets are preserved). v Unique sort (discards records if multiple records have identical sorting key values). v Case sensitivity. v Sort direction. Sorted as EBCDIC (ASCII is the default).

    If you have NLS enabled, you can also specify the collate convention used.

    Some WebSphere DataStage operations require that the data they process is sorted (for example, the Merge operation). If WebSphere DataStage detects that the input data set is not sorted in such a case, it will automatically insert a sort operation in order to enable the processing to take place unless you have explicitly specified otherwise.

    Data sets Inside a WebSphere DataStage parallel job, data is moved around in data sets. These carry meta data with them, both column definitions and information about the configuration that was in effect when the data set was created. If for example, you have a stage which limits execution to a subset of available nodes, and the data set was created by a stage using all nodes, WebSphere DataStage can detect that the data will need repartitioning.

    If required, data sets can be landed as persistent data sets, represented by a Data Set stage (see Chapter 4, Data set stage, on page 67, Data Set Stage.) This is the most efficient way of moving data between linked jobs. Persistent data sets are stored in a series of files linked by a control file (note that you should not attempt to manipulate these files using UNIX tools such as RM or MV. Always use the tools provided with WebSphere DataStage).

    24 Parallel Job Developer Guide

  • Note: The example screenshots in the individual stage descriptions often show the stage connected to a Data Set stage. This does not mean that these kinds of stage can only be connected to Data Set stages.

    Metadata Metadata is information about data. It describes the data flowing through your job in terms of column definitions, which describe each of the fields making up a data record.

    WebSphere DataStage has two alternative ways of handling metadata, through table definitions, or through Schema files. By default, parallel stages derive their meta data from the columns defined on the Outputs or Input page Column tab of your stage editor. Additional formatting information is supplied, where needed, by a Formats tab on the Outputs or Input page. In some cases you can specify that the stage uses a schema file instead by explicitly setting a property on the stage editor and specify the name and location of the schema file. Note that, if you use a schema file, you should ensure that runtime column propagation is turned on. Otherwise the column definitions specified in the stage editor will always override any schema file.

    Where is additional formatting information needed? Typically this is where you are reading from, or writing to, a file of some sort and WebSphere DataStage needs to know more about how data in the file is formatted.

    You can specify formatting information on a row basis, where the information is applied to every column in every row in the dataset. This is done from the Formats tab (the Formats tab is described with the stage editors that support it; for example, for Sequential files, see page Input Link Format Tab). You can also specify formatting for particular columns (which overrides the row formatting) from the Edit Column Metadata dialog box for each column (see page Field Level).

    Runtime column propagation WebSphere DataStage is also flexible about meta data. It can cope with the situation where meta data isnt fully defined. You can define part of your schema and specify that, if your job encounters extra columns that are not defined in the meta data when it actually runs, it will adopt these extra columns and propagate them through the rest of the job. This is known as runtime column propagation (RCP). This can be enabled for a project via the WebSphere DataStage Administrator (see WebSphere DataStage Administrator Client Guide), and set for individual links via the Output Page Columns tab (see Columns Tab on page Columns Tab) for most stages, or in the Output page General tab for Transformer stages (see Output Page ). You should always ensure that runtime column propagation is turned on if you want to use schema files to define column meta data.

    Table definitions A table definition is a set of related columns definitions that are stored in the Repository. These can be loaded into stages as and when required.

    You can import a table definition from a data source via the Designer. You can also edit and define new table definitions in the Designer (see WebSphere DataStage Designer Client Guide). If you want, you can edit individual column definitions once you have loaded them into your stage.

    You can also simply type in your own column definition from scratch on the Outputs or Input page Column tab of your stage editor. When you have entered a set of column definitions you can save them as a new table definition in the Repository for subsequent reuse in another job.

    Chapter 2. Designing parallel jobs 25

  • Schema files and partial schemas You can also specify the meta data for a stage in a plain text file known as a schema file. This is not stored in the Repository but you could, for example, keep it in a document management or source code control system, or publish it on an intranet site.

    The form