ramana-pb opened a new issue, #37626:
URL: https://github.com/apache/superset/issues/37626

   ### Bug description
   
   Description
   
   We are experiencing an issue in Apache Superset where custom SQL defined 
inside a metric is automatically modified after saving, causing incorrect 
results.
   
   Specifically, whitespace inside string literals is removed, which changes 
the logic of the condition and leads to filters becoming inactive or returning 
incorrect values.
   
   Example
   
   Original metric SQL:
   
   COUNT(
     DISTINCT CASE
       WHEN type = 'Internal'
         AND "Days B/W A and S" = '1 Day (Same day)'
         AND sourcetype = 'Cheque'
       THEN CONCAT("ID", '-', title)
     END
   )
   
   
   After saving the chart (or sometimes after editing/reopening), Superset 
automatically changes the string literal to:
   
   '1 Day(Same day)'
   
   
   Notice the space between Day and (Same day) is removed.
   
   Actual Behavior
   
   Superset alters the SQL inside the metric without user input.
   
   Whitespace inside string values is removed.
   
   As a result:
   
   The condition no longer matches the actual column value.
   
   Filters become inactive.
   
   Metric values change unexpectedly.
   
   Expected Behavior
   
   Superset should preserve the custom SQL exactly as written, especially 
string literals.
   
   No automatic formatting or modification should occur that changes query 
semantics.
   
   Impact
   
   Incorrect metric calculations
   
   Inconsistent dashboard results
   
   Hard-to-detect data issues after saving or reloading charts
   
   Frequency
   
   Occurs intermittently after saving or editing charts/metrics.
   
   Workarounds Tried
   
   Re-editing and re-saving the metric manually
   
   Replacing the condition with alternative logic
   (Neither provides a reliable long-term fix.)
   
   ### Screenshots/recordings
   
   _No response_
   
   ### Superset version
   
   master / latest-dev
   
   ### Python version
   
   3.9
   
   ### Node version
   
   16
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   Using Superset Version 4.1.1
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [ ] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


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