fix: ODPS (MaxCompute) data source table preview failed

When using the ODPS (MaxCompute) data source, previewing partitioned
tables in SQLLab would fail because ODPS requires a partition to be
specified for partition tables.

This PR adds ODPS-specific handling:
- New OdpsEngineSpec with partition detection support
- Modified select_star to add partition filter for ODPS partition tables
- New Partition dataclass in sql/parse.py
- New is_odps_partitioned_table method in DatabaseDAO

Closes #32301

Co-Authored-By: zhutong6688 <zhutong66@163.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Evan Rusackas
2026-02-22 20:27:37 -08:00
committed by Claude Code
parent ffe60bd960
commit a1bf361fe2
8 changed files with 284 additions and 6 deletions

View File

@@ -322,6 +322,37 @@ class Table:
)
@dataclass(eq=True, frozen=True)
class Partition:
"""
Partition object, with two attribute keys:
ispartitioned_table and partition_comlumn,
used to provide partition information
Here is an example of an object:
{"ispartitioned_table":true,"partition_column":["month","day"]}
"""
is_partitioned_table: bool
partition_column: list[str] | None = None
def __str__(self) -> str:
"""
Return the partition columns of table name.
"""
partition_column_str = (
", ".join(map(str, self.partition_column))
if self.partition_column
else "None"
)
return (
f"Partition(is_partitioned_table={self.is_partitioned_table}, "
f"partition_column=[{partition_column_str}])"
)
def __eq__(self, other: Any) -> bool:
return str(self) == str(other)
# To avoid unnecessary parsing/formatting of queries, the statement has the concept of
# an "internal representation", which is the AST of the SQL statement. For most of the
# engines supported by Superset this is `sqlglot.exp.Expression`, but there is a special