betodealmeida commented on code in PR #41106:
URL: https://github.com/apache/superset/pull/41106#discussion_r3438173613
##########
superset/commands/dataset/duplicate.py:
##########
@@ -68,6 +68,7 @@ def run(self) -> Model:
table = SqlaTable(table_name=table_name, owners=owners)
table.database = database
table.schema = self._base_model.schema
+ table.catalog = self._base_model.catalog
Review Comment:
While this works, it's a patchy solution that's likely to break again
whenever we add new fields to `SqlaTable`. We can instead do something like
this:
```python
table = self._base_model.copy() # copies all `export_fields`
table.table_name = table_name # override the cloned name
table.owners = owners
table.database = database
table.is_sqllab_view = True
if table.sql:
table.sql = table.sql.strip().strip(";")
db.session.add(table)
table.columns = [
TableColumn(
column_name=c.column_name,
verbose_name=c.verbose_name,
expression=c.expression,
filterable=True,
groupby=True,
is_dttm=c.is_dttm,
type=c.type,
description=c.description,
)
for c in self._base_model.columns
]
table.metrics = [
SqlMetric(
metric_name=m.metric_name,
verbose_name=m.verbose_name,
expression=m.expression,
metric_type=m.metric_type,
description=m.description,
)
for m in self._base_model.metrics
]
return table
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]