@@ -1750,7 +1750,7 @@ def test_translate_column_names_missing_column_match_explicit_null() -> None:
1750
1750
)
1751
1751
1752
1752
# Translate column names
1753
- translated_expr = translate_column_names (bound_expr , file_schema , case_sensitive = True , projected_field_values = {2 : None })
1753
+ translated_expr = translate_column_names (bound_expr , file_schema , projected_field_values = {2 : None })
1754
1754
1755
1755
# Should evaluate to AlwaysTrue because the missing column is treated as null
1756
1756
# missing_col's default initial_default (None) satisfies the IsNull predicate
@@ -1828,12 +1828,7 @@ def test_translate_column_names_missing_column_with_projected_field_matches() ->
1828
1828
)
1829
1829
1830
1830
# Projected column that is missing in the file schema
1831
- projected_field_values = {2 : 42 }
1832
-
1833
- # Translate column names
1834
- translated_expr = translate_column_names (
1835
- bound_expr , file_schema , case_sensitive = True , projected_field_values = projected_field_values
1836
- )
1831
+ translated_expr = translate_column_names (bound_expr , file_schema , projected_field_values = {2 : 42 })
1837
1832
1838
1833
# Should evaluate to AlwaysTrue since projected field value matches the expression literal
1839
1834
# even though the field is missing in the file schema
@@ -1860,18 +1855,13 @@ def test_translate_column_names_missing_column_with_projected_field_mismatch() -
1860
1855
)
1861
1856
1862
1857
# Projected column that is missing in the file schema
1863
- projected_field_values = {2 : 1 }
1864
-
1865
- # Translate column names
1866
- translated_expr = translate_column_names (
1867
- bound_expr , file_schema , case_sensitive = True , projected_field_values = projected_field_values
1868
- )
1858
+ translated_expr = translate_column_names (bound_expr , file_schema , projected_field_values = {2 : 1 })
1869
1859
1870
1860
# Should evaluate to AlwaysFalse since projected field value does not match the expression literal
1871
1861
assert translated_expr == AlwaysFalse ()
1872
1862
1873
1863
1874
- def test_translate_column_names_missing_column_projected_field_fallbacks_to_initial_default () -> None :
1864
+ def test_translate_column_names_missing_column_projected_field_ignores_initial_default () -> None :
1875
1865
"""Test translate_column_names when projected field value doesn't match but initial_default does."""
1876
1866
# Original schema with a field that has an initial_default
1877
1867
original_schema = Schema (
@@ -1891,43 +1881,11 @@ def test_translate_column_names_missing_column_projected_field_fallbacks_to_init
1891
1881
)
1892
1882
1893
1883
# Projected field value that differs from both the expression literal and initial_default
1894
- projected_field_values = {2 : 10 } # This doesn't match expression literal (42)
1895
-
1896
- # Translate column names
1897
- translated_expr = translate_column_names (
1898
- bound_expr , file_schema , case_sensitive = True , projected_field_values = projected_field_values
1899
- )
1900
-
1901
- # Should evaluate to AlwaysTrue since projected field value doesn't match but initial_default does
1902
- assert translated_expr == AlwaysTrue ()
1903
-
1904
-
1905
- def test_translate_column_names_missing_column_projected_field_matches_initial_default_mismatch () -> None :
1906
- """Test translate_column_names when both projected field value and initial_default doesn't match."""
1907
- # Original schema with a field that has an initial_default that doesn't match the expression
1908
- original_schema = Schema (
1909
- NestedField (field_id = 1 , name = "existing_col" , field_type = StringType (), required = False ),
1910
- NestedField (field_id = 2 , name = "missing_col" , field_type = IntegerType (), required = False , initial_default = 10 ),
1911
- schema_id = 1 ,
1912
- )
1913
-
1914
- # Create bound expression for the missing column
1915
- unbound_expr = EqualTo ("missing_col" , 42 )
1916
- bound_expr = visit (unbound_expr , visitor = BindVisitor (schema = original_schema , case_sensitive = True ))
1917
-
1918
- # File schema only has the existing column (field_id=1), missing field_id=2
1919
- file_schema = Schema (
1920
- NestedField (field_id = 1 , name = "existing_col" , field_type = StringType (), required = False ),
1921
- schema_id = 1 ,
1922
- )
1923
-
1924
- # Projected field value that matches the expression literal
1925
- projected_field_values = {2 : 10 } # This doesn't match expression literal (42)
1926
-
1927
- # Translate column names
1928
1884
translated_expr = translate_column_names (
1929
- bound_expr , file_schema , case_sensitive = True , projected_field_values = projected_field_values
1885
+ bound_expr ,
1886
+ file_schema ,
1887
+ projected_field_values = {2 : 10 }, # This doesn't match expression literal (42)
1930
1888
)
1931
1889
1932
- # Should evaluate to AlwaysFalse since both projected field value and initial_default does not match
1890
+ # Should evaluate to AlwaysFalse since projected field value doesn't match the expression literal
1933
1891
assert translated_expr == AlwaysFalse ()
0 commit comments