dlt-hub / verified-sources

Contribute to dlt verified sources 🔥
https://dlthub.com/docs/walkthroughs/add-a-verified-source
Apache License 2.0
50 stars 40 forks source link

Enable default inclusion of views in MetaData object (SQL database) #459

Closed dat-a-man closed 1 month ago

dat-a-man commented 1 month ago

Feature description

Please enable the MetaData.reflect function in dlt to include views by default when accessing database resources. Currently, views are not included by default, requiring additional steps to configure, leading to potential oversight.

Are you a dlt user?

Yes, I run dlt in production.

Use case

When extracting and loading views from a SQL database, users need to manually enable view inclusion by setting MetaData.reflect(bind=engine, views=True) method. This additional step can be overlooked and is not initially intuitive.

Proposed solution

Modify the default behavior of the MetaData object to include views by default by setting views=True in the MetaData.reflect method. This would streamline processes for users who manage databases and want to load views.

Related issues

No response

rudolfix commented 1 month ago

To implement that correctly:

  1. check that sql_table can extract a view by writing a test even without setting any flags in sql alchemy
  2. add a flag to sql_database to include views in reflection (default: false)
  3. write tests that check if the flag works