FrancescoCastaldi commented on code in PR #43695:
URL: https://github.com/apache/superset/pull/43695#discussion_r4243552751
##########
superset/db_engine_specs/lint_metadata.py:
##########
@@ -272,10 +276,17 @@ def get_all_engine_specs_ast() -> list[dict[str, Any]]:
# noqa: C901
if isinstance(item, ast.Assign):
for target in item.targets:
if isinstance(target, ast.Name) and target.id ==
"engine":
- # Check if engine value is non-empty string
if isinstance(item.value, ast.Constant):
has_non_empty_engine =
bool(item.value.value)
break
+ elif isinstance(item, ast.AnnAssign):
+ if (
+ isinstance(item.target, ast.Name)
+ and item.target.id == "engine"
+ ):
+ if isinstance(item.value, ast.Constant):
+ has_non_empty_engine = bool(item.value.value)
+ break
Review Comment:
Handled in `lint_metadata.py`: `AnnAssign` items without an initializer
(`item.value is None`) now continue scanning the class body to pick up
subsequent assignment statements (such as `engine = 'typed_engine'`), ensuring
typed base engine specs remain in the AST report.
##########
superset/db_engine_specs/parseable.py:
##########
@@ -41,11 +41,14 @@ class ParseableEngineSpec(BaseEngineSpec):
"Parseable is a distributed log analytics database "
"with SQL-like query interface."
),
+ "logo": "parseable.png",
+ "homepage_url": "https://www.parseable.com",
"categories": [DatabaseCategory.SEARCH_NOSQL,
DatabaseCategory.OPEN_SOURCE],
"pypi_packages": ["sqlalchemy-parseable"],
"connection_string": (
"parseable://{username}:{password}@{hostname}:{port}/{stream_name}"
),
+ "default_port": 8000,
Review Comment:
Updated in `parseable.py`: the default template URI now uses
`parseable+http://` on port 8000, while the connection example specifically
showcases `parseable+https://` on port 443.
##########
superset/db_engine_specs/databricks.py:
##########
@@ -955,6 +980,29 @@ class DatabricksODBCEngineSpec(DatabricksBaseEngineSpec):
drivers = {"pyodbc": "ODBC driver for SQL endpoint"}
default_driver = "pyodbc"
+ metadata = {
+ "description": ("Databricks SQL Endpoint connectivity via the pyodbc
driver."),
+ "logo": "databricks.png",
+ "homepage_url": "https://www.databricks.com/",
+ "categories": [
+ DatabaseCategory.CLOUD_DATA_WAREHOUSES,
+ DatabaseCategory.ANALYTICAL_DATABASES,
+ DatabaseCategory.PROPRIETARY,
+ ],
+ "pypi_packages": ["pyodbc"],
Review Comment:
Addressed in commit `3b708447d1`: updated
`DatabricksODBCEngineSpec.metadata['pypi_packages']` to list
`databricks-dbapi[sqlalchemy]` so the dialect is properly registered.
##########
superset/db_engine_specs/databricks.py:
##########
@@ -974,6 +1022,31 @@ class DatabricksHiveEngineSpec(HiveEngineSpec):
drivers = {"pyhive": "Hive driver for Interactive Cluster"}
default_driver = "pyhive"
+ metadata = {
+ "description": (
+ "Databricks Interactive Cluster connectivity via the PyHive
connector."
+ ),
+ "logo": "databricks.png",
+ "homepage_url": "https://www.databricks.com/",
+ "categories": [
+ DatabaseCategory.CLOUD_DATA_WAREHOUSES,
+ DatabaseCategory.ANALYTICAL_DATABASES,
+ DatabaseCategory.HOSTED_OPEN_SOURCE,
+ ],
+ "pypi_packages": ["pyhive"],
Review Comment:
Addressed in commit `3b708447d1`: updated
`DatabricksPyHiveEngineSpec.metadata['pypi_packages']` to list
`databricks-dbapi[sqlalchemy]` for dialect registration.
##########
superset/db_engine_specs/clickhouse.py:
##########
@@ -261,9 +261,25 @@ class ClickHouseEngineSpec(ClickHouseBaseEngineSpec):
_show_functions_column = "name"
supports_file_upload = False
- # Note: Primary metadata is in ClickHouseConnectEngineSpec which
consolidates
- # both drivers. This spec exists for backwards compatibility with existing
- # connections using the clickhouse-sqlalchemy driver.
+ metadata = {
+ "description": (
+ "ClickHouse is an open-source column-oriented database for
real-time "
+ "analytics using SQL (legacy clickhouse-sqlalchemy connector)."
+ ),
+ "logo": "clickhouse.png",
+ "homepage_url": "https://clickhouse.com/",
+ "categories": [
+ DatabaseCategory.ANALYTICAL_DATABASES,
+ DatabaseCategory.OPEN_SOURCE,
+ ],
+ "pypi_packages": ["clickhouse-sqlalchemy"],
+ "connection_string": (
+ "clickhouse://{username}:{password}@{host}:{port}/{database}"
+ ),
+ "default_port": 8123,
+ "docs_url": "https://clickhouse.com/docs/",
+ "sqlalchemy_docs_url":
"https://github.com/xzkostyan/clickhouse-sqlalchemy",
Review Comment:
Addressed in commit `17b804d2e6`: defined explicit `sqlalchemy_docs_url` on
`ClickHouseConnectEngineSpec.metadata` to prevent falling back to the legacy
driver link via class inheritance.
##########
superset/db_engine_specs/ibmi.py:
##########
@@ -14,20 +14,41 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from superset.db_engine_specs.base import DatabaseCategory
+
from .db2 import Db2EngineSpec
class IBMiEngineSpec(Db2EngineSpec):
- """IBM Db2 for i (AS/400) engine spec.
-
- Note: Documentation is in Db2EngineSpec's compatible_databases section.
- This spec exists for runtime support of the ibmi driver.
- """
+ """IBM Db2 for i (AS/400) engine spec."""
engine = "ibmi"
engine_name = "IBM Db2 for i"
max_column_name_length = 128
+ metadata = {
+ "description": (
+ "IBM Db2 for i (formerly AS/400) is an integrated relational
database "
+ "engine on IBM Power systems running IBM i."
+ ),
+ "logo": "ibm-db2.svg",
+ "homepage_url": "https://www.ibm.com/products/db2-for-i",
+ "categories": [
+ DatabaseCategory.TRADITIONAL_RDBMS,
+ DatabaseCategory.PROPRIETARY,
+ ],
+ "pypi_packages": ["sqlalchemy-ibmi"],
+ "connection_string": "ibmi://{username}:{password}@{host}/{database}",
+ "parameters": {
+ "username": "IBM i username",
+ "password": "IBM i password",
+ "host": "IBM i system host",
+ "database": "Library/schema name",
Review Comment:
Addressed in commit `1ad6d80546`: updated IBM i database description to
specify 'RDB name' matching ODBC driver expectations.
##########
tests/unit_tests/db_engine_specs/test_lint_metadata.py:
##########
@@ -0,0 +1,65 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+# either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import tempfile
+from pathlib import Path
+from textwrap import dedent
+
+from superset.db_engine_specs import lint_metadata
+from superset.db_engine_specs.lint_metadata import get_all_engine_specs_ast
+
+
+def test_get_all_engine_specs_ast_annotated_attributes() -> None:
+ """
+ Ensure engine specs with type-annotated engine, engine_name, and metadata
+ are correctly discovered and parsed by get_all_engine_specs_ast.
+ """
+ specs_dir = Path(lint_metadata.__file__).parent
+ code = dedent(
+ """
+ from typing import Any
+ from superset.db_engine_specs.base import BaseEngineSpec
+
+ class TypedBaseEngineSpec(BaseEngineSpec):
+ engine: str = "typed_engine"
+ engine_name: str = "Typed Engine"
+ metadata: dict[str, Any] = {
+ "description": "A typed engine spec",
+ }
+ """
+ )
+
+ with tempfile.NamedTemporaryFile(
+ mode="w",
+ dir=specs_dir,
Review Comment:
Resolved: `test_lint_metadata.py` uses pytest `tmp_path` fixtures for
synthetic engine specs, leaving the package source tree untouched.
--
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]