rusackas commented on code in PR #44627:
URL: https://github.com/apache/superset/pull/44627#discussion_r4113884503


##########
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:
   Same basis as the other threads here: doc-verified against the function 
reference, not live. Matches how Redshift's own override already ships here, 
tracking live verification as a follow-up rather than blocking on it.



##########
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:
   Same basis as the other threads here: doc-verified against Snowflake's 
function reference, not live. `SnowflakeEngineSpec` was disabled outright 
before this PR for exactly this reason, so it's a deliberate opt-in, not an 
oversight.



##########
docs/src/components/databases/DatabasePage.tsx:
##########
@@ -492,6 +492,30 @@ const DatabasePage: React.FC<DatabasePageProps> = ({ 
database, name }) => {
     );
   };
 
+  // Render extended aggregate function support (MEDIAN/STDDEV_SAMP/VAR_SAMP)
+  const renderExtendedAggregations = () => {
+    const aggregations = database.extended_aggregations;
+    if (!aggregations || Object.keys(aggregations).length === 0) return null;
+
+    return (
+      <Card title="Extended Aggregate Functions" style={{ marginBottom: 16 }}>
+        <Text type="secondary" style={{ display: 'block', marginBottom: 8 }}>
+          The base aggregates (SUM, COUNT, AVG, MIN, MAX, COUNT DISTINCT) are
+          supported everywhere; these are opt-in per engine.

Review Comment:
   This docs site doesn't have i18n wired up anywhere, none of the other cards 
on this page use a translation helper, so singling this one out would be 
inconsistent.



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