liujiwen-up commented on code in PR #31580:
URL: https://github.com/apache/superset/pull/31580#discussion_r1899496428


##########
superset/db_engine_specs/doris.py:
##########
@@ -245,17 +248,47 @@ def adjust_engine_params(
         catalog: Optional[str] = None,
         schema: Optional[str] = None,
     ) -> tuple[URL, dict[str, Any]]:
-        database = uri.database
-        if schema and database:
-            schema = parse.quote(schema, safe="")
-            if "." in database:
-                database = database.split(".")[0] + "." + schema
-            else:
-                database = "internal." + schema
-            uri = uri.set(database=database)
-
+        if catalog:
+            pass
+        elif uri.database and "." in uri.database:
+            catalog, _ = uri.database.split(".", 1)
+        else:
+            catalog = "internal"
+
+        # In Apache Doris, each catalog has an information_schema for BI tool
+        # compatibility. See: https://github.com/apache/doris/pull/28919
+        if schema:
+            adjusted_database = ".".join([catalog or "", schema])
+        else:
+            adjusted_database = ".".join([catalog or "", "information_schema"])
+        uri = uri.set(database=adjusted_database)

Review Comment:
   @villebro 
   One more thing that comes to mind: is it really necessary to assign 
information_schema to the connection string if no schema is selected?
   This is necessary here. In Doris, there must be a schema to link correctly. 
Catalog is not necessary, but schema is necessary.
   When switching catalogs in the sqllab front-end interface, when you select a 
catalog, you don't know which schemas will be under the catalog. If there is no 
schema in the link string, an error will be reported. However, one thing is 
known: there is an information_schema library in each catalog, so using it to 
link to the search is a very good choice, which can ensure that every time you 
switch catalogs, it will succeed. After obtaining the schma list under the 
current catalog, users can select the corresponding schema to obtain all tables.



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