Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
ffanali0804
Contributor
Contributor

how to generate row_number in tmap

hello,

Is there a solution to use this row_number in a tMap?

SELECT AccountID,

UserTagID,

Status,

LogDate,

"row_number"() OVER (PARTITION BY UserTagID, AccountID, LogDate ORDER BY LogDate DESC) rn

FROM log_user_tag

Thank you so much,

Federico

Labels (2)
5 Replies
Anonymous
Not applicable

You can certainly add row numbers in the tMap, but if you are trying to replicate this query, why don't you just use this query in your DB component?

Anonymous
Not applicable

Take a look at sequence of the Numeric routine: https://help.talend.com/r/en-US/8.0/studio-user-guide/numeric-routines

We can do a partition like this:

Numeric.sequence( row1.UserTagID+"__"+row1. AccountID+"__"+row1.LogDate , 1, 1)

 

ORDER BY I'm afraid is only possible if you add a tSortRow to your flow.

ffanali0804
Contributor
Contributor
Author

I had actually tried this solution but I had doubts about the performance, so I wanted to compare it with the one with the tmap. If you confirm that they are similar then I would use the one you are proposing directly 🙂

thanks

Anonymous
Not applicable

You will NEVER outperform a DB manipulating data like this, with any other application that has to receive the data, then sort it. This is what databases are for. If you have all of your data in a single DB, you may as well carry out any sorting or calculations that can be carried out in the DB, in the DB. Then send it to other applications to be further processed.

Anonymous
Not applicable

Databases are made to run queries super fast. We're trying to maninpulate data that is not in the right order, etc. It can't be that efficient.