Copilot commented on code in PR #44627:
URL: https://github.com/apache/superset/pull/44627#discussion_r4101366677
##########
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:
The base-class contract requires every `_extended_aggregations` entry to be
verified against real engine behavior, explicitly because matching syntax does
not establish correct semantics. These Databricks entries are enabled solely
from vendor documentation, so they bypass that invariant; either perform live
verification before opting in or make the verification policy change explicit
and update the negative tests/documentation consistently.
##########
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;
Review Comment:
This panel reads `database.extended_aggregations`, but the checked-in
`docs/src/data/databases.json` entries for Databricks and Snowflake contain no
such field, so the panel is absent from the published docs. The generator's AST
fallback also does not extract `_extended_aggregations`; add this field to the
fallback/committed data (or otherwise make generation preserve it) before
relying on this UI.
##########
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:
The base-class contract requires every `_extended_aggregations` entry to be
verified against real engine behavior, explicitly because matching syntax does
not establish correct semantics. This map is enabled solely from Snowflake
documentation, so it bypasses that invariant; either perform live verification
before opting in or make the verification policy change explicit and update the
negative tests/documentation consistently.
--
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]