codeant-ai-for-open-source[bot] commented on code in PR #44627:
URL: https://github.com/apache/superset/pull/44627#discussion_r4099919224
##########
superset/db_engine_specs/databricks.py:
##########
@@ -246,6 +248,17 @@ class DatabricksBaseEngineSpec(BaseEngineSpec):
identifier_quote_start: str = "`"
identifier_quote_end: str = "`"
+ # Databricks SQL documents native MEDIAN/STDDEV_SAMP/VAR_SAMP aggregate
+ # functions (docs.databricks.com/aws/en/sql/language-manual/functions/
+ # {median,stddev_samp,var_samp}), confirmed against that reference, not a
+ # live Databricks instance. All three are plain function calls, same
+ # spelling as Postgres/DuckDB, so no dialect-specific rewriting is needed.
+ _extended_aggregations: dict[str, Callable[[ColumnElement],
ColumnElement]] = {
+ "MEDIAN": sa.func.median,
+ "STDDEV_SAMP": sa.func.stddev_samp,
+ "VAR_SAMP": sa.func.var_samp,
+ }
Review Comment:
**Suggestion:** This opts every Databricks connector into emitting these
aggregates without live-engine verification, so unsupported runtimes can fail
during query execution instead of returning Superset's supported error.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=aae0da205fd748b0a4db2620c1cef3fc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=aae0da205fd748b0a4db2620c1cef3fc&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/databricks.py
**Line:** 256:260
**Comment:**
*Api Mismatch: This opts every Databricks connector into emitting these
aggregates without live-engine verification, so unsupported runtimes can fail
during query execution instead of returning Superset's supported error.
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%2F44627&comment_hash=2e57805c97baf34a97ed82fb756303457005ee9ab20456d39c3687ea43b6b268&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44627&comment_hash=2e57805c97baf34a97ed82fb756303457005ee9ab20456d39c3687ea43b6b268&reaction=dislike'>๐</a>
##########
superset/db_engine_specs/databricks.py:
##########
@@ -986,6 +999,16 @@ class DatabricksHiveEngineSpec(HiveEngineSpec):
_time_grain_expressions = time_grain_expressions
+ # Interactive Clusters run Spark SQL, same as the primary Databricks
+ # connector above; same native MEDIAN/STDDEV_SAMP/VAR_SAMP functions
+ # apply here rather than the inherited (unimplemented) HiveEngineSpec/
+ # PrestoEngineSpec default.
+ _extended_aggregations: dict[str, Callable[[ColumnElement],
ColumnElement]] = {
+ "MEDIAN": sa.func.median,
+ "STDDEV_SAMP": sa.func.stddev_samp,
+ "VAR_SAMP": sa.func.var_samp,
+ }
Review Comment:
**Suggestion:** The legacy PyHive Interactive Cluster spec is enabled
without live verification, allowing the metric builder to generate aggregates
that some cluster versions may reject at execution time.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=de6afe3c0a68459b829c0650059eab08&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=de6afe3c0a68459b829c0650059eab08&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/databricks.py
**Line:** 1006:1010
**Comment:**
*Api Mismatch: The legacy PyHive Interactive Cluster spec is enabled
without live verification, allowing the metric builder to generate aggregates
that some cluster versions may reject at execution time.
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%2F44627&comment_hash=027ed2c3e86eb8bf189852f2855943ae026393d5f262476a720cfd9871a52a73&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44627&comment_hash=027ed2c3e86eb8bf189852f2855943ae026393d5f262476a720cfd9871a52a73&reaction=dislike'>๐</a>
##########
superset/db_engine_specs/snowflake.py:
##########
@@ -142,10 +143,19 @@ class SnowflakeEngineSpec(PostgresBaseEngineSpec):
force_column_alias_quotes = True
max_column_name_length = 256
- # `PostgresBaseEngineSpec._extended_aggregations`
(MEDIAN/STDDEV_SAMP/VAR_SAMP)
- # is verified against real Postgres behavior, not Snowflake's; disable it
here
- # until someone confirms the same expressions against a live Snowflake
instance.
- _extended_aggregations: dict[str, Callable[[ColumnElement],
ColumnElement]] = {}
+ # Snowflake documents native MEDIAN/STDDEV_SAMP/VAR_SAMP aggregate
functions
+ #
(docs.snowflake.com/en/sql-reference/functions/{median,stddev_samp,var_samp}),
+ # confirmed against that reference, not a live Snowflake instance.
STDDEV_SAMP/
+ # VAR_SAMP are plain function calls, same spelling as inherited from
+ # `PostgresBaseEngineSpec`, so those are reused directly. MEDIAN is
overridden:
+ # Snowflake's own `MEDIAN(x)` is a plain function call, unlike Postgres's
+ # `percentile_cont(0.5) WITHIN GROUP (ORDER BY x)` (Postgres has no native
+ # MEDIAN), so there is no reason to compile the more complex inherited
form.
+ _extended_aggregations: dict[str, Callable[[ColumnElement],
ColumnElement]] = {
+ "MEDIAN": sa.func.median,
+ "STDDEV_SAMP":
PostgresBaseEngineSpec._extended_aggregations["STDDEV_SAMP"],
+ "VAR_SAMP": PostgresBaseEngineSpec._extended_aggregations["VAR_SAMP"],
+ }
Review Comment:
**Suggestion:** This advertises Snowflake aggregates based only on
documentation, despite the engine-spec contract requiring live verification;
unsupported behavior now reaches execution instead of producing a validation
error.
**Assessment:** ๐ `Major` ยท ๐ `Occurrence: Rarely` ยท ๐ท๏ธ `Api mismatch`
[](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=02c2406a9acd44548babd327e1e40dc4&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=02c2406a9acd44548babd327e1e40dc4&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/snowflake.py
**Line:** 154:158
**Comment:**
*Api Mismatch: This advertises Snowflake aggregates based only on
documentation, despite the engine-spec contract requiring live verification;
unsupported behavior now reaches execution instead of producing a validation
error.
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%2F44627&comment_hash=b7b7f95edc65dd2e412023f203380ae1ed1cc54eaa7515f99baec8c91be7a527&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F44627&comment_hash=b7b7f95edc65dd2e412023f203380ae1ed1cc54eaa7515f99baec8c91be7a527&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]