Copilot commented on code in PR #43698:
URL: https://github.com/apache/superset/pull/43698#discussion_r3891800552
##########
tests/unit_tests/db_engine_specs/test_ydb.py:
##########
@@ -81,3 +81,22 @@ def test_specify_credentials() -> None:
YDBEngineSpec.update_params_from_encrypted_extra(database, params)
connect_args = params.setdefault("connect_args", {})
assert connect_args.get("credentials") == auth_params
+
+
+def test_ydb_properties() -> None:
+ from superset.db_engine_specs.ydb import YDBEngineSpec
+
+ assert YDBEngineSpec.engine == "yql"
+ assert YDBEngineSpec.engine_name == "YDB"
+ assert YDBEngineSpec.default_driver == "ydb"
+ assert YDBEngineSpec.allows_alias_in_orderby is True
+
+
+def test_ydb_metadata() -> None:
+ from superset.db_engine_specs.ydb import YDBEngineSpec
+
+ metadata = YDBEngineSpec.metadata
+ assert "YDB is a distributed SQL database" in metadata["description"]
+ assert metadata["logo"] == "ydb.svg"
+ assert "ydb" in metadata["pypi_packages"]
+
Review Comment:
`metadata["pypi_packages"]` for YDB is `["ydb-sqlalchemy",
"ydb-sqlglot-plugin"]`, so asserting membership of the string "ydb" will fail.
Assert against the actual package name(s) instead.
##########
tests/unit_tests/db_engine_specs/test_druid.py:
##########
@@ -258,3 +258,23 @@ def test_unmask_encrypted_extra() -> None:
assert DruidEngineSpec.unmask_encrypted_extra(old, new) == json.dumps(
{"connect_args": {"scheme": "http", "jwt": "old-token", "password":
"new"}}
)
+
+
+def test_druid_properties() -> None:
+ from superset.db_engine_specs.druid import DruidEngineSpec
+
+ assert DruidEngineSpec.engine == "druid"
+ assert DruidEngineSpec.engine_name == "Apache Druid"
+ assert DruidEngineSpec.allows_joins is True
+ assert DruidEngineSpec.allows_subqueries is True
+
Review Comment:
`DruidEngineSpec.allows_joins` is computed from the `DRUID_JOINS` feature
flag (not a constant `True`), and the spec's `default_port` is 9088. These
assertions will be flaky/incorrect.
This issue also appears on line 275 of the same file.
##########
tests/unit_tests/db_engine_specs/test_drill.py:
##########
@@ -174,3 +174,22 @@ def test_connect_make_label_compatible(column_name: str,
expected_result: str) -
label = spec.make_label_compatible(column_name)
assert label == expected_result
+
+
+def test_drill_properties() -> None:
+ from superset.db_engine_specs.drill import DrillEngineSpec
+
+ assert DrillEngineSpec.engine == "drill"
+ assert DrillEngineSpec.engine_name == "Apache Drill"
+ assert DrillEngineSpec.default_driver == "sadrill"
+
+
+def test_drill_metadata() -> None:
+ from superset.db_engine_specs.drill import DrillEngineSpec
+
+ metadata = DrillEngineSpec.metadata
+ assert "Apache Drill" in metadata["description"]
+ assert metadata["logo"] == "drill.png"
+ assert "sqlalchemy-drill" in metadata["pypi_packages"]
+ assert metadata["default_port"] == 8047
Review Comment:
DrillEngineSpec metadata uses `apache-drill.png` as its logo; asserting
`drill.png` will fail.
##########
tests/unit_tests/db_engine_specs/test_firebird.py:
##########
@@ -104,3 +104,22 @@ def test_convert_dttm(
)
assert_convert_dttm(spec, target_type, expected_result, dttm)
+
+
+def test_firebird_properties() -> None:
+ from superset.db_engine_specs.firebird import FirebirdEngineSpec
+
+ assert FirebirdEngineSpec.engine == "firebird"
+ assert FirebirdEngineSpec.engine_name == "Firebird"
+ assert FirebirdEngineSpec.default_driver == "fdb"
+
Review Comment:
FirebirdEngineSpec does not define `default_driver` (it inherits `None` from
BaseEngineSpec), so this assertion will fail.
##########
tests/unit_tests/db_engine_specs/test_redshift.py:
##########
@@ -109,3 +109,24 @@ def
test_extended_aggregation_func_inherited_from_postgres() -> None:
for aggregate in ("STDDEV_SAMP", "VAR_SAMP"):
assert RedshiftEngineSpec.get_extended_aggregation_func(aggregate) is
not None
+
+
+def test_redshift_properties() -> None:
+ from superset.db_engine_specs.postgres import PostgresBaseEngineSpec
+ from superset.db_engine_specs.redshift import RedshiftEngineSpec
+
+ assert RedshiftEngineSpec.engine == "redshift"
+ assert RedshiftEngineSpec.engine_name == "Amazon Redshift"
+ assert RedshiftEngineSpec.max_column_name_length == 127
+ assert issubclass(RedshiftEngineSpec, PostgresBaseEngineSpec)
+
+
+def test_redshift_metadata() -> None:
+ from superset.db_engine_specs.redshift import RedshiftEngineSpec
+
+ metadata = RedshiftEngineSpec.metadata
+ assert "Amazon Redshift is a fully managed, petabyte-scale" in
metadata["description"]
+ assert metadata["logo"] == "aws.png"
+ assert "redshift_connector" in metadata["pypi_packages"]
+ assert metadata["default_port"] == 5439
Review Comment:
RedshiftEngineSpec metadata in the engine spec uses `redshift.png` and the
`sqlalchemy-redshift` PyPI package, and the description string differs. These
expectations won't match the actual metadata.
##########
tests/unit_tests/db_engine_specs/test_kusto.py:
##########
@@ -224,3 +224,27 @@ def test_kql_execute_array_processing(raw_query: str,
expected_query: str) -> No
KustoKqlEngineSpec.execute(mock_cursor, raw_query, mock_db)
mock_cursor.execute.assert_called_once_with(expected_query)
+
+
+def test_kusto_properties() -> None:
+ from superset.db_engine_specs.kusto import KustoKqlEngineSpec,
KustoSqlEngineSpec
+
+ assert KustoSqlEngineSpec.engine == "kustosql"
+ assert KustoSqlEngineSpec.engine_name == "Azure Data Explorer (Kusto SQL)"
+ assert KustoKqlEngineSpec.engine == "kustokql"
+ assert KustoKqlEngineSpec.engine_name == "Azure Data Explorer (Kusto KQL)"
+
+
+def test_kusto_metadata() -> None:
+ from superset.db_engine_specs.kusto import KustoKqlEngineSpec,
KustoSqlEngineSpec
+
+ sql_meta = KustoSqlEngineSpec.metadata
+ assert "Azure Data Explorer" in sql_meta["description"]
+ assert sql_meta["logo"] == "azure.svg"
+ assert "sqlalchemy-kusto" in sql_meta["pypi_packages"]
+
+ kql_meta = KustoKqlEngineSpec.metadata
+ assert "Azure Data Explorer" in kql_meta["description"]
+ assert kql_meta["logo"] == "azure.svg"
+ assert "sqlalchemy-kusto" in kql_meta["pypi_packages"]
Review Comment:
Kusto SQL engine spec uses `engine_name = "Azure Data Explorer"` and
metadata `logo = "kusto.png"`. Kusto KQL engine spec uses `engine_name = "Azure
Data Explorer (KQL)"` and does not define metadata (inherits `{}`), so
asserting the more specific names and accessing metadata keys will fail.
##########
tests/unit_tests/db_engine_specs/test_db2.py:
##########
@@ -109,33 +109,14 @@ def test_get_prequeries(mocker: MockerFixture) -> None:
("grain", "expected_expression"),
[
(None, "my_col"),
- (
- TimeGrain.SECOND,
- "CAST(my_col as TIMESTAMP) - MICROSECOND(my_col) MICROSECONDS",
- ),
- (
- TimeGrain.MINUTE,
- "CAST(my_col as TIMESTAMP)"
- " - SECOND(my_col) SECONDS - MICROSECOND(my_col) MICROSECONDS",
- ),
- (
- TimeGrain.HOUR,
- "CAST(my_col as TIMESTAMP)"
- " - MINUTE(my_col) MINUTES"
- " - SECOND(my_col) SECONDS - MICROSECOND(my_col) MICROSECONDS ",
- ),
- (TimeGrain.DAY, "DATE(my_col)"),
- (TimeGrain.WEEK, "my_col - (DAYOFWEEK(my_col)) DAYS"),
- (TimeGrain.MONTH, "my_col - (DAY(my_col)-1) DAYS"),
- (
- TimeGrain.QUARTER,
- "my_col - (DAY(my_col)-1) DAYS"
- " - (MONTH(my_col)-1) MONTHS + ((QUARTER(my_col)-1) * 3) MONTHS",
- ),
- (
- TimeGrain.YEAR,
- "my_col - (DAY(my_col)-1) DAYS - (MONTH(my_col)-1) MONTHS",
- ),
+ (TimeGrain.SECOND, "DATE_TRUNC('SECOND', my_col)"),
+ (TimeGrain.MINUTE, "DATE_TRUNC('MINUTE', my_col)"),
+ (TimeGrain.HOUR, "DATE_TRUNC('HOUR', my_col)"),
+ (TimeGrain.DAY, "DATE_TRUNC('DAY', my_col)"),
+ (TimeGrain.WEEK, "DATE_TRUNC('WEEK', my_col)"),
+ (TimeGrain.MONTH, "DATE_TRUNC('MONTH', my_col)"),
+ (TimeGrain.QUARTER, "DATE_TRUNC('QUARTER', my_col)"),
+ (TimeGrain.YEAR, "DATE_TRUNC('YEAR', my_col)"),
],
)
def test_time_grain_expressions(grain: TimeGrain, expected_expression: str) ->
None:
Review Comment:
The parametrization includes `grain=None`, but the test signature types
`grain` as `TimeGrain`. This is an incorrect type annotation and can trip
static checks.
##########
tests/unit_tests/db_engine_specs/test_impala.py:
##########
@@ -172,3 +172,23 @@ def test_cancel_query_allows_internal_host_with_opt_out(
allow_redirects=False,
)
assert result is True
+
+
+def test_impala_properties() -> None:
+ from superset.db_engine_specs.impala import ImpalaEngineSpec
+
+ assert ImpalaEngineSpec.engine == "impala"
+ assert ImpalaEngineSpec.engine_name == "Apache Impala"
+ assert ImpalaEngineSpec.default_driver == "impala"
+ assert ImpalaEngineSpec.force_column_alias_quotes is True
+
Review Comment:
ImpalaEngineSpec does not override `default_driver` (defaults to `None`) and
does not set `force_column_alias_quotes` (defaults to `False` in
BaseEngineSpec). These assertions will fail.
##########
tests/unit_tests/db_engine_specs/test_hive.py:
##########
@@ -274,3 +274,23 @@ def test_spark_identifier_quote_uses_backticks() -> None:
"end": "`",
"escape_by_doubling": True,
}
+
+
+def test_hive_properties() -> None:
+ from superset.db_engine_specs.hive import HiveEngineSpec
+
+ assert HiveEngineSpec.engine == "hive"
+ assert HiveEngineSpec.engine_name == "Apache Hive"
+ assert HiveEngineSpec.default_driver == "pyhive"
+ assert HiveEngineSpec.max_column_name_length == 767
Review Comment:
HiveEngineSpec does not set `default_driver` (it inherits `None` from
BaseEngineSpec), and the engine spec metadata logo is `apache-hive.svg`, not
`hive.png`. These assertions will fail.
This issue also appears on line 291 of the same file.
##########
tests/unit_tests/db_engine_specs/test_impala.py:
##########
@@ -172,3 +172,23 @@ def test_cancel_query_allows_internal_host_with_opt_out(
allow_redirects=False,
)
assert result is True
+
+
+def test_impala_properties() -> None:
+ from superset.db_engine_specs.impala import ImpalaEngineSpec
+
+ assert ImpalaEngineSpec.engine == "impala"
+ assert ImpalaEngineSpec.engine_name == "Apache Impala"
+ assert ImpalaEngineSpec.default_driver == "impala"
+ assert ImpalaEngineSpec.force_column_alias_quotes is True
+
+
+def test_impala_metadata() -> None:
+ from superset.db_engine_specs.impala import ImpalaEngineSpec
+
+ metadata = ImpalaEngineSpec.metadata
+ assert "Apache Impala" in metadata["description"]
+ assert metadata["logo"] == "impala.png"
+ assert "impyla" in metadata["pypi_packages"]
+ assert metadata["default_port"] == 21050
Review Comment:
ImpalaEngineSpec metadata logo is `apache-impala.png` in the engine spec;
asserting `impala.png` will fail.
--
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]