reload dataset schema programmatically

fmonari
Level 2
reload dataset schema programmatically

Hi All,

is it possible to reload a s3 dataset schema programmatically through the usage of the dataikuapi package? Thanks in advance!

Regards,

Filippo

0 Kudos
2 Replies
KeijiY
Dataiker

Hello @fmonari,

Thank you so much for posting the question on Community.

Yes, you can reload a dataset's schema via Dataiku Python API as follows:

import dataiku

client = dataiku.api_client()
project = client.get_default_project()
dataset = project.get_dataset('your_dataset_name')

# `autodetect_settings` will however only detect if the schema is empty, so let's clear it.
settings = dataset.get_settings()
del settings.schema_columns[:]
settings.save()

# Redetect and save the suggestion.
settings = dataset.autodetect_settings()
settings.save()

Please see this DSS document https://doc.dataiku.com/dss/8.0/python-api/datasets-other.html#sql-dataset-modifying-settings for the details.

I hope this would help.

Sincerely,
Keiji, Dataiku Technical Support

0 Kudos
fmonari
Level 2
Author

Thanks KeijiY I will try it out!

0 Kudos