provide logic to find rank
Moderators: chulett, rschirm, roy
provide logic to find rank
Hi
woul you please provide logic to find rank on scr column by using transformer stage
This is my in put data
cid name scr
101 xxx 95
102 yyy 80
103 vvv 91
104 ddd 40
105 sss 92
106 eee 50
require o/p
cid name scr rank
101 xxx 95 1
102 yyy 80 4
103 vvv 91 3
104 ddd 40 6
105 sss 92 2
106 eee 50 5
woul you please provide logic to find rank on scr column by using transformer stage
This is my in put data
cid name scr
101 xxx 95
102 yyy 80
103 vvv 91
104 ddd 40
105 sss 92
106 eee 50
require o/p
cid name scr rank
101 xxx 95 1
102 yyy 80 4
103 vvv 91 3
104 ddd 40 6
105 sss 92 2
106 eee 50 5
Venkat Sandu
vsandu.cg@gmail.com
vsandu.cg@gmail.com
If the source is oracle you can user analytical functions directly in the query and if it is file you can follow the below steps
1)sort the data using sort stage on scr column (desc ) in sequential mode
2)In transformer use same partition and also counter=counter+1 intialized to 0
and also it won not assign same rank if scr column contains duplicates
1)sort the data using sort stage on scr column (desc ) in sequential mode
2)In transformer use same partition and also counter=counter+1 intialized to 0
and also it won not assign same rank if scr column contains duplicates
-
- Premium Member
- Posts: 730
- Joined: Tue Nov 04, 2008 10:14 am
- Location: Bangalore
Please correct me if i am wrong and i am a beginner for Datastage
1)since sort stage we are running in sequential mode(single node) and if we use same partition(without doing any repartition) in transformer then the transformer will run in sequential mode(single node) irrespective of number of nodes in configuraton file.
1)since sort stage we are running in sequential mode(single node) and if we use same partition(without doing any repartition) in transformer then the transformer will run in sequential mode(single node) irrespective of number of nodes in configuraton file.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Not true. You have to change the Transformer stage properties explicitly to have it run in sequential mode (another way is to force the entire job to run in sequential mode, or to use a one-node configuration file).
Rank is not really an ETL function - it's a display function. That said, it can be done with stage variables, though you have to maintain two counts to handle the situation that you have tied ranks.
Rank is not really an ETL function - it's a display function. That said, it can be done with stage variables, though you have to maintain two counts to handle the situation that you have tied ranks.
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.
1)Please let me know What is the problem if we use with same partition in transformer?
2)Suppose if are using same partition in transformer what data will contain in node1,node2,node 3 etc? beacause according to my understanding only node 0 will contain the data if we use same partition in transformer
of course i got your point that Transformer stage properties explicitly should be changed to run in sequential mode to get the correct output
2)Suppose if are using same partition in transformer what data will contain in node1,node2,node 3 etc? beacause according to my understanding only node 0 will contain the data if we use same partition in transformer
of course i got your point that Transformer stage properties explicitly should be changed to run in sequential mode to get the correct output
logic for rank
vamsi.4a6 wrote:If the source is oracle you can user analytical functions directly in the query and if it is file you can follow the below steps
1)sort the data using sort stage on scr column (desc ) in sequential mode
2)In transformer use same partition and also counter=counter+1 intialized to 0
and also it won not assign same rank if scr column contains duplicates
Hi
i am not able to understand will u please elobarate please
what is counter= counter + 1
y it is require
Venkat Sandu
vsandu.cg@gmail.com
vsandu.cg@gmail.com
1)In stage variable define counter=counter+1 with intial value 0
and in Transfomer output derivation assign counter--->rank
2)After sorting during processing of first record in transformer counter=0+1 will contain 1
3) For second record counter=1+1[previousley counter value is 1] will contain 2 etc
As ray suggested use transformer in sequential mode instead of same paritition
and in Transfomer output derivation assign counter--->rank
2)After sorting during processing of first record in transformer counter=0+1 will contain 1
3) For second record counter=1+1[previousley counter value is 1] will contain 2 etc
As ray suggested use transformer in sequential mode instead of same paritition
Last edited by vamsi.4a6 on Thu Apr 19, 2012 4:39 am, edited 1 time in total.
Can anybody please clarify the below pointsray.wurlod wrote:Not true. You have to change the Transformer stage properties explicitly to have it run in sequential mode (another way is to force the entire job to run in sequential mode, or to use a one-node conf ...
1)Please let me know What is the problem if we use with same partition in transformer?
2)Suppose if are using same partition in transformer what data will contain in node1,node2,node 3 etc? beacause according to my understanding only node 0 will contain the data if we use same partition in transformer
of course i got your point that Transformer stage properties explicitly should be changed to run in sequential mode to get the correct output
-
- Participant
- Posts: 597
- Joined: Fri Apr 29, 2005 6:19 am
- Location: Singapore
Vamsi,
SAME partition brings the data of 0 partition of the previous stage to 0 partition of current stage. This is used in most of the places where you don't need to reparitition the data flow.
This answers both of your questions.
E.g.
your job design is like dataset to transformer
Assume that 0 partition of dataset has
1,a
2,a
3,a
Then, 0 partition of transfomer will have
1,a
2,a
3,a
SAME partition brings the data of 0 partition of the previous stage to 0 partition of current stage. This is used in most of the places where you don't need to reparitition the data flow.
This answers both of your questions.
E.g.
your job design is like dataset to transformer
Assume that 0 partition of dataset has
1,a
2,a
3,a
Then, 0 partition of transfomer will have
1,a
2,a
3,a
Kandy
_________________
Try and Try again…You will succeed atlast!!
_________________
Try and Try again…You will succeed atlast!!
I got your point
For this post to acheive the output i am following the below two steps
1)sort the data using sort stage on scr column (desc ) in sequential mode
2)In transformer use same partition and also counter=counter+1 intialized to 0
what is the problem with same partition in transformer since i am using sort stage in sequential mode and what data will contain in node1,node2,node 3 etc in transfomer?
For this post to acheive the output i am following the below two steps
1)sort the data using sort stage on scr column (desc ) in sequential mode
2)In transformer use same partition and also counter=counter+1 intialized to 0
what is the problem with same partition in transformer since i am using sort stage in sequential mode and what data will contain in node1,node2,node 3 etc in transfomer?
-
- Premium Member
- Posts: 536
- Joined: Thu Oct 11, 2007 1:48 am
- Location: Bangalore
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
if one of the stage is running in sequential mode and then the downstream operator is running in parallel mode then the data is partitioned. set the transformer to run in sequential mode as keeping it in parallel is not going to add any value anyways.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.
Genius may have its limitations, but stupidity is not thus handicapped.