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></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>
[](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]