Skip to content

Commit 3893eb5

Browse files
committed
nix attr accessor for now
1 parent 110645f commit 3893eb5

2 files changed

Lines changed: 4 additions & 5 deletions

File tree

python/sedonadb/python/sedonadb/expr/expression.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -329,9 +329,11 @@ def __len__(self) -> int:
329329
)
330330

331331
# Nested expressions
332-
def __getitem__(self, key: Union[int, str, "Expr"]) -> "Expr":
332+
def __getitem__(self, key: Union[int, str]) -> "Expr":
333333
if isinstance(key, int):
334334
# Python uses 0-based indexing; SQL uses 1-based indexing
335+
if key < 0:
336+
raise ValueError("Can't index array expression with negative integer")
335337
return self.funcs.array_extract(key + 1)
336338
elif isinstance(key, str):
337339
# get_field works for both structs and maps, returning a scalar
@@ -342,9 +344,6 @@ def __getitem__(self, key: Union[int, str, "Expr"]) -> "Expr":
342344
"or .funcs.get_field() to extract with an expression key."
343345
)
344346

345-
def __getattr__(self, name: str) -> "Expr":
346-
return self.funcs.get_field(name)
347-
348347

349348
class SortExpr:
350349
"""A sort key — an `Expr` plus direction and null placement.

python/sedonadb/tests/expr/test_expression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ def test_nested_expression_exec(con):
366366
)
367367

368368
pd.testing.assert_frame_equal(
369-
t.select(a=t.struct_col.a).to_pandas(), pd.DataFrame({"a": [1, 3]})
369+
t.select(a=t.struct_col["a"]).to_pandas(), pd.DataFrame({"a": [1, 3]})
370370
)
371371

372372
pd.testing.assert_frame_equal(

0 commit comments

Comments
 (0)