Filter stage - documentation error?

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
jgreve
Premium Member
Premium Member
Posts: 107
Joined: Mon Sep 25, 2006 4:25 pm

Filter stage - documentation error?

Post by jgreve »

Here's an example from (parjdev.pdf) Parallel Job Developers Guide.

I'm wondering if the docs are accurate?

Filter Stage 29-5 ( p.682)
-----begin excerpt-----
Evaluating Input Columns
You want to evaluate each input row to see if these conditions prevail:
* EITHER all the following are true
- Column number1 does not have the value 0
- Column number2 does not have the value 3
- Column number3 has the value 0
* OR column name equals the string ZAG
You enter the following in the Where property:
number1 <> 0 and number2 <> 3 and number3 = 0 or name = 'ZAG'
If these conditions are met, the stage writes the row to the output link.
-----end excerpt-----

Is the above example wrong?
I thought you'd have to do this, e.g. parens around the AND-clause:
(number1 <> 0 and number2 <> 3 and number3 = 0) or name = 'ZAG'
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Would depend on operator precedence and associativity... and I don't recall seeing that specifically documented somewhere. I would suspect you are correct. At the very least, adding the parens would remove any doubt as to how it would be evaluated. :wink:
-craig

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

Post by ray.wurlod »

It's correct. Logic is left to right where there are no parentheses. So the two AND operators will have been evaluated before it gets to the OR operator. (Optimized it may not even get to the OR operator if one of the preceding conditions is not true.)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
jgreve
Premium Member
Premium Member
Posts: 107
Joined: Mon Sep 25, 2006 4:25 pm

Post by jgreve »

ray.wurlod wrote:It's correct. Logic is left to right where there are no parentheses. So the two AND operators will have been evaluated before it gets to the OR operator. (Optimized it may not even get to the OR operator if one of the preceding conditions is not true.)
Ok, that makes sense. Thank you.
*sigh* What was I thinking. :?

If DataStage does optimize (short-circuit as in C, Java),
then the (name = "ZAG") check could be safely ignored,
provided everything to that point had yielded TRUE.

Oh well, at some point this will all make sense to me.
John G.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes. If you need that to be tested, apply parentheses and/or change the order.

Code: Select all

(name = "ZAG") or (number1 <> 0 and number2 <> 3 and number3 = 0)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply