# A way to replace the definition of a VDS?

**URL:** <https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604>\
**Category:** Uncategorized\
**Created:** [January 23, 2019, 9:47am UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604 "2019-01-23T09:47:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfleckinger](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dfleckinger/32/370_2.png) [@dfleckinger](https://community.dremio.com/u/dfleckinger)\
**Post date:** [January 23, 2019, 9:47am UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604/1 "2019-01-23T09:47:31Z")

</div>

Hi,

there is currently a way to create a VDS using command CREATE VDS,  
and there is a way to create a table through CREATE TABLE AS SELECT (CTAS).

I would like to be able to replace a VDS and also replace a physical table ? Is there a command for that ?

My use case is the following : I create a physical dataset using CTAS. I would like to periodically update this physical dataset (eg with new daily data) without loosing the accelerations already created. The data fields would remain the same.

Thanks  
David

---

<div class="post-metadata">

**Author:** ![kelly](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/kelly/32/11_2.png) [@kelly](https://community.dremio.com/u/kelly)\
**Post date:** [January 25, 2019, 5:33pm UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604/2 "2019-01-25T17:33:06Z")

</div>

What you might be able to do is to partition your data by time using CTAS:

/mytable/day1/files.parquet  
/mytable/day2/files.parquet  
etc

Then have a VDS that sits on top of /mytable.

This would only work in an append-only model, no ability to update individual rows, but you could re-run the CTAS for a given day.

Does that help?

---

<div class="post-metadata">

**Author:** ![dfleckinger](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dfleckinger/32/370_2.png) [@dfleckinger](https://community.dremio.com/u/dfleckinger)\
**Post date:** [January 29, 2019, 9:30am UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604/3 "2019-01-29T09:30:46Z")

</div>

Thanks @kelly.  
I’ve already implemented mechanisms such as the one you describe.

From your answer, I understand there is currently no command to change the definition of a VDS, without removing it. I was hoping there was a command to mimic the “Save” button that we use when updating a dataset.

---

<div class="post-metadata">

**Author:** ![pbofonseca](https://avatars.discourse-cdn.com/v4/letter/p/74df32/32.png) [@pbofonseca](https://community.dremio.com/u/pbofonseca)\
**Post date:** [August 19, 2019, 12:38pm UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604/4 "2019-08-19T12:38:19Z")

</div>

Hi, @dfleckinger

Did you find any solution to refresh without recreate your dataset based on CTAS? I have something like that. I saved the results in a parquet file in S3, but I need to increment it.

---

<div class="post-metadata">

**Author:** ![dfleckinger](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dfleckinger/32/370_2.png) [@dfleckinger](https://community.dremio.com/u/dfleckinger)\
**Post date:** [August 19, 2019, 1:02pm UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604/5 "2019-08-19T13:02:40Z")

</div>

hi @pbofonseca, not really.  
I could not use Dremio for that, as during my tests CTAS was not able to create parquet files without also creating a Physical dataset at the same time. Also at the time, parquet files created by Dremio were not readable by my other python tools (pandas, pyarrow). I think that since a few versions, pyarrow pandas should be able to read Dremio CTAS files so may be there’s a way to use CTAS.

What I currently do :

- I have created a Dremio Physical Dataset (PDS) at the root.
- For new data to be appended to this dataset, I extract data to a pandas DataFrame with Dremio, and write it as a parquet partitioned dataset on a daily basis within the PDS
- After parquet writing, I execute the Dremio command “ALTER PDS {my\_pds} REFRESH METADATA”, so that Dremio is able to see the files that have just been created.

---

<div class="post-metadata">

**Author:** ![dfleckinger](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/dfleckinger/32/370_2.png) [@dfleckinger](https://community.dremio.com/u/dfleckinger)\
**Post date:** [August 19, 2019, 1:07pm UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604/6 "2019-08-19T13:07:53Z")

</div>

Also I recently saw that there is now a way ro replace a VDS :

[https://docs.dremio.com/sql-reference/sql-commands/datasets.html](https://docs.dremio.com/sql-reference/sql-commands/datasets.html)

`> CREATE OR REPLACE VDS <VIRTUAL-DATASET-PATH> AS <SQL-QUERY>`

For example  
`> CREATE OR REPLACE VDS demo.jobs_vds as SELECT * FROM "oracle_e2e".DREMIO.JOBS`

I don’t know which version introduced that but that’s a good new !

---

<div class="post-metadata">

**Author:** ![pbofonseca](https://avatars.discourse-cdn.com/v4/letter/p/74df32/32.png) [@pbofonseca](https://community.dremio.com/u/pbofonseca)\
**Post date:** [August 19, 2019, 2:19pm UTC](https://community.dremio.com/t/a-way-to-replace-the-definition-of-a-vds/2604/7 "2019-08-19T14:19:45Z")

</div>

> [@dfleckinger](#):
>
> - I have created a Dremio Physical Dataset (PDS) at the root.
> - For new data to be appended to this dataset, I extract data to a pandas DataFrame with Dremio, and write it as a parquet partitioned dataset on a daily basis within the PDS
> - After parquet writing, I execute the Dremio command “ALTER PDS {my\_pds} REFRESH METADATA”, so that Dremio is able to see the files that have just been created.

I’ll try this!

> [@dfleckinger](#):
>
> [https://docs.dremio.com/sql-reference/sql-commands/datasets.html](https://docs.dremio.com/sql-reference/sql-commands/datasets.html)

I think that is my last step. Thanks a lot!
