This repository was archived by the owner on May 9, 2024. It is now read-only.
File tree 3 files changed +12
-2
lines changed
3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,7 @@ cdef extern from "omniscidb/QueryEngine/Descriptors/RelAlgExecutionDescriptor.h"
73
73
74
74
const CResultSetPtr& getRows()
75
75
const vector[CTargetMetaInfo]& getTargetsMeta()
76
+ string getExplanation()
76
77
77
78
cdef extern from " omniscidb/QueryEngine/RelAlgExecutor.h" :
78
79
cdef cppclass CRelAlgExecutor " RelAlgExecutor" :
Original file line number Diff line number Diff line change @@ -74,6 +74,9 @@ cdef class ExecutionResult:
74
74
cdef shared_ptr[CArrowTable] at = converter.get().convertToArrowTable()
75
75
return pyarrow_wrap_table(at)
76
76
77
+ def to_explain_str (self ):
78
+ return self .c_result.getExplanation()
79
+
77
80
cdef class RelAlgExecutor:
78
81
cdef shared_ptr[CRelAlgExecutor] c_rel_alg_executor
79
82
# DataMgr is used only to pass it to each produced ExecutionResult
@@ -108,6 +111,7 @@ cdef class RelAlgExecutor:
108
111
c_eo.output_columnar_hint = kwargs.get(" enable_columnar_output" , g_enable_columnar_output)
109
112
c_eo.with_watchdog = kwargs.get(" enable_watchdog" , g_enable_watchdog)
110
113
c_eo.with_dynamic_watchdog = kwargs.get(" enable_dynamic_watchdog" , g_enable_dynamic_watchdog)
114
+ c_eo.just_explain = kwargs.get(" just_explain" , False )
111
115
cdef CExecutionResult c_res = self .c_rel_alg_executor.get().executeRelAlgQuery(c_co, c_eo, False )
112
116
cdef ExecutionResult res = ExecutionResult()
113
117
res.c_result = move(c_res)
Original file line number Diff line number Diff line change @@ -29,16 +29,21 @@ def teardown_class(cls):
29
29
del cls .storage
30
30
31
31
@classmethod
32
- def execute_sql (cls , sql ):
32
+ def execute_sql (cls , sql , ** kwargs ):
33
33
ra = cls .calcite .process (sql )
34
34
rel_alg_executor = pyhdk .sql .RelAlgExecutor (
35
35
cls .executor , cls .storage , cls .data_mgr , ra
36
36
)
37
- return rel_alg_executor .execute ()
37
+ return rel_alg_executor .execute (** kwargs )
38
38
39
39
def test_simple_projection (self ):
40
40
res = self .execute_sql ("SELECT * FROM test;" )
41
41
df = res .to_arrow ().to_pandas ()
42
42
assert df .shape == (3 , 2 )
43
43
assert df ["a" ].tolist () == [1 , 2 , 3 ]
44
44
assert df ["b" ].tolist () == [10 , 20 , 30 ]
45
+
46
+ def test_explain (self ):
47
+ res = self .execute_sql ("SELECT * FROM test;" , just_explain = True )
48
+ explain_str = res .to_explain_str ()
49
+ assert (explain_str [:15 ] == "IR for the CPU:" )
You can’t perform that action at this time.
0 commit comments