bito-code-review[bot] commented on code in PR #35540:
URL: https://github.com/apache/superset/pull/35540#discussion_r2408934864


##########
superset/models/core.py:
##########
@@ -833,17 +833,17 @@ def select_star(  # pylint: disable=too-many-arguments
         cols: list[ResultSetColumnType] | None = None,
     ) -> str:
         """Generates a ``select *`` statement in the proper dialect"""
-        with self.get_sqla_engine(catalog=table.catalog, schema=table.schema) 
as engine:
-            return self.db_engine_spec.select_star(
-                self,
-                table,
-                engine=engine,
-                limit=limit,
-                show_cols=show_cols,
-                indent=indent,
-                latest_partition=latest_partition,
-                cols=cols,
-            )
+        dialect = self.get_dialect()
+        return self.db_engine_spec.select_star(
+            self,
+            table,
+            dialect=dialect,
+            limit=limit,
+            show_cols=show_cols,
+            indent=indent,
+            latest_partition=latest_partition,
+            cols=cols,
+        )

Review Comment:
   
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Connection resource leak</b></div>
   <div id="fix">
   
   The change from using the engine context manager to direct dialect creation 
breaks connection management and resource handling. The original code properly 
managed database connections via context manager, while the new code creates a 
dialect instance without connection management. This could lead to connection 
leaks and resource exhaustion in production. Restore the context manager usage 
and use `dialect=engine.dialect` to match the expected signature while 
maintaining proper resource management.
   </div>
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ```suggestion
           with self.get_sqla_engine(catalog=table.catalog, 
schema=table.schema) as engine:
               return self.db_engine_spec.select_star(
                   self,
                   table,
                   dialect=engine.dialect,
                   limit=limit,
                   show_cols=show_cols,
                   indent=indent,
                   latest_partition=latest_partition,
                   cols=cols,
               )
   ```
   
   </div>
   </details>
   </div>
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/35540#issuecomment-3374557317>#7de252</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]

Reply via email to