codeant-ai-for-open-source[bot] commented on code in PR #44279:
URL: https://github.com/apache/superset/pull/44279#discussion_r4012218861


##########
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:
   **Suggestion:** Existing Druid URIs without an explicit port produce 
`port=None`, but this required field rejects that value and prevents those 
connections from being edited through the dynamic form. [api mismatch]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=62634a07213c47bf892937b94caaa447&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=62634a07213c47bf892937b94caaa447&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/druid.py
   **Line:** 67:71
   **Comment:**
        *Api Mismatch: Existing Druid URIs without an explicit port produce 
`port=None`, but this required field rejects that value and prevents those 
connections from being edited through the dynamic form.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44279&comment_hash=0ad0e4e7f2fa9c6c30623e53f375ec88efc49ac68747f5974cc82fe69e88d838&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44279&comment_hash=0ad0e4e7f2fa9c6c30623e53f375ec88efc49ac68747f5974cc82fe69e88d838&reaction=dislike'>๐Ÿ‘Ž</a>



##########
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:
   **Suggestion:** `database` is returned even though `DruidParametersSchema` 
does not define it, so editing an existing dynamic-form connection fails 
Marshmallow validation on this unknown field. [api mismatch]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Often`
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=ba5000074ca94add91d20f1f24590964&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=ba5000074ca94add91d20f1f24590964&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent ๐Ÿค– </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/druid.py
   **Line:** 249:249
   **Comment:**
        *Api Mismatch: `database` is returned even though 
`DruidParametersSchema` does not define it, so editing an existing dynamic-form 
connection fails Marshmallow validation on this unknown field.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44279&comment_hash=67c3587b1076b3e5bda208d5bcf1dc021aa0b6ccd972aa30673575546541dc17&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44279&comment_hash=67c3587b1076b3e5bda208d5bcf1dc021aa0b6ccd972aa30673575546541dc17&reaction=dislike'>๐Ÿ‘Ž</a>



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