Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Wale
Contributor II
Contributor II

Iterative CDC issues with Qlik Sense

Hello all,

I am working on a project where I am trying to switch a bunch of Qliksense QVDs from full nightly reloads to change data capture reloads (CDC), where only new data (identified by a Primary Key) from our base table (in databricks) will be inserted/updated into a QVD where all the data is stored. 

The current QVD stored via QlikSense feeds off of a base DLT (delta live table) table from databricks. However, we now want to implement CDC and not do a FULL reload every night to save money on clusters costs.

Only new data identified by a BOL_UPD_DT field from said base DLT in databricks will be loaded (added/concatenated) to the existent QVD. The BOL_UPD_DT field  is a timestamp that allows me to identify if an existing row has been newly updated or newly inserted).

My goal is to use the BOL_UPD_DT and Primary Key (PK) from said base DLT table to scope out new data that will make it to the QVD. Both base table and QVD have the same named fields. My issue is - How do I carry out the following steps (via data load editor):

1. Select new data (CDC) from base table based on "LastExecTime" and "BeginningThisExecTime" of the QVD reload. 

2. Load the data from the existing QVD.

3. Join the CDC data from the base table (in step 1) with the loaded data from QVD (in step 2) using their Primary Key (PK) and insert new data into the QVD if the data is new or update existing data in the QVD

How does one script this??????

Qlik-sense does a lot of things intuitively and seemingly doesn't give one refined process control per CDCs; so far for the 3 steps laid out above I the following pseudo script-wise:

===============

Let LastExecTime = ConvertToLocalTime(ReloadTime(), 'Place/TimeZone');
Let BeginningThisExecTime = ConvertToLocalTime(now(), 'Place/TimeZone');
Let LastExecTime = reloadtime();

// Loads data from QVD

LOAD   

PK,
BOL_UPD_DT,
c,
d,
e

 

//Isolate Primary Key for join use using unqualify function

qualify *;
unqualify PK;

// Select newly updated or inserted data from base table

SELECT

PK,
BOL_UPD_DT,
c,
d,
e

FROM base DLT
WHERE BOL_UPD_DT >= #$(LastExecTime)#
AND BOL_UPD_DT < #$(BeginningThisExecTime)#;

=====================

//Next for new QVD inserts I tried:

Concatenate LOAD * FROM QVD 
WHERE NOT EXISTS(PK);   

// did not work. QVD data load editor did not even save/compile because mistake in the script. 

I need some help here....

Labels (1)
12 Replies
Zenababy
Contributor II
Contributor II

Hello, my dear, how are you doing today, I am Zena 24 years old girl, I saw your profile today
I like It, I decided to contact you because i have
an important issue i need to disclosed to you
privately, please try to contact me with my
email address here ( zenahammed@hotmail.com )
if i hear from you i will tell you more about
me with my photos, thanks hoping to hear from
you, yours Zina.
Wale
Contributor II
Contributor II
Author

So I have figured it all out 🙂 Thanks for your initial reply:

Final Code:

=============================================================
LastUpdateDate:
Load
MAX(CDC_UPDATE_DT) as max_last_update
FROM lib://Folder_path/QLIK_CDC/qlik_cdc.qvd (QVD);
LET vMaxLastUpdate = Date(Peek('max_last_update', 0, 'TempTable'), 'YYYY-MM-DD');
DROP Table LastUpdateDate;
 
Incremental:
SELECT `CAR_ID`,
`CAR_MODEL`,
`CAR_YEAR`,
`COLOR`,
`CDC_CREATE_DT`,
`CDC_UPDATE_DT`
FROM `dw_schema`.`qlik_cdc`
WHERE CDC_UPDATE_DT > '$(vMaxLastUpdate)';
 
//for inserts and updates 
Concatenate 
LOAD CAR_ID, 
     CAR_MODEL, 
     CAR_YEAR, 
     COLOR, 
     CDC_CREATE_DT,
     CDC_UPDATE_DT
     FROM lib://Folder_path/QLIK_CDC/qlik_cdc.qvd (QVD)
     WHERE NOT Exists(CAR_ID); 
 
// for deletes
Inner Join 
SELECT `CAR_ID`
FROM `dw_schema`.`qlik_cdc`;
 
STORE Incremental INTO "lib://Folder_path/QLIK_CDC/qlik_cdc.qvd";
=============================================================

It works for new Inserts and updates (tested) and should work for deletes too.

Thanks
henrikalmen
Specialist II
Specialist II

Great! 🙂