Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions python/pylance/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pyarrow.dataset as ds
from pylance.lib import LanceFileFormat


def dataset(uri: str):
"""
Create an Arrow Dataset from the given lance uri.

Parameters
----------
uri: str
The uri to the lance data
"""
fmt = LanceFileFormat()
return ds.dataset(uri, format=fmt)
27 changes: 27 additions & 0 deletions python/pylance/_lib.pyx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from libcpp.memory cimport shared_ptr
from pyarrow.includes.libarrow_dataset cimport CFileFormat
from pyarrow._dataset cimport FileFormat


cdef extern from "lance/arrow/file_lance.h" namespace "lance" nogil:

cdef cppclass CLanceFileFormat "::lance::arrow::LanceFileFormat"(
CFileFormat):
pass


cdef class LanceFileFormat(FileFormat):

def __init__(self):
self.init(shared_ptr[CFileFormat](new CLanceFileFormat()))

def equals(self, LanceFileFormat other):
return True

@property
def default_extname(self):
return "lance"

def __reduce__(self):
return LanceFileFormat, tuple()