How to generate sequences in View logic in Dremio

66 Views Asked by At

I need to create a view in with total 5 columns. Two columns are from source 1 and other 2 columns are from source 2 and 1 column is sequence number. This SQL code is in Dremio tool (data lake house) where I can have live connections to source systems (direct connection to source systems).This sequence number is assigned to each record to serve as a unique identifier for the record. The view at logical space is pulling values for 4 columns (mentioned above) through live connections to 2 different source systems (source 1 and source 2 as mentioned above) Can you please help if there is a way to generate sequence number and assig to each record (a record consists of above 4 fields , 2 from each source). Another challenge is , each time I select the record from view , the sequence number assigned to each record should not change. I mean if the sequence number for record 1 with account name ABC was 101 then if I query the same record at any time later , the sequence number should be 101 only for that record at later time as well.

1

There are 1 best solutions below

0
Alex Merced On

Not sure if this is currently possible in the way of you want without leverage some other column to generate consistent id since it's a function of the record itself.

If the two of columns have values that should never repeat on another record you can derive a column from that.

For example, if there customer_id and timestamp, you can convert the timestamp into a UTC number then add that to the customer id to generate an indentifier that will be consistent and unique on the view.

SELECT customer_id + UNIX_TIMESTAMP(timestamp) as ID, ...