Skip to content

Commit

Permalink
Skip columns for hidden tables (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
gouline authored Jul 4, 2024
1 parent 3d18ffa commit 0d36ef2
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions dbtmetabase/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,19 @@ def export_models(

field = table.get("fields", {}).get(column_name)
if not field:
if table.get("visibility_type") == "hidden":
table_label = "hidden table"
table["stale"] = True
else:
table_label = "table"
synced = False

_logger.warning(
"Field '%s' not in table '%s'", column_name, table_key
"Field '%s' not in %s '%s'",
column_name,
table_label,
table_key,
)
synced = False
continue

ctx.tables = tables
Expand Down Expand Up @@ -178,6 +187,13 @@ def __export_model(
model_caveats = model.caveats or None
model_visibility = model.visibility_type or None

# Going from hidden to visible may require a retry
retryable = (
api_table.get("visibility_type") == "hidden"
and model_visibility != "hidden"
and api_table.get("stale", False)
)

body_table = {}

# Update if specified, otherwise reset one that had been set
Expand Down Expand Up @@ -205,6 +221,10 @@ def __export_model(
else:
_logger.info("Table '%s' is up to date", table_key)

if model_visibility == "hidden":
_logger.info("Table '%s' is hidden, skipping columns", table_key)
return success

for column in model.columns:
success &= self.__export_column(
ctx,
Expand All @@ -221,6 +241,11 @@ def __export_model(
table_key=table_key,
)

if not success and retryable:
_logger.error(
"Table '%s' got stale while hidden, retrying may help", table_key
)

return success

def __export_model_column_order(
Expand Down

0 comments on commit 0d36ef2

Please sign in to comment.