Skip to content

6.1.0rc1 SQL comments in Custom SQL filters are stripped from generated queries #39169

@luizotavio32

Description

@luizotavio32

Bug Description

When users add SQL filters with comments in the Custom SQL filter tab, the comments are stripped when the query is generated and executed.

Expected Behavior

SQL comments should be preserved in the generated query, as they are used for:

  • Query hints and optimizer directives
  • Annotation metadata
  • Audit trail information

Actual Behavior

Comments are removed from the filter. For example:

  • Input: TRUE /* my_annotation*/
  • Generated WHERE clause: WHERE TRUE (comment is missing)

Steps to Reproduce

  1. Create or edit a chart in Explore
  2. Add a filter using the "Custom SQL" tab
  3. Enter a filter with a comment, e.g.: TRUE /* my_annotation */
  4. Save the filter and run the query
  5. Click the kebab menu → "View query"
  6. Observe that the comment is missing from the WHERE clause

Environment

  • Superset version: (all versions)
  • Browser: N/A (backend issue)

Additional Context

This affects teams that rely on SQL comments for query annotations or database-specific hints passed through filter expressions.

Screenshots/recordings

Screen.Recording.2026-04-07.at.14.44.34.mov

Superset version

6.0.0

Python version

3.10

Node version

16

Browser

Chrome

Additional context

No response

Checklist

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    explore:filterRelated to filters in Explore

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions