codeant-ai-for-open-source[bot] commented on code in PR #44279:
URL: https://github.com/apache/superset/pull/44279#discussion_r4286797813
##########
superset/db_engine_specs/druid.py:
##########
@@ -40,14 +50,54 @@
_DRUID_FLOAT_SPECIAL = frozenset({"NaN", "Infinity", "-Infinity"})
-class DruidEngineSpec(BaseEngineSpec):
+class DruidParametersSchema(Schema):
+ """
+ Parameters for the dynamic connection form.
+
+ Druid connects over a fixed SQL endpoint (`/druid/v2/sql/`), so the schema
+ intentionally omits the ``database`` field. The ``encryption`` toggle
selects
+ the http vs. https pydruid dialect rather than adding a query parameter.
+ """
+
+ username = fields.String(allow_none=True, metadata={"description":
__("Username")})
+ password = fields.String(allow_none=True, metadata={"description":
__("Password")})
+ host = fields.String(
+ required=True, metadata={"description": __("Hostname or IP address")}
+ )
+ port = fields.Integer(
+ required=True,
+ metadata={"description": __("Database port")},
+ validate=Range(min=0, max=2**16, max_inclusive=False),
+ )
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `609cd6b`.
Added a default Druid broker port and use it when the parsed URI has no
explicit port, so the required form field receives an integer.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/db_engine_specs/druid.py:
##########
@@ -162,6 +212,44 @@ def alter_new_orm_column(cls, orm_col: TableColumn) ->
None:
if orm_col.column_name == "__time":
orm_col.is_dttm = True
+ @classmethod
+ def build_sqlalchemy_uri(
+ cls,
+ parameters: BasicParametersType,
+ encrypted_extra: dict[str, str] | None = None,
+ ) -> str:
+ query = parameters.get("query", {}).copy()
+ # `druid+https` selects pydruid's TLS dialect; the bare `druid` driver
+ # connects over plain HTTP.
+ driver = "https" if parameters.get("encryption") else
cls.default_driver
+
+ # SQLAlchemy 2.0 hides the password from `URL.__str__()`, so render it
+ # explicitly since this URI is used to connect, not just displayed.
+ return URL.create(
+ f"{cls.engine}+{driver}".rstrip("+"),
+ username=parameters.get("username"),
+ password=parameters.get("password"),
+ host=parameters["host"],
+ port=parameters["port"],
+ database=cls.sqlalchemy_uri_database,
+ query=query,
+ ).render_as_string(hide_password=False)
+
+ @classmethod
+ def get_parameters_from_uri(
+ cls, uri: str, encrypted_extra: dict[str, Any] | None = None
+ ) -> BasicParametersType:
+ url = make_url_safe(uri)
+ return BasicParametersType(
+ username=url.username,
+ password=url.password,
+ host=url.host,
+ port=url.port,
+ database=url.database or cls.sqlalchemy_uri_database,
+ query=dict(url.query),
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `609cd6b`.
Set the schema’s unknown-field handling to `EXCLUDE`, so the returned
`database` value is ignored during form validation.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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]