betodealmeida commented on code in PR #34140:
URL: https://github.com/apache/superset/pull/34140#discussion_r2201952516


##########
tests/unit_tests/db_engine_specs/test_doris.py:
##########
@@ -81,56 +82,108 @@ def test_get_column_spec(
 
 
 @pytest.mark.parametrize(
-    "sqlalchemy_uri,connect_args,return_schema,return_connect_args",
+    "sqlalchemy_uri, connect_args, catalog, schema, 
return_schema,return_connect_args",
     [
         (
             "doris://user:password@host/db1",
             {"param1": "some_value"},
-            "internal.information_schema",
+            None,
+            None,
+            "db1",
             {"param1": "some_value"},
         ),
         (
             "pydoris://user:password@host/db1",
             {"param1": "some_value"},
-            "internal.information_schema",
+            None,
+            None,
+            "db1",
             {"param1": "some_value"},
         ),
         (
             "doris://user:password@host/catalog1.db1",
             {"param1": "some_value"},
-            "catalog1.information_schema",
+            None,
+            None,
+            "catalog1.db1",
             {"param1": "some_value"},
         ),
         (
             "pydoris://user:password@host/catalog1.db1",
             {"param1": "some_value"},
-            "catalog1.information_schema",
+            None,
+            None,
+            "catalog1.db1",
+            {"param1": "some_value"},
+        ),
+        (
+            "pydoris://user:password@host/catalog1.db1",
+            {"param1": "some_value"},
+            "catalog2",
+            None,
+            "catalog2.db1",
+            {"param1": "some_value"},
+        ),
+        (
+            "pydoris://user:password@host/catalog1.db1",
+            {"param1": "some_value"},
+            None,
+            "db2",
+            "catalog1.db2",
+            {"param1": "some_value"},
+        ),
+        (
+            "pydoris://user:password@host/catalog1.db1",
+            {"param1": "some_value"},
+            "catalog2",
+            "db2",
+            "catalog2.db2",
             {"param1": "some_value"},
         ),
     ],
 )
 def test_adjust_engine_params(
     sqlalchemy_uri: str,
     connect_args: dict[str, Any],
+    catalog: str | None,
+    schema: str | None,
     return_schema: str,
     return_connect_args: dict[str, Any],
 ) -> None:
     from superset.db_engine_specs.doris import DorisEngineSpec
 
     url = make_url(sqlalchemy_uri)
     returned_url, returned_connect_args = DorisEngineSpec.adjust_engine_params(
-        url, connect_args
+        url,
+        connect_args,
+        catalog,
+        schema,
     )
 
     assert returned_url.database == return_schema
     assert returned_connect_args == return_connect_args
 
 
+def test_adjust_engine_params_no_database() -> None:
+    """
+    Test that we raise an exception when the database is not specified.
+    """
+    from superset.db_engine_specs.doris import DorisEngineSpec
+
+    url = make_url("doris://user:password@host")
+    with pytest.raises(
+        ValueError,
+        match="Doris requires a database to be specified in the URI.",
+    ):
+        DorisEngineSpec.adjust_engine_params(url, {})
+
+
 @pytest.mark.parametrize(
     "url,expected_schema",
     [
         ("doris://localhost:9030/hive.test", "test"),
-        ("doris://localhost:9030/hive", None),

Review Comment:
   This is another test that was wrong. In Doris `hive` in this test would 
correspond to the schema, not to the catalog — the catalog is optional, not the 
schema.



-- 
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]

Reply via email to