@@ -36,10 +36,10 @@ Positional arguments have no special metadata. Their position index is
3636determined by their order in the schema.
3737
3838``` python
39- # Arg [int] (0) becomes:
39+ # count: Annotated [int, Arg (0)] becomes:
4040pa.field(" count" , pa.int64())
4141
42- # Arg [str] (1) becomes:
42+ # name: Annotated [str, Arg (1)] becomes:
4343pa.field(" name" , pa.utf8())
4444```
4545
@@ -49,35 +49,35 @@ Named arguments have `vgi_arg=named` metadata. The field name is the
4949argument key used in SQL.
5050
5151``` python
52- # Arg [str] ("format") becomes:
52+ # format: Annotated [str, Arg ("format")] becomes:
5353pa.field(" format" , pa.utf8(), metadata = {b " vgi_arg" : b " named" })
5454```
5555
5656## Special Types
5757
5858### Table Input
5959
60- Table input arguments (` Arg [TableInput]` ) receive streaming RecordBatches
61- rather than scalar values.
60+ Table input arguments (` Annotated [TableInput, Arg(...) ]` ) receive streaming
61+ RecordBatches rather than scalar values.
6262
6363- ** Arrow type** : ` pa.null() `
6464- ** Metadata** : ` {b"vgi_type": b"table"} `
6565
6666``` python
67- # Arg [TableInput] (1) becomes:
67+ # data: Annotated [TableInput, Arg (1)] becomes:
6868pa.field(" data" , pa.null(), metadata = {b " vgi_type" : b " table" })
6969```
7070
7171### Any Type
7272
73- Any-type arguments (` Arg[AnyArrow ]` ) accept any valid Arrow scalar type
74- at runtime.
73+ Any-type arguments (` Annotated[AnyArrowValue, Arg(...) ]` ) accept any valid
74+ Arrow scalar type at runtime.
7575
7676- ** Arrow type** : ` pa.null() `
7777- ** Metadata** : ` {b"vgi_type": b"any"} `
7878
7979``` python
80- # Arg[AnyArrow] (0) becomes:
80+ # value: Annotated[AnyArrowValue, Arg (0)] becomes:
8181pa.field(" value" , pa.null(), metadata = {b " vgi_type" : b " any" })
8282```
8383
@@ -90,7 +90,7 @@ arguments from their position onwards.
9090- ** Metadata** : ` {b"vgi_varargs": b"true"} `
9191
9292``` python
93- # Arg[ str] (0, varargs=True) becomes:
93+ # columns: Annotated[tuple[ str, ...], Arg (0, varargs=True)] becomes:
9494pa.field(" columns" , pa.utf8(), metadata = {b " vgi_varargs" : b " true" })
9595```
9696
@@ -100,7 +100,7 @@ Fields can have multiple metadata keys. For example, a named argument
100100that accepts any type:
101101
102102``` python
103- # Arg[AnyArrow] ("threshold") becomes:
103+ # threshold: Annotated[AnyArrowValue, Arg ("threshold")] becomes:
104104pa.field(" threshold" , pa.null(), metadata = {
105105 b " vgi_arg" : b " named" ,
106106 b " vgi_type" : b " any" ,
@@ -112,10 +112,12 @@ pa.field("threshold", pa.null(), metadata={
112112### Example 1: Simple Function
113113
114114``` python
115+ from typing import Annotated
116+
115117class MyFunction (TableInOutFunction ):
116- count = Arg [int ] (0 ) # Positional 0
117- name = Arg [str ] (1 ) # Positional 1
118- verbose = Arg [bool ] (" verbose" ) # Named
118+ count: Annotated [int , Arg (0 )] # Positional 0
119+ name: Annotated [str , Arg (1 )] # Positional 1
120+ verbose: Annotated [bool , Arg (" verbose" )] # Named
119121
120122# Serializes to:
121123schema = pa.schema([
@@ -128,9 +130,12 @@ schema = pa.schema([
128130### Example 2: Function with Table Input
129131
130132``` python
133+ from typing import Annotated
134+ from vgi.arguments import TableInput
135+
131136class TransformFunction (TableInOutFunction ):
132- multiplier = Arg [float ] (0 )
133- data: TableInput = Arg[TableInput] (1 )
137+ multiplier: Annotated [float , Arg (0 )]
138+ data: Annotated[ TableInput, Arg(1 )]
134139
135140# Serializes to:
136141schema = pa.schema([
@@ -142,8 +147,10 @@ schema = pa.schema([
142147### Example 3: Function with Varargs
143148
144149``` python
150+ from typing import Annotated
151+
145152class SumColumnsFunction (TableInOutFunction ):
146- columns = Arg[ str ] (0 , varargs = True )
153+ columns: Annotated[tuple[ str , ... ], Arg (0 , varargs = True )]
147154
148155# Serializes to:
149156schema = pa.schema([
@@ -154,12 +161,16 @@ schema = pa.schema([
154161### Example 4: Complex Function
155162
156163``` python
164+ from typing import Annotated
165+ from vgi import AnyArrowValue
166+ from vgi.arguments import TableInput
167+
157168class ComplexFunction (TableInOutFunction ):
158- count = Arg [int ] (0 )
159- data: TableInput = Arg[TableInput] (1 )
160- extra = Arg[ float ] (2 , varargs = True )
161- format = Arg [str ] (" format" )
162- threshold: AnyArrow = Arg[AnyArrow] (" threshold" )
169+ count: Annotated [int , Arg (0 )]
170+ data: Annotated[ TableInput, Arg(1 )]
171+ extra: Annotated[tuple[ float , ... ], Arg (2 , varargs = True )]
172+ format : Annotated [str , Arg (" format" )]
173+ threshold: Annotated[AnyArrowValue, Arg(" threshold" )]
163174
164175# Serializes to:
165176schema = pa.schema([
0 commit comments