codeant-ai-for-open-source[bot] commented on code in PR #44627:
URL: https://github.com/apache/superset/pull/44627#discussion_r4099942583
##########
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:
✅ **Customized review instruction saved!**
**Instruction:**
> For Databricks aggregate support, documentation verification is
sufficient; do not require live-engine verification before enabling documented
native functions.
**Applied to:**
- `superset/db_engine_specs/databricks.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
##########
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:
✅ **Customized review instruction saved!**
**Instruction:**
> For Databricks Interactive Cluster specs, rely on documented Spark SQL
aggregate support even without live-cluster verification; retain explicit
functions so unsupported cases fail clearly rather than falling back to
unimplemented defaults.
**Applied to:**
- `superset/db_engine_specs/databricks.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
##########
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:
✅ **Customized review instruction saved!**
**Instruction:**
> Allow Snowflake aggregate support to be enabled based on verification
against Snowflake's official function reference; do not require live-instance
verification for this engine spec.
**Applied to:**
- `superset/db_engine_specs/snowflake.py`
---
💡 *To manage or update this instruction, visit: [CodeAnt AI
Settings](https://app.codeant.ai/org/settings/learnings)*
--
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]