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


##########
superset/dashboards/export_info.py:
##########
@@ -0,0 +1,101 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+"""Describe a dashboard export (title, permalink, filters, chart links)."""
+
+from __future__ import annotations
+
+from typing import Any
+
+from superset_core.exports.types import AppliedFilter, DashboardExportInfo
+
+from superset import security_manager
+from superset.commands.dashboard.exceptions import DashboardNotFoundError
+from superset.commands.dashboard.permalink.create import (
+    CreateDashboardPermalinkCommand,
+)
+from superset.daos.dashboard import DashboardDAO
+from superset.dashboards.excel_export.layout import get_charts_in_layout_order
+from superset.utils.urls import get_url_path
+
+
+def _is_empty(value: Any) -> bool:
+    return value is None or value == [] or value == ""
+
+
+def _display_value(filter_state: dict[str, Any]) -> str:
+    label = filter_state.get("label")
+    if isinstance(label, str) and label:
+        return label
+    value = filter_state["value"]
+    if isinstance(value, list):
+        return ", ".join(str(item) for item in value)
+    return str(value)
+
+
+def describe_dashboard_export(
+    dashboard_id: int, active_data_mask: dict[str, Any]
+) -> DashboardExportInfo:
+    """
+    Describe a dashboard export for an extension's "About" tab.
+
+    Raises DashboardNotFoundError for a missing dashboard and
+    SupersetSecurityException when the current user cannot access it.
+    """
+    dashboard = DashboardDAO.find_by_id(dashboard_id)
+    if dashboard is None:
+        raise DashboardNotFoundError(str(dashboard_id))
+    security_manager.raise_for_access(dashboard=dashboard)
+
+    key = CreateDashboardPermalinkCommand(
+        dashboard_id=str(dashboard_id), state={"dataMask": active_data_mask}
+    ).run()
+    permalink_url = get_url_path(
+        "Superset.dashboard_permalink", user_friendly=True, key=key
+    )
+
+    charts = get_charts_in_layout_order(dashboard)
+    native_names = {
+        config["id"]: config["name"]
+        for config in dashboard.params_dict.get("native_filter_configuration", 
[])
+        if "id" in config and "name" in config
+    }
+
+    applied_filters: list[AppliedFilter] = []
+    for filter_id in sorted(active_data_mask):

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `426d9dd`.
   
   When a filter ID is absent from `active_data_mask`, the loop now reads its 
`defaultDataMask` from the filter configuration and uses that state when 
building export metadata.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



##########
superset/charts/data/run_query_context.py:
##########
@@ -0,0 +1,177 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Host implementations of the `superset_core.exports` chart-query 
functions."""
+
+from __future__ import annotations
+
+from typing import Any
+
+import pandas as pd
+from marshmallow import ValidationError
+from superset_core.exports.types import ChartQueryResult, GenericDataType
+
+from superset import is_feature_enabled, security_manager
+from superset.charts.client_processing import apply_client_processing
+from superset.charts.schemas import ChartDataQueryContextSchema
+from superset.commands.chart.data.get_data_command import ChartDataCommand
+from superset.common.chart_data import ChartDataResultFormat, 
ChartDataResultType
+from superset.common.query_context_factory import QueryContextFactory
+from superset.daos.dashboard import DashboardDAO
+from superset.exceptions import SupersetSecurityException
+from superset.utils.core import extract_dataframe_dtypes
+
+# Result types whose queries return rows; the rest return SQL or metadata.
+ROW_RESULT_TYPES = frozenset(
+    {
+        ChartDataResultType.FULL,
+        ChartDataResultType.RESULTS,
+        ChartDataResultType.POST_PROCESSED,
+        ChartDataResultType.SAMPLES,
+        ChartDataResultType.DRILL_DETAIL,
+    }
+)
+
+# Header of the row-label column; blank, like the unnamed index in a CSV 
export.
+ROW_LABEL_COLUMN = ""
+
+
+def _requested_result_types(payload: dict[str, Any]) -> set[str]:
+    """Collect the context-level and per-query result types a payload asks 
for."""
+    requested = {str(payload.get("result_type") or ChartDataResultType.FULL)}
+    for query in payload.get("queries") or []:
+        if isinstance(query, dict) and query.get("result_type"):
+            requested.add(str(query["result_type"]))
+    return requested
+
+
+def _coltype(value: Any) -> GenericDataType:
+    """Map a host column type to the core enum; unknown types read as 
strings."""
+    try:
+        return GenericDataType(value)
+    except ValueError:
+        return GenericDataType.STRING
+
+
+def _flatten_label(label: Any) -> str:
+    """Join a hierarchical label the way client processing flattens tuples."""
+    if isinstance(label, tuple):
+        return " ".join(str(part) for part in label).strip()
+    return str(label)
+
+
+def post_processed_rows(query: dict[str, Any]) -> dict[str, Any]:
+    """
+    Return ``query`` with post-processed JSON data rebuilt as row records.
+
+    Client processing serializes its frame as ``{column: {row label: value}}``
+    and drops the index names, so the row labels become a leading
+    ``ROW_LABEL_COLUMN`` unless they are the default ``0..n-1`` positions.
+    ``colnames`` and ``coltypes`` are recomputed to describe the rows.
+    """
+    data = query.get("data")
+    if not isinstance(data, dict):
+        return query
+
+    df = pd.DataFrame.from_dict(data)
+    df.columns = [_flatten_label(column) for column in df.columns]
+    if df.index.tolist() == list(range(len(df))):
+        df = df.reset_index(drop=True)

Review Comment:
   ✅ **CodeAnt verified this suggestion was addressed in subsequent commits and 
marked this thread resolved** as of `426d9dd`.
   
   With `row_labels` enabled, the code now inserts every DataFrame index value 
into the leading `ROW_LABEL_COLUMN`, without filtering out numeric-looking 
labels.
   
   <sub>If that's not right, unresolve this thread and CodeAnt will leave it 
open.</sub>
   
   <!-- codeant-auto-resolve-reply -->



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

  • [PR] feat(c... orion222 (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... orion222 (via GitHub) via notifications
    • Re: [P... orion222 (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... orion222 (via GitHub) via notifications
    • Re: [P... codecov[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... codeant-ai-for-open-source[bot] (via GitHub) via notifications
    • Re: [P... orion222 (via GitHub) via notifications
    • Re: [P... orion222 (via GitHub) via notifications
    • Re: [P... netlify[bot] (via GitHub) via notifications

Reply via email to