MCPcopy Index your code
hub / github.com/apache/superset / strip_comments_from_sql

Function strip_comments_from_sql

superset/sql_parse.py:68–78  ·  view source on GitHub ↗

Strips comments from a SQL statement, does a simple test first to avoid always instantiating the expensive ParsedQuery constructor This is useful for engines that don't support comments :param statement: A string with the SQL statement :return: SQL statement without comments

(statement: str)

Source from the content-addressed store, hash-verified

66
67
68def strip_comments_from_sql(statement: str) -> str:
69 """
70 Strips comments from a SQL statement, does a simple test first
71 to avoid always instantiating the expensive ParsedQuery constructor
72
73 This is useful for engines that don't support comments
74
75 :param statement: A string with the SQL statement
76 :return: SQL statement without comments
77 """
78 return ParsedQuery(statement).strip_comments() if "--" in statement else statement
79
80
81@dataclass(eq=True, frozen=True)

Callers 1

Calls 2

ParsedQueryClass · 0.85
strip_commentsMethod · 0.80

Tested by 1