bito-code-review[bot] commented on code in PR #35420:
URL: https://github.com/apache/superset/pull/35420#discussion_r2395151843
##########
superset/sql/dialects/pinot.py:
##########
@@ -95,3 +101,8 @@ def datatype_sql(self, expression: exp.DataType) -> str:
return f"{type_sql} UNSIGNED{nested}"
return f"{type_sql}{nested}"
+
+ def cast_sql(self, expression: exp.Cast, safe_prefix: str | None =
None) -> str:
+ # Pinot doesn't support MySQL's TIMESTAMP() function
+ # Use standard CAST syntax instead
+ return super(MySQL.Generator, self).cast_sql(expression,
safe_prefix)
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>super() call syntax</b></div>
<div id="fix">
The cast_sql method uses incorrect super() syntax with explicit class
specification. This will cause method resolution issues in the inheritance
chain between Pinot.Generator and MySQL.Generator, potentially leading to
infinite recursion or incorrect CAST behavior. Fix by using modern Python 3
super() syntax.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```suggestion
return super().cast_sql(expression, safe_prefix)
```
</div>
</details>
</div>
<small><i>Code Review Run <a
href=https://github.com/apache/superset/pull/35420#issuecomment-3357113736>#ebb48d</a></i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
tests/unit_tests/sql/dialects/pinot_tests.py:
##########
@@ -421,3 +421,80 @@ def test_unsigned_type() -> None:
assert "UNSIGNED" in result
assert "BIGINT" in result
+
+
+def test_date_trunc_preserved() -> None:
+ """
+ Test that DATE_TRUNC is preserved and not converted to MySQL's DATE()
function.
+ """
+ sql = "SELECT DATE_TRUNC('day', dt_column) FROM table"
+ result = sqlglot.parse_one(sql, Pinot).sql(Pinot)
+
+ assert "DATE_TRUNC" in result
+ assert "DATE_TRUNC('day'" in result or "DATE_TRUNC('DAY'" in result
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Case-sensitive assertion issue</b></div>
<div id="fix">
The assertion on line 434 is too brittle and uses exact case-sensitive
string matching for 'DATE_TRUNC('day'' which may fail due to case variations in
SQLGlot's output. The test should use case-insensitive matching to handle
potential formatting differences. This affects the `test_date_trunc_preserved`
function and could cause false test failures in CI.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```suggestion
assert "DATE_TRUNC" in result
assert "date_trunc('day'" in result.lower()
```
</div>
</details>
</div>
<small><i>Code Review Run <a
href=https://github.com/apache/superset/pull/35420#issuecomment-3357113736>#ebb48d</a></i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]