File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -32,3 +32,36 @@ the following expression represents the set of rows for which the `age` column l
3232.. autofunction :: vortex.expr.literal
3333
3434.. autoclass :: vortex.expr.Expr
35+ :members:
36+
37+ .. py :method :: __getitem__ (name, / )
38+
39+ Extract a field of a struct array.
40+
41+ :parameters:
42+
43+ - **name ** (:class: `.str `) -- The name of the field.
44+
45+ :return type:
46+
47+ :class: `.vortex.Expr `
48+
49+ .. rubric :: Examples
50+
51+ >>> import vortex as vx
52+ >>> import vortex.expr as ve
53+ >>> import pyarrow as pa
54+ >>>
55+ >>> array = pa.array([
56+ ... {" x" : 1 , " y" : {" yy" : " a" }},
57+ ... {" x" : 2 , " y" : {" yy" : " b" }},
58+ ... ])
59+ >>>
60+ >>> vx.io.write(vx.array(array), ' /tmp/foo.vortex' )
61+ >>> (vx.file.open(' /tmp/foo.vortex' )
62+ ... .scan(expr = vx.expr.column(" y" )[" yy" ] == " a" )
63+ ... .read_all()
64+ ... .to_pylist()
65+ ... )
66+ [{'x': 1, 'y': {'yy': 'a'}}]
67+
Original file line number Diff line number Diff line change @@ -159,6 +159,8 @@ impl PyExpr {
159159 py_binary_operator ( self_, Operator :: Or , coerce_expr ( right) ?)
160160 }
161161
162+ // Special methods docstrings cannot be defined in Rust. Write a docstring in the corresponding
163+ // rST file. https://github.com/PyO3/pyo3/issues/4326
162164 fn __getitem__ ( self_ : PyRef < ' _ , Self > , field : String ) -> PyResult < PyExpr > {
163165 get_item ( field, self_. clone ( ) )
164166 }
@@ -236,6 +238,10 @@ pub fn root() -> PyExpr {
236238/// >>> ve.column("age")
237239/// <vortex.Expr object at ...>
238240/// ```
241+ ///
242+ /// .. seealso::
243+ ///
244+ /// Use :meth:`.vortex.expr.Expr.__getitem__` to retrieve a field of a struct array.
239245#[ pyfunction]
240246pub fn column < ' py > ( name : & Bound < ' py , PyString > ) -> PyResult < Bound < ' py , PyExpr > > {
241247 let py = name. py ( ) ;
You can’t perform that action at this time.
0 commit comments