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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Sauree_10
Contributor II
Contributor II

Qlik Replicate | Custom SQL

 All,

Can I write the customized sql query while selecting the data in Qlik replicate?

If, yes how to do so?

 

Thanks,

Saurabh  

Labels (1)
1 Solution

Accepted Solutions
john_wang
Support
Support

Hello @zparveen ,

Glad to hear you are interesting how Replicate works 🙂 Well, it's not a special language but only a few 'tricks':

1- The whole passthrough filter expression in the GUI will be executed in source side database so its syntax relies on source database; that means you may use 3rd  party JDBC/ODBC query tools to test your SQL, eg SQL Workbench/J, RazorSQL, DBeaver etc, it's much easier to debug SQL than using Replicate task running.

2- The whole passthrough filter expression (eg "xxxx" ) will be sent to source database combined with "WHERE ( xxxx )" sub-clause. No way to repress the WHERE sub-clause as it's hard coded, however we may use single right parenthesis ")" to end up the WHERE sub-clause prior to embedded ")".

3- "LIMIT nnnn" cannot be included in WHERE clause, we have to move it out of "WHERE ( xxxx )" string

4- To make sure no empty parenthesis "()" generated (it may lead syntax error), we add "1=1" (it's TRUE forever). Certainly you may add more clauses eg "1=1 and ID >= 20230101" if necessary (ID is your table column) then you may keep or remove "1=1".

5- Now we end up the expression by semicolon, it looks like "1=1) LIMIT 1000 ;".  The last step is removing the latest useless embedded ")": We add comment string "--" before it, PostgreSQL will ignore the comment string "--)". So the whole expression in PostgreSQL is:

1=1) LIMIT 1000 ;--

With above expression, Replicate will execute the query as:

2023-02-10T17:00:46 [SOURCE_UNLOAD   ]T:  SELECT ... FROM ... WHERE (1=1) LIMIT 1000 ;--), postgres_construct_select_statement

Hope it helps,

Regards,

John.

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!

View solution in original post

12 Replies
Alan_Wang
Support
Support

Hi Saurabh,

You do not write customized SQL queries for selecting data in Qlik Replicate. You can use table settings to enable filters on the columns that will filter data for Replication.

Thanks,

Alan

If the issue is solved please mark the answer with Accept as Solution.
Clever_Anjos
Employee
Employee

If you plan to use a Full Load (not CDC) you could create a view with your SQL and use it as a source

zparveen
Contributor II
Contributor II

Do you have sample query filters for eg adding Limit condition in the Pass through filters.

Only selecting 1000 rows. Can you provide some samples please

zparveen
Contributor II
Contributor II

I'm working on the POC , Postgres SQL as the source and AWS S3 as the target endpoints

shashi_holla
Support
Support

@zparveen You have to add following text in the passthru filter field for the table

1=1 LIMIT 1000

Internally Replicate will convert it as follows:

select a,b from table where 1=1 LIMIT 1000

Thank you,

zparveen
Contributor II
Contributor II

Thanks Shashi for responding, I tried your filter but still shows it is picking 10 million records when the task is running. Do we have any Qlik guide on this queries pass through?

 

Michael_Litz
Support
Support

Hi @zparveen ,

Please have a look at this Techspert where there is a section on doing passthrough filters.

https://community.qlik.com/t5/Official-Support-Articles/Qlik-Replicate-Loading-Best-Practices/ta-p/2...

Let me know if this helps out.

Thanks,
Michael

narendersarva
Support
Support

Hi @zparveen 

You can try to create a view in the same database which will select the 1000 rows. 

 

Thanks
Naren

john_wang
Support
Support

Hello @zparveen , @Sauree_10 ,

For PostgreSQL source database, the LIMIT rows sample is:

1=1) LIMIT 1000 ;--

john_wang_0-1676007500387.png

Hope this helps.

Regards,

John.

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!