scenario
Moderators: chulett, rschirm, roy
Just to make it more clear for me ...
Source Table contains data like this:
TABLE_NAME
---------------
A
A
B
B
B
...
And you want to achieve this:
TABLE_NAME COUNTER
--------------- -----------
A 1
A 2
B 1
B 2
B 3
...
If this is your requirment I would think about some grouping / transformer (stage variables) logic ...
Source Table contains data like this:
TABLE_NAME
---------------
A
A
B
B
B
...
And you want to achieve this:
TABLE_NAME COUNTER
--------------- -----------
A 1
A 2
B 1
B 2
B 3
...
If this is your requirment I would think about some grouping / transformer (stage variables) logic ...
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Hi Sudhana,
You can design a job as below
Source--->Sort--->Transformer--->Target
Sort your i/p data based on the only input column you have.
In the following transformer, you can use the three stage variables in the same order as below.
Map the value of stagevariable 'Counter' to your second column.
This should work.
Do any of you see any problem with this approach???
Regards,
Raja R P
You can design a job as below
Source--->Sort--->Transformer--->Target
Sort your i/p data based on the only input column you have.
In the following transformer, you can use the three stage variables in the same order as below.
1.Column1Changed =>if link.COLUMN1 = PrevColumn1 then 'NC' else 'C'
2.Counter => If Column1Changed='C' Then 1 else Counter+1
3.PrevColumn1 =>link.COLUMN1
Map the value of stagevariable 'Counter' to your second column.
This should work.
Do any of you see any problem with this approach???
Regards,
Raja R P
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
For the input:
i am getting:
Job design is:
Stage variables:
Let me know,if you face any issues.
Thanks
Code: Select all
a
a
a
b
b
c
a
b
d
e
b
d
e
Code: Select all
Peek_6,0: id:a Counter:1
Peek_6,0: id:a Counter:2
Peek_6,0: id:a Counter:3
Peek_6,0: id:a Counter:4
Peek_6,0: id:b Counter:1
Peek_6,0: id:b Counter:2
Peek_6,0: id:b Counter:3
Peek_6,0: id:b Counter:4
Peek_6,0: id:c Counter:1
Peek_6,0: id:d Counter:1
Peek_6,0: id:d Counter:2
Peek_6,0: id:e Counter:1
Peek_6,0: id:e Counter:2
Code: Select all
seq..file-->Sort-->Transformer-->peek
Code: Select all
StageVar: input.id
Counter: if input.id=StageVar1 then Counter+1 else 1
StageVar1: StageVar
Thanks
pandeeswaran
Why using so much stages variables?
You could group the data in the sort stage (by TableName) and then use the created key change column in one stage variable in transformer.
The syntax of <stagevar>: If KeyChange
Then 1
Else <stagevar> +1
That's what I meant with grouping / transformer logic in my post ...
You could group the data in the sort stage (by TableName) and then use the created key change column in one stage variable in transformer.
The syntax of <stagevar>: If KeyChange
Then 1
Else <stagevar> +1
That's what I meant with grouping / transformer logic in my post ...
-
- Participant
- Posts: 1
- Joined: Fri Feb 10, 2012 10:49 am
HendrikB
I didn't think of 'create key change' column and this is less messy as well
Regards,
Raja R P
This should work like charmYou could group the data in the sort stage (by TableName) and then use the created key change column in one stage variable in transformer.
The syntax of <stagevar>: If KeyChange
Then 1
Else <stagevar> +1
I didn't think of 'create key change' column and this is less messy as well
Regards,
Raja R P