EnxDev commented on code in PR #44721:
URL: https://github.com/apache/superset/pull/44721#discussion_r4141741880


##########
superset/db_engine_specs/exasol.py:
##########
@@ -85,6 +133,29 @@ class ExasolEngineSpec(BaseEngineSpec):  # pylint: 
disable=abstract-method
         TimeGrain.YEAR: "DATE_TRUNC('year', {col})",
     }
 
+    @classmethod
+    def _extract_error_message(cls, ex: Exception) -> str:
+        """Extract the server diagnostic without driver-echoed SQL."""
+        message = super()._extract_error_message(ex)
+        # Strip SQL before looking for a verbose message field: SQL literals
+        # can themselves contain text resembling a driver envelope.
+        message = re.split(
+            r"(?m)^[ \t]*(?:query[ \t]*=>|\[SQL:|\[parameters:)",
+            message,
+            maxsplit=1,
+        )[0]
+        if match := re.search(r"(?m)^[ \t]*message[ \t]*=>[ \t]*", message):
+            # PyExasol prints the message first, then its fixed 
connection/query
+            # fields. Only those field names end the message, so a diagnostic
+            # line that itself contains ``=>`` is kept.
+            message = re.split(
+                r"(?m)^[ \t]*(?:(?:dsn|user|schema|session_id|code|query)[ 
\t]*=>"
+                r"|\)[ \t]*$)",
+                message[match.end() :],
+                maxsplit=1,
+            )[0]
+        return message.strip()

Review Comment:
   When the `message =>` field is empty, this returns `''`. So the user gets a 
blank error, where before they'd at least see the envelope with `code => 42000`.
   
   Falling back to the SQL-stripped text keeps the code and still drops the 
query (your 79 tests pass with it):
   
   ```suggestion
               diagnostic = re.split(
                   r"(?m)^[ \t]*(?:(?:dsn|user|schema|session_id|code|query)[ 
\t]*=>"
                   r"|\)[ \t]*$)",
                   message[match.end() :],
                   maxsplit=1,
               )[0].strip()
               if diagnostic:
                   return diagnostic
           return message.strip()
   ```



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