mirror of
https://github.com/apache/superset.git
synced 2026-04-18 23:55:00 +00:00
fix(redshift): normalize table names to lowercase for CSV uploads (#37019)
This commit is contained in:
@@ -20,6 +20,7 @@ from typing import Optional
|
||||
|
||||
import pytest
|
||||
|
||||
from superset.db_engine_specs.redshift import RedshiftEngineSpec
|
||||
from tests.unit_tests.db_engine_specs.utils import assert_convert_dttm
|
||||
from tests.unit_tests.fixtures.common import dttm # noqa: F401
|
||||
|
||||
@@ -49,3 +50,32 @@ def test_convert_dttm(
|
||||
)
|
||||
|
||||
assert_convert_dttm(spec, target_type, expected_result, dttm)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"table_name,schema_name,expected_table,expected_schema",
|
||||
[
|
||||
("BPO_mytest_2", "MySchema", "bpo_mytest_2", "myschema"),
|
||||
("MY_TABLE", None, "my_table", None),
|
||||
("already_lower", "lower_schema", "already_lower", "lower_schema"),
|
||||
],
|
||||
)
|
||||
def test_normalize_table_name_for_upload(
|
||||
table_name: str,
|
||||
schema_name: Optional[str],
|
||||
expected_table: str,
|
||||
expected_schema: Optional[str],
|
||||
) -> None:
|
||||
"""
|
||||
Test that table and schema names are normalized to lowercase for Redshift.
|
||||
|
||||
Redshift folds unquoted identifiers to lowercase, so we need to normalize
|
||||
table names to ensure consistent behavior when checking table existence
|
||||
and performing replace operations.
|
||||
"""
|
||||
normalized_table, normalized_schema = (
|
||||
RedshiftEngineSpec.normalize_table_name_for_upload(table_name, schema_name)
|
||||
)
|
||||
|
||||
assert normalized_table == expected_table
|
||||
assert normalized_schema == expected_schema
|
||||
|
||||
Reference in New Issue
Block a user