Fixed value in a lookup

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Fixed value in a lookup

Post by PhilHibbs »

Is there any way of doing a lookup with a fixed value? I have a data set of price information, and I want to look up the "Buy" price and then the "Sell" price, but I can't specify "Buy" in one lookup link and "Sell" in another.

Would the "right" way to handle this be to split the look up data stream into two Lookup stages with filter conditions controlling which type of price goes into which Lookup stage?
Phil Hibbs | Capgemini
Technical Consultant
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

I'm not sure what you're saying. Surely you're using something like "item number" as the lookup key, so one lookup could return buy price and another lookup could return sell price from the same source data? Of course, two copies of the reference data will be needed in memory as soon as you have two lookups. But each only needs two columns - one has item number and buy price, the other has item number and sell price.

Is this a sparse lookup, perchance?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

Look up data looks like this:

Code: Select all

Date        Time     Type   Price
2010-10-01  00:00    Buy    1.00
2010-10-01  00:00    Sell   1.10
2010-10-01  01:00    Buy    2.00
2010-10-01  01:00    Sell   2.20
2010-10-01  02:00    Buy    3.00
2010-10-01  02:00    Sell   3.30
Stream data has Date, Time, and I want to get the Buy price and Sell price for that hour. So I want to do one look up on Date, Time, "Buy" and one look up on Date, Time, "Sell". I've done it by splitting my look up data into two streams, one for "Buy" and one for "Sell", with each stream going to a different Lookup Stage.
Phil Hibbs | Capgemini
Technical Consultant
nitkuar
Participant
Posts: 46
Joined: Mon Jun 23, 2008 3:09 am

Post by nitkuar »

You can also use only one Lookup stage with two reference links, having BUY data in one link and SELL in another.
PhilHibbs
Premium Member
Premium Member
Posts: 1044
Joined: Wed Sep 29, 2004 3:30 am
Location: Nottingham, UK
Contact:

Post by PhilHibbs »

nitkuar wrote:You can also use only one Lookup stage with two reference links, having BUY data in one link and SELL in another.
I did that early on, but now I always put each lookup in a separate stage, so I can separate out the reject links and get clearer error messages.
Phil Hibbs | Capgemini
Technical Consultant
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Hi Phil,
They are different records. You cannot do it in single lookup stage.

You need to group by based on hour and use two lookup stages and a transformer.

Regards
Sreeni
nitkuar
Participant
Posts: 46
Joined: Mon Jun 23, 2008 3:09 am

Post by nitkuar »

PhilHibbs wrote:I did that early on, but now I always put each lookup in a separate stage, so I can separate out the reject links and get clearer error messages.
that seems logical as well :)
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Can't you include that Type column as a key for the lookup and then hardcode either the 'Buy' or 'Sell' value in the field used for the lookup itself? :?
-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 »

Exactly. You can generate these constants in an upstream Column Generator or Transformer stage.
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