mirror of
https://github.com/apache/superset.git
synced 2026-07-12 17:55:38 +00:00
fix: ODPS (MaxCompute) data source table preview failed (#38174)
Co-authored-by: zhutong6688 <zhutong66@163.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,6 +32,7 @@ from superset.sql.parse import (
|
||||
KQLTokenType,
|
||||
KustoKQLStatement,
|
||||
LimitMethod,
|
||||
Partition,
|
||||
process_jinja_sql,
|
||||
remove_quotes,
|
||||
RLSMethod,
|
||||
@@ -139,6 +140,41 @@ def test_table_qualify() -> None:
|
||||
assert qualified.catalog == table.catalog
|
||||
|
||||
|
||||
def test_partition() -> None:
|
||||
"""
|
||||
Test the `Partition` class and its string conversion.
|
||||
"""
|
||||
# Test partitioned table with partition columns
|
||||
partition = Partition(is_partitioned_table=True, partition_column=("col1", "col2"))
|
||||
assert partition.is_partitioned_table is True
|
||||
assert partition.partition_column == ("col1", "col2")
|
||||
assert (
|
||||
str(partition)
|
||||
== "Partition(is_partitioned_table=True, partition_column=[col1, col2])"
|
||||
)
|
||||
|
||||
# Test non-partitioned table
|
||||
partition_none = Partition(is_partitioned_table=False, partition_column=None)
|
||||
assert partition_none.is_partitioned_table is False
|
||||
assert partition_none.partition_column is None
|
||||
assert (
|
||||
str(partition_none)
|
||||
== "Partition(is_partitioned_table=False, partition_column=[None])"
|
||||
)
|
||||
|
||||
# Test equality
|
||||
partition1 = Partition(is_partitioned_table=True, partition_column=("col1",))
|
||||
partition2 = Partition(is_partitioned_table=True, partition_column=("col1",))
|
||||
partition3 = Partition(is_partitioned_table=True, partition_column=("col2",))
|
||||
assert partition1 == partition2
|
||||
assert partition1 != partition3
|
||||
|
||||
# A frozen dataclass with a tuple field must be hashable (a list field would
|
||||
# raise TypeError: unhashable type at hash time).
|
||||
assert hash(partition1) == hash(partition2)
|
||||
assert len({partition1, partition2, partition3}) == 2
|
||||
|
||||
|
||||
def extract_tables_from_sql(sql: str, engine: str = "postgresql") -> set[Table]:
|
||||
"""
|
||||
Helper function to extract tables from SQL.
|
||||
|
||||
Reference in New Issue
Block a user