rusackas commented on code in PR #42733:
URL: https://github.com/apache/superset/pull/42733#discussion_r3740356497
##########
tests/unit_tests/sql/parse_tests.py:
##########
@@ -938,6 +938,54 @@ def test_sqlscript() -> None:
assert query.get_settings() == {"querytrace": True}
+def test_sqlscript_format_preserves_optimizer_hint_block() -> None:
+ """
+ Regression for #38189: an inline `--` comment trailing a query with a
+ `/*+ SET_VAR(...) */` optimizer hint must not get repositioned inside
+ the hint block during `format()` -- that would corrupt the hint syntax
+ (StarRocks and other engines using the `/*+ ... */` convention reject
+ a nested `/* */` inside it). `format()` is what Superset's execution
+ path actually sends to the engine (see `executor.py`/`celery_task.py`).
+ """
+ sql = """SELECT /*+ SET_VAR(query_timeout = 3000) */ col1, col2
+FROM my_table
+LIMIT 100
+
+-- increase timeout for large scans"""
+ statement = SQLScript(sql, "starrocks").statements[0]
+ formatted = statement.format()
+
+ assert "/*+ SET_VAR(query_timeout = 3000) */" in formatted
+ assert "SET_VAR(query_timeout /*" not in formatted
Review Comment:
Good point, tightened the oracle to assert the trailing comment survives
outside the hint block rather than just checking for the absence of the
corruption string. Applied to both the passing and xfail cases.
--
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]