Skip to content

Commit

Permalink
fix: use dataset fetch_metadata method
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed Apr 4, 2024
1 parent 32553c1 commit 1ce785a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
from pathlib import Path

from superset import security_manager
from superset.commands.dataset.refresh import RefreshDatasetCommand
from superset.examples.utils import load_configs_from_directory
from superset.extensions import db
from superset.models.dashboard import Dashboard
from superset.connectors.sqla.models import SqlaTable
from superset.utils.database import get_or_create_db
from superset.models.embedded_dashboard import EmbeddedDashboard
from pythonpath.localization import get_translation
from flask import g
from superset.connectors.sqla.utils import get_columns_description

BASE_DIR = "/app/assets/superset"
Expand Down Expand Up @@ -294,14 +292,8 @@ def update_datasets():
db.session.query(SqlaTable).all()
)
for dataset in datasets:
try:
if dataset_is_empty(dataset):
print(f"Dataset {dataset.table_name} is empty")
continue
RefreshDatasetCommand(dataset.id).run()
print(f"Refreshing dataset {dataset.table_name}")
except Exception as e:
print(f"Failed to refresh dataset {dataset.table_name}")
print(f"Refreshing dataset {dataset.table_name}")
dataset.fetch_metadata(commit=True)


def dataset_is_empty(dataset):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ columns:
python_date_format: null
type: String
verbose_name: Video Name
- advanced_data_type: null
column_name: video_position
description: null
expression: null
extra: {}
filterable: true
groupby: true
is_active: true
is_dttm: false
python_date_format: null
type: Decimal(9, 2)
verbose_name: Video Position
- advanced_data_type: null
column_name: org
description: null
Expand All @@ -98,6 +110,54 @@ columns:
python_date_format: null
type: String
verbose_name: Organization
- advanced_data_type: null
column_name: video_duration
description: null
expression: null
extra: {}
filterable: true
groupby: true
is_active: true
is_dttm: false
python_date_format: null
type: Int64
verbose_name: Video Duration
- advanced_data_type: null
column_name: graded
description: null
expression: null
extra: {}
filterable: true
groupby: true
is_active: true
is_dttm: false
python_date_format: null
type: Bool
verbose_name: Graded
- advanced_data_type: null
column_name: visualization_bucket
description: null
expression: null
extra: {}
filterable: true
groupby: true
is_active: true
is_dttm: false
python_date_format: null
type: String
verbose_name: Visualization Bucket
- advanced_data_type: null
column_name: video_id
description: null
expression: null
extra: {}
filterable: true
groupby: true
is_active: true
is_dttm: false
python_date_format: null
type: String
verbose_name: Video ID
database_uuid: 21174b6c-4d40-4958-8161-d6c3cf5e77b6
default_endpoint: null
description: null
Expand Down Expand Up @@ -130,7 +190,8 @@ metrics:
d3format: null
description: null
expression: COUNT(*)
extra: null
extra:
warning_markdown: ''
metric_name: count
metric_type: count
verbose_name: COUNT(*)
Expand Down

0 comments on commit 1ce785a

Please sign in to comment.