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


##########
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 is appropriate because it ensures consistent handling of 
column metadata. Using `col.get("name")` provides a safe, uniform approach to 
accessing the column identifier, avoiding the inconsistency of mixing a guarded 
`get` for the alias with an unguarded dictionary access for the name.
   
   **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