server-client-python icon indicating copy to clipboard operation
server-client-python copied to clipboard

Would be possible to add an option to have incremental refresh for workbooks or datasources?

Open smafra opened this issue 5 years ago • 7 comments

Would be nice if we can have in refresh.py a incremental or full refresh option on workbooks/dasources. Today it´s defaulted to full extract always.

smafra avatar Dec 15 '20 23:12 smafra

Hi @smafra.

I've been waiting for this feature for awhile but it looks like it's a limitation from the Tableau Rest API itself not the TSC.

ghost avatar Dec 17 '20 05:12 ghost

Hi @rafaeljraposo,

Thanks for the answer. Any known workarounds for that?

smafra avatar Dec 17 '20 18:12 smafra

This is an old issue, but commenting for anyone else with the same issue. It's possible to trigger the incremental refresh of a datasource, you just have to use the tasks api to run the extract rather than the datasources api

import tableauserverclient as tsc
import xmltodict


personal_access_token_name = ''
personal_access_token_secret = ''
tableau_server = ''

# Name of the data source in tableau
datasource = ''

tableau_auth = tsc.PersonalAccessTokenAuth(
    token_name=personal_access_token_name,
    personal_access_token=personal_access_token_secret
)
server = tsc.Server(tableau_server, use_server_version=True)
server.auth.sign_in(tableau_auth)

# Get datasource id from datasource name
req_option = tsc.RequestOptions(pagesize=1000)
req_option.filter.update([tsc.Filter(tsc.RequestOptions.Field.Name, tsc.RequestOptions.Operator.Equals, datasource)])
all_datasources = list(tsc.Pager(server.datasources, req_option))

datasource_id = all_datasources[0].id

# Get 1000 tasks and then filter for only extract tasks under the datasource id of interest
# I don't believe you can filter tasks
all_extracts = list(tsc.Pager(server.tasks, tsc.RequestOptions(pagesize=1000)))

# The task type for incremental extracts is 'IncrementExtractTask' and full extracts is 'extractRefresh'
extracts = [i for i in all_extracts if (i.target.id == datasource_id) and ('IncrementExtractTask' == i.task_type)]

incremental_extract_obj = extracts[0]

# Trigger the incremental extract associated with the datasource
update_xml = server.tasks.run(incremental_extract_obj)
job_id = xmltodict.parse(update_xml)['tsResponse']['job']['@id']
print(f"Refresh extract job {job_id} created")

This is working on Tableau Server version 2021.4.3 with Tableau Python Server Client 0.16.0

hydriniumh2 avatar Apr 27 '22 18:04 hydriniumh2

How to do the Incremental refresh on workbooks using python script. it´s defaulted to full extract always. Do let me know.

NandiniCS avatar Nov 07 '22 13:11 NandiniCS

Thanks @hydriniumh2, it works well.

harrydevforlife avatar Nov 18 '25 08:11 harrydevforlife

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. If this is still relevant, please comment to keep it open.

github-actions[bot] avatar Aug 06 '26 02:08 github-actions[bot]

Closing — incremental refresh was added in PR #1545 (feat: incremental refresh for extracts). Both workbooks.refresh() and datasources.refresh() now accept an incremental=True kwarg:

server.workbooks.refresh(workbook, incremental=True)
server.datasources.refresh(datasource, incremental=True)

jacalata avatar Aug 06 '26 05:08 jacalata