Skip to content

Commit c3cdf18

Browse files
committed
added properties to VortexScanner
Signed-off-by: Siddharth Kumar <[email protected]>
1 parent a2fe4d3 commit c3cdf18

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

vortex-python/python/vortex/dataset.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,16 @@ def __init__(
791791
def schema(self):
792792
return self._dataset.schema
793793

794+
@property
795+
def dataset_schema(self) -> pyarrow.Schema:
796+
return self._dataset.schema
797+
798+
@property
799+
def projected_schema(self) -> pyarrow.Schema:
800+
if self._columns:
801+
return pyarrow.schema([self._dataset.schema.field(c) for c in self._columns])
802+
return self._dataset.schema
803+
794804
@override
795805
def count_rows(self):
796806
return self._dataset.count_rows(

vortex-python/test/test_scan.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,13 @@ def test_scan_with_cast(vxfile: vx.VortexFile):
6464
[{"index": 1, "string": pa.scalar("1", pa.string_view()), "bool": False, "float": math.sqrt(1)}]
6565
)
6666
assert str(actual.to_arrow_array()) == str(expected)
67+
68+
69+
def test_scanner_property_projected(vxfile: vx.VortexFile):
70+
assert vxfile.to_dataset().scanner(columns=["bool"]).projected_schema == pa.schema([("bool", pa.bool_())])
71+
72+
73+
def test_scanner_property_dataset_schema(vxfile: vx.VortexFile):
74+
assert vxfile.to_dataset().scanner().dataset_schema == pa.schema(
75+
[("bool", pa.bool_()), ("float", pa.float64()), ("index", pa.int64()), ("string", pa.string_view())]
76+
)

0 commit comments

Comments
 (0)