Kettle: filling the field without conflict

I have a data stream with the following structure

user_id (integer)
user_name (string)

user_idis something between 100 and 65536. I want to add a field target_user_id(integer) according to the following logic:

  • If it user_idis in the range 1000..9999, then let the field target_user_idbe equaluser_id
  • If not, fill out target_user_idsomething in the range 1000..9999 without causing a conflict. Preferably the smallest possible.

The length of the stream is less than 9000. The field is user_idunique in the original stream.

+5
source share
1 answer

I'm not sure what you are using for cache use, but the general procedure could be as follows:

  • (, )
  • user_id 1000..9999 user_name = null ( TableOutput)
  • user_id 1000..9999, . ( Update) .
  • user_id 1000..9999:

    • user_id, SQL- (DBLookup)

      SELECT MIN(user_id) FROM temporary_table WHERE user_name IS NULL;
      
    • ( Update)

  • ( TableInput)

,

+3
source

All Articles