Skip to main content

Add a randomint to a kafka load stream

  • Jul 5, 2018 2:58 PM UTC
  • 1 reply
  • 13 views

cbonf63

I would like to load with a kafka microbatch (using the KafkaJsonParser ) a table defined as:

create table trans
(
trans_name varchar(20),
trans_seq identity(1,1,1) not null,
trans_part int not null default RANDOMINT(4)
);
The message (in json format) in the kafka topic contains only the trans_name value
ex:
{"trans_name":"TT_000001"}
What I would expect is that trans_seq and trans_part are automatically filled.
This true for trans_seq but not for trans_part, and as trans_part is defined as not null an error is generated (in the case null is allowed no error but value is null)

Is this allowed ? How can I configure load-spec to have this behaviour ?

1 reply

cbonf63
  • Author
  • New Participant
  • Jul 6, 2018 8:23 AM UTC

The solution is to specify --target-columns trans_name in the microbatch