dosubot[bot] commented on issue #30363:
URL: https://github.com/apache/superset/issues/30363#issuecomment-2369158486
<!-- Greeting -->
Hey @ilsaloving, I'm here to help you with any bugs, questions, or
contributions you have regarding Superset. Let's tackle this together!
<!-- Answer -->
To obtain the YAML schema definition for data sources in Superset 4.0.2
using the CLI, you should use the `export_datasource_schema` command. Here is
the command you need to run:
```sh
superset export_datasource_schema
```
This command will export the datasource YAML schema to stdout. If you want
to include parent back references, you can add the `-b` flag:
```sh
superset export_datasource_schema -b
```
Regarding the `AttributeError` you encountered with the
`legacy-export-datasource-schema` command, it seems to be related to a change
in the `export_schema_to_dict` function in `dict_import_export.py`. The
function was modified to call `Database.export_schema` with the parameters
`recursive=True` and `include_parent_ref=back_references`. This change might
cause an `AttributeError` if the `Database` class does not have an
`export_schema` method.
Here is the relevant code snippet:
```python
def export_schema_to_dict(back_references: bool) -> dict[str, Any]:
"""Exports the supported import/export schema to a dictionary"""
databases = [
Database.export_schema(recursive=True,
include_parent_ref=back_references)
]
data = {}
if databases:
data[DATABASES_KEY] = databases
return data
```
If `Database` does not have an `export_schema` method, attempting to call it
will result in an `AttributeError`
<sup>[[1]](https://github.com/apache/superset/blob/master/superset/cli/importexport.py)</sup><sup>[[2]](https://github.com/apache/superset/blob/master/superset/utils/dict_import_export.py)</sup>.
For the `SqlMetric` class, the `class_` attribute is not defined. The
`SqlMetric` class includes attributes such as `id`, `metric_name`,
`verbose_name`, `metric_type`, `description`, `d3format`, `currency`,
`warning_text`, `table_id`, `expression`, and `extra`. It also includes
relationships, methods, and properties to handle various functionalities
related to SQL metrics
<sup>[[3]](https://github.com/apache/superset/blob/master/superset/connectors/sqla/models.py)</sup><sup>[[4]](https://github.com/apache/superset/blob/master/tests/unit_tests/datasets/conftest.py)</sup>.
To resolve the issue, you may need to ensure that the `Database` class has
the `export_schema` method implemented or adjust the code to handle the absence
of this method.
<!-- Dosu Comment Footer -->
*To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
--
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]