Commit 5b1af01
authored
MINOR: [C++][Compute] Remove resolved TODO comments in case_when null validation (#48749)
### Rationale for this change
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1771
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1819
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1861
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1903
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1921
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1939
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1967
https://github.com/apache/arrow/blob/8ccdbe78063ad4b43872b8826aba37a1a73dc951/cpp/src/arrow/compute/kernels/scalar_if_else.cc#L1981
are all user-facing checks so cannot be `DCHECK`.
(Generated by ChatGPT)
```python
import pyarrow as pa
import pyarrow.compute as pc
print("=" * 60)
print("PyArrow case_when Validation Examples")
print("=" * 60)
# Helper function to test case_when
def test_case_when(name, cond_array, value1, value2, line_number):
try:
result = pc.case_when(cond_array, value1, value2)
print(f"✅ {name}: Success")
return True
except pa.ArrowInvalid as e:
print(f"❌ {name} (line {line_number}): {e}")
return False
# Create condition structs
valid_cond = pa.array([
{'c1': True}, {'c1': False}
], type=pa.struct([pa.field('c1', pa.bool_())]))
invalid_cond = pa.array([
{'c1': True}, None # ← OUTER NULL triggers validation!
], type=pa.struct([pa.field('c1', pa.bool_())]))
print("\n1. BINARY TYPE (line 1771 - enable_if_base_binary)")
print("-" * 60)
binary1 = pa.array([b'v1', b'v1'])
binary2 = pa.array([b'v2', b'v2'])
test_case_when("Valid binary", valid_cond, binary1, binary2, 1771)
test_case_when("Invalid binary", invalid_cond, binary1, binary2, 1771)
print("\n2. LIST TYPE (line 1818 - enable_if_var_size_list)")
print("-" * 60)
list1 = pa.array([[1, 2], [3, 4]])
list2 = pa.array([[5, 6], [7, 8]])
test_case_when("Valid list", valid_cond, list1, list2, 1818)
test_case_when("Invalid list", invalid_cond, list1, list2, 1818)
print("\n3. LIST_VIEW TYPE (line 1859 - enable_if_list_view)")
print("-" * 60)
listview1 = pa.array([[1, 2], [3, 4]], type=pa.list_view(pa.int64()))
listview2 = pa.array([[5, 6], [7, 8]], type=pa.list_view(pa.int64()))
test_case_when("Valid list_view", valid_cond, listview1, listview2, 1859)
test_case_when("Invalid list_view", invalid_cond, listview1, listview2, 1859)
print("\n4. MAP TYPE (line 1900)")
print("-" * 60)
map1 = pa.array([[('k1', 100)], [('k2', 200)]], type=pa.map_(pa.string(), pa.int64()))
map2 = pa.array([[('k3', 300)], [('k4', 400)]], type=pa.map_(pa.string(), pa.int64()))
test_case_when("Valid map", valid_cond, map1, map2, 1900)
test_case_when("Invalid map", invalid_cond, map1, map2, 1900)
print("\n5. STRUCT TYPE (line 1917)")
print("-" * 60)
struct1 = pa.array([{'x': 1}, {'x': 2}], type=pa.struct([pa.field('x', pa.int64())]))
struct2 = pa.array([{'x': 3}, {'x': 4}], type=pa.struct([pa.field('x', pa.int64())]))
test_case_when("Valid struct", valid_cond, struct1, struct2, 1917)
test_case_when("Invalid struct", invalid_cond, struct1, struct2, 1917)
print("\n6. FIXED_SIZE_LIST TYPE (line 1934)")
print("-" * 60)
fsl1 = pa.array([[1, 2], [3, 4]], type=pa.list_(pa.int64(), 2))
fsl2 = pa.array([[5, 6], [7, 8]], type=pa.list_(pa.int64(), 2))
test_case_when("Valid fixed_size_list", valid_cond, fsl1, fsl2, 1934)
test_case_when("Invalid fixed_size_list", invalid_cond, fsl1, fsl2, 1934)
print("\n7. DICTIONARY TYPE (line 1974)")
print("-" * 60)
dict1 = pa.array(['a', 'b']).dictionary_encode()
dict2 = pa.array(['c', 'd']).dictionary_encode()
test_case_when("Valid dictionary", valid_cond, dict1, dict2, 1974)
test_case_when("Invalid dictionary", invalid_cond, dict1, dict2, 1974)
print("\n" + "=" * 60)
print("KEY POINT: Outer nulls (None in struct) trigger validation")
print(" Inner nulls ({'c1': None}) are allowed")
print("=" * 60)
```
### What changes are included in this PR?
This PR removes obsolete TODOs. They cannot be DCHECK.
### Are these changes tested?
Yes, as described above.
### Are there any user-facing changes?
No, dev-only.
Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>1 parent 75f78a6 commit 5b1af01
1 file changed
Lines changed: 0 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1768 | 1768 | | |
1769 | 1769 | | |
1770 | 1770 | | |
1771 | | - | |
1772 | 1771 | | |
1773 | 1772 | | |
1774 | 1773 | | |
| |||
1816 | 1815 | | |
1817 | 1816 | | |
1818 | 1817 | | |
1819 | | - | |
1820 | 1818 | | |
1821 | 1819 | | |
1822 | 1820 | | |
| |||
1858 | 1856 | | |
1859 | 1857 | | |
1860 | 1858 | | |
1861 | | - | |
1862 | 1859 | | |
1863 | 1860 | | |
1864 | 1861 | | |
| |||
1900 | 1897 | | |
1901 | 1898 | | |
1902 | 1899 | | |
1903 | | - | |
1904 | 1900 | | |
1905 | 1901 | | |
1906 | 1902 | | |
| |||
1918 | 1914 | | |
1919 | 1915 | | |
1920 | 1916 | | |
1921 | | - | |
1922 | 1917 | | |
1923 | 1918 | | |
1924 | 1919 | | |
| |||
1936 | 1931 | | |
1937 | 1932 | | |
1938 | 1933 | | |
1939 | | - | |
1940 | 1934 | | |
1941 | 1935 | | |
1942 | 1936 | | |
| |||
1964 | 1958 | | |
1965 | 1959 | | |
1966 | 1960 | | |
1967 | | - | |
1968 | 1961 | | |
1969 | 1962 | | |
1970 | 1963 | | |
| |||
1978 | 1971 | | |
1979 | 1972 | | |
1980 | 1973 | | |
1981 | | - | |
1982 | 1974 | | |
1983 | 1975 | | |
1984 | 1976 | | |
| |||
0 commit comments