korbit-ai[bot] commented on code in PR #32310:
URL: https://github.com/apache/superset/pull/32310#discussion_r1961843257


##########
superset/db_engine_specs/base.py:
##########
@@ -1689,7 +1689,11 @@ def select_star(  # pylint: disable=too-many-arguments
 
         full_table_name = cls.quote_table(table, engine.dialect)
         qry = select(fields).select_from(text(full_table_name))
-
+        if database.backend == 'odps':
+            if partition.ispartitioned_table and partition.partition_column is 
not None and len(partition.partition_column) > 0:
+                partition_str = partition.partition_column[0]
+                partition_str_where = f"CAST({partition_str} AS STRING) LIKE 
'%'"
+                qry = qry.where(text(partition_str_where))

Review Comment:
   ### Undefined partition variable in ODPS preview logic <sub>![category 
Functionality](https://img.shields.io/badge/Functionality-0284c7)</sub>
   
   <details>
     <summary>Tell me more</summary>
   
   ###### What is the issue?
   The code attempts to use an undefined 'partition' variable which would cause 
a NameError when executing select_star for ODPS backend.
   
   ###### Why this matters
   This will cause the preview functionality to fail for all ODPS tables, not 
just partitioned ones, preventing users from viewing any table data.
   
   ###### Suggested change ∙ *Feature Preview*
   The partition parameter needs to be passed to the select_star method and 
used in the ODPS-specific logic. Add a 'partition' parameter to the method 
signature and use it in the ODPS condition:
   ```python
   @classmethod
   def select_star(  # pylint: disable=too-many-arguments
       cls,
       database: Database,
       table: Table,
       engine: Engine,
       limit: int = 100,
       show_cols: bool = False,
       indent: bool = True,
       latest_partition: bool = True,
       cols: list[ResultSetColumnType] | None = None,
       partition: Partition | None = None,
   ) -> str:
       ...
       if database.backend == 'odps' and partition:
           if partition.ispartitioned_table and partition.partition_column is 
not None and len(partition.partition_column) > 0:
               partition_str = partition.partition_column[0]
               partition_str_where = f"CAST({partition_str} AS STRING) LIKE '%'"
               qry = qry.where(text(partition_str_where))
   ```
   
   
   </details>
   
   <sub>
   
   [![Report a problem with this 
comment](https://img.shields.io/badge/Report%20a%20problem%20with%20this%20comment-gray.svg?logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiNmNWVjMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0ibHVjaWRlIGx1Y2lkZS10cmlhbmdsZS1hbGVydCI+PHBhdGggZD0ibTIxLjczIDE4LTgtMTRhMiAyIDAgMCAwLTMuNDggMGwtOCAxNEEyIDIgMCAwIDAgNCAyMWgxNmEyIDIgMCAwIDAgMS43My0zIi8+PHBhdGggZD0iTTEyIDl2NCIvPjxwYXRoIGQ9Ik0xMiAxN2guMDEiLz48L3N2Zz4=)](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/a13e9991-debe-485f-9de9-4ff0001c4edd?suggestedFixEnabled=true)
   
   💬 Chat with Korbit by mentioning @korbit-ai.
   </sub>
   
   <!--- korbi internal id:78a81700-ab28-49bc-9852-442b7e06ed77 -->
   



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