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'
Filter stage - documentation error?
Moderators: chulett, rschirm, roy
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.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Ok, that makes sense. Thank you.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.)
*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.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
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.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.