codeant-ai-for-open-source[bot] commented on code in PR #25176:
URL: https://github.com/apache/superset/pull/25176#discussion_r2633778173


##########
superset/db_engine_specs/seqslab.py:
##########
@@ -0,0 +1,56 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""
+Superset db engine specs for SeqsLab
+"""
+from superset.db_engine_specs import BaseEngineSpec
+from superset.db_engine_specs.hive import HiveEngineSpec
+from superset.exceptions import SupersetException
+from superset import sql_parse
+
+
+class SeqsLabHiveEngineSpec(HiveEngineSpec):
+    engine_name = "Atgenomix SeqsLab Interactive Job"
+
+    engine = "seqslab"
+    drivers = {"hive": "Hive driver for SeqsLab interactive job"}
+    default_driver = "hive"
+
+    _show_functions_column = "function"
+
+    _time_grain_expressions = {
+        None: "{col}",
+        "PT1S": "date_trunc('second', {col})",
+        "PT1M": "date_trunc('minute', {col})",
+        "PT1H": "date_trunc('hour', {col})",
+        "P1D": "date_trunc('day', {col})",
+        "P1W": "date_trunc('week', {col})",
+        "P1M": "date_trunc('month', {col})",
+        "P3M": "date_trunc('quarter', {col})",
+        "P1Y": "date_trunc('year', {col})",
+        "P1W/1970-01-03T00:00:00Z": "date_trunc('week', {col} + interval '1 
day') + interval '5 days'",
+        "1969-12-28T00:00:00Z/P1W": "date_trunc('week', {col} + interval '1 
day') - interval '1 day'",
+    }
+
+    @staticmethod
+    def execute(  # type: ignore
+        cursor, query: str, **kwargs
+    ):  # pylint: disable=arguments-differ
+        if not BaseEngineSpec.is_readonly_query(sql_parse.ParsedQuery(query)):

Review Comment:
   **Suggestion:** The read-only check inside `execute` calls 
`BaseEngineSpec.is_readonly_query(sql_parse.ParsedQuery(query))`, but 
`BaseEngineSpec` has no `is_readonly_query` method and there is no 
`ParsedQuery` symbol elsewhere in the codebase, so this will raise an 
AttributeError as soon as the method is invoked; replace it with a local DML 
keyword check on the SQL string to enforce read-only behavior without relying 
on non-existent helpers. [logic error]
   
   **Severity Level:** Minor ⚠️
   ```suggestion
           lowered_query = query.lower()
           dml_keywords = (
               "insert ",
               "update ",
               "delete ",
               "merge ",
               "create ",
               "alter ",
               "drop ",
               "truncate ",
           )
           if any(keyword in lowered_query for keyword in dml_keywords):
   ```
   <details>
   <summary><b>Why it matters? ⭐ </b></summary>
   
   I checked the codebase: there is no BaseEngineSpec.is_readonly_query and no 
ParsedQuery symbol (grep returned no matches). That means the current code will 
raise an AttributeError or NameError at runtime when execute() is invoked. 
Replacing the call with a simple, local DML keyword check fixes an actual 
runtime error and enforces the stated read-only policy without relying on 
non-existent helpers. This is a real bug fix, not a cosmetic suggestion.
   </details>
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset/db_engine_specs/seqslab.py
   **Line:** 54:54
   **Comment:**
        *Logic Error: The read-only check inside `execute` calls 
`BaseEngineSpec.is_readonly_query(sql_parse.ParsedQuery(query))`, but 
`BaseEngineSpec` has no `is_readonly_query` method and there is no 
`ParsedQuery` symbol elsewhere in the codebase, so this will raise an 
AttributeError as soon as the method is invoked; replace it with a local DML 
keyword check on the SQL string to enforce read-only behavior without relying 
on non-existent helpers.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   ```
   </details>



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