mirror of
https://github.com/apache/superset.git
synced 2026-04-21 17:14:57 +00:00
fix: handle empty catalog when DB supports them (#29840)
This commit is contained in:
@@ -54,23 +54,28 @@ class CreateDatasetCommand(CreateMixin, BaseCommand):
|
||||
def validate(self) -> None:
|
||||
exceptions: list[ValidationError] = []
|
||||
database_id = self._properties["database"]
|
||||
schema = self._properties.get("schema")
|
||||
catalog = self._properties.get("catalog")
|
||||
schema = self._properties.get("schema")
|
||||
table_name = self._properties["table_name"]
|
||||
sql = self._properties.get("sql")
|
||||
owner_ids: Optional[list[int]] = self._properties.get("owners")
|
||||
|
||||
table = Table(self._properties["table_name"], schema, catalog)
|
||||
|
||||
# Validate uniqueness
|
||||
if not DatasetDAO.validate_uniqueness(database_id, table):
|
||||
exceptions.append(DatasetExistsValidationError(table))
|
||||
|
||||
# Validate/Populate database
|
||||
database = DatasetDAO.get_database_by_id(database_id)
|
||||
if not database:
|
||||
exceptions.append(DatabaseNotFoundValidationError())
|
||||
self._properties["database"] = database
|
||||
|
||||
# Validate uniqueness
|
||||
if database:
|
||||
if not catalog:
|
||||
catalog = self._properties["catalog"] = database.get_default_catalog()
|
||||
|
||||
table = Table(table_name, schema, catalog)
|
||||
|
||||
if not DatasetDAO.validate_uniqueness(database, table):
|
||||
exceptions.append(DatasetExistsValidationError(table))
|
||||
|
||||
# Validate table exists on dataset if sql is not provided
|
||||
# This should be validated when the dataset is physical
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user