From 48e4034b0295df0cb333552ab718add97702a54a Mon Sep 17 00:00:00 2001 From: Dave Date: Tue, 26 Nov 2024 11:01:44 +0100 Subject: [PATCH] fall back to default dataset if table not in schema --- dlt/destinations/dataset/dataset.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/dlt/destinations/dataset/dataset.py b/dlt/destinations/dataset/dataset.py index 0d08956354..4a96ad674c 100644 --- a/dlt/destinations/dataset/dataset.py +++ b/dlt/destinations/dataset/dataset.py @@ -112,18 +112,21 @@ def __call__(self, query: Any) -> ReadableDBAPIRelation: def table(self, table_name: str) -> SupportsReadableRelation: # we can create an ibis powered relation if ibis is available - try: - from dlt.common.libs.ibis import create_unbound_ibis_table - from dlt.destinations.dataset.ibis_relation import ReadableIbisRelation - - unbound_table = create_unbound_ibis_table(self.sql_client, self.schema, table_name) - return ReadableIbisRelation(readable_dataset=self, expression=unbound_table) # type: ignore[abstract] - except MissingDependencyException: - # fallback to the standard dbapi relation - return ReadableDBAPIRelation( - readable_dataset=self, - table_name=table_name, - ) # type: ignore[abstract] + if table_name in self.schema.tables: + try: + from dlt.common.libs.ibis import create_unbound_ibis_table + from dlt.destinations.dataset.ibis_relation import ReadableIbisRelation + + unbound_table = create_unbound_ibis_table(self.sql_client, self.schema, table_name) + return ReadableIbisRelation(readable_dataset=self, expression=unbound_table) # type: ignore[abstract] + except MissingDependencyException: + pass + + # fallback to the standard dbapi relation + return ReadableDBAPIRelation( + readable_dataset=self, + table_name=table_name, + ) # type: ignore[abstract] def __getitem__(self, table_name: str) -> SupportsReadableRelation: """access of table via dict notation"""