bito-code-review[bot] commented on code in PR #44703:
URL: https://github.com/apache/superset/pull/44703#discussion_r4129938696


##########
superset/db_engine_specs/elasticsearch.py:
##########
@@ -75,19 +82,19 @@ def _fetch_page_via_cursor(
         r"\s+LIMIT\s+\d+\s*$", "", sanitized_sql, flags=re.IGNORECASE
     )
 
-    # The raw transport does not auto-set Content-Type the way the Python
-    # DB-API driver does; ES rejects POSTs without a JSON content type.
-    json_headers = {"Content-Type": "application/json"}
+    request_kwargs: dict[str, Any] = {"headers": headers} if headers else {}
     with database.get_raw_connection() as conn:
         transport = conn.es.transport
         response = transport.perform_request(
             "POST",
             sql_path,
-            headers=json_headers,
             body={"query": sanitized_sql, "fetch_size": page_size},
+            **request_kwargs,
         )
-        columns = [col["name"] for col in response.get("columns", [])]
-        rows = response.get("rows", [])
+        columns = [
+            col.get("alias") or col["name"] for col in 
response.get(columns_key, [])
+        ]

Review Comment:
   <!-- Bito Reply -->
   The suggestion to use `col.get("name")` is appropriate because it provides a 
consistent and safe way to access column metadata. By using `get`, the code 
avoids potential `KeyError` exceptions if the `name` key is missing from the 
external service response, ensuring more robust handling of the column payload.
   
   **superset/db_engine_specs/elasticsearch.py**
   ```
   columns = [
               col.get("name") for col in response.get(columns_key, [])
           ]
   ```



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