Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Propagate Arrow Storage Exceptions #63

Merged
merged 1 commit into from
Sep 20, 2022
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
14 changes: 7 additions & 7 deletions python/pyhdk/_storage.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ cdef class Storage(SchemaProvider):

cdef extern from "omniscidb/ArrowStorage/ArrowStorage.h":
cdef cppclass CArrowStorage "ArrowStorage"(CSchemaProvider, CAbstractDataProvider):
CArrowStorage(int, string, int);
CArrowStorage(int, string, int) except +;

CTableInfoPtr importArrowTable(shared_ptr[CArrowTable], string&, CTableOptions&);
void dropTable(const string&, bool)
CTableInfoPtr importArrowTable(shared_ptr[CArrowTable], string&, CTableOptions&) except +;
void dropTable(const string&, bool) except +;

cdef extern from "omniscidb/BufferProvider/BufferProvider.h" namespace "Data_Namespace":
cdef cppclass CBufferProvider "BufferProvider":
Expand All @@ -146,11 +146,11 @@ cdef extern from "omniscidb/DataMgr/PersistentStorageMgr/PersistentStorageMgr.h"

cdef extern from "omniscidb/DataMgr/DataMgr.h" namespace "Data_Namespace":
cdef cppclass CDataMgr "DataMgr":
CDataMgr(const CConfig&, const CSystemParameters&, map[CGpuMgrPlatform, unique_ptr[CGpuMgr]]&& gpuMgrs, size_t reservedGpuMem, size_t numReaderThreads)
CDataMgr(const CConfig&, const CSystemParameters&, map[CGpuMgrPlatform, unique_ptr[CGpuMgr]]&& gpuMgrs, size_t reservedGpuMem, size_t numReaderThreads) except +;

CPersistentStorageMgr* getPersistentStorageMgr()
CBufferProvider* getBufferProvider()
CDataProvider* getDataProvider()
CPersistentStorageMgr* getPersistentStorageMgr() except +;
CBufferProvider* getBufferProvider() except +;
CDataProvider* getDataProvider() except +;

cdef class DataMgr:
cdef shared_ptr[CDataMgr] c_data_mgr
Expand Down
13 changes: 13 additions & 0 deletions python/tests/test_pyhdk_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def execute_sql(cls, sql, **kwargs):
)
return rel_alg_executor.execute(**kwargs)

@classmethod
def get_storage(cls):
return cls.storage

def test_simple_count(self):
res = self.execute_sql("SELECT COUNT(*) FROM test;")
df = res.to_arrow().to_pandas()
Expand All @@ -62,3 +66,12 @@ def test_explain(self):
res = self.execute_sql("SELECT * FROM test;", just_explain=True)
explain_str = res.to_explain_str()
assert explain_str[:15] == "IR for the CPU:"

def test_storage_exceptions(self):
at = pyarrow.Table.from_pandas(
pandas.DataFrame({"c": [1, 2, 3], "d": [10, 20, 30]})
)
opt = pyhdk.storage.TableOptions(2)

with pytest.raises(RuntimeError):
self.get_storage().importArrowTable(at, "test", opt)