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

Commit 4acf3bf

Browse files
committed
Add dump methods to ResultSetTableToken.
Signed-off-by: ienkovich <[email protected]>
1 parent 91b7472 commit 4acf3bf

File tree

4 files changed

+65
-3
lines changed

4 files changed

+65
-3
lines changed

omniscidb/ResultSetRegistry/ResultSetTableToken.cpp

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,57 @@ std::shared_ptr<arrow::Table> ResultSetTableToken::toArrow() const {
6767
return res;
6868
}
6969

70+
std::string ResultSetTableToken::description() const {
71+
auto first_rs = resultSet(0);
72+
auto last_rs = resultSet(resultSetCount() - 1);
73+
size_t total_entries = first_rs->entryCount();
74+
for (size_t rs_idx = 1; rs_idx < resultSetCount(); ++rs_idx) {
75+
total_entries += resultSet(rs_idx)->entryCount();
76+
}
77+
std::ostringstream oss;
78+
oss << "Result Set Table Info" << std::endl;
79+
oss << "\tFragments: " << resultSetCount() << std::endl;
80+
oss << "\tLayout: " << first_rs->getQueryMemDesc().queryDescTypeToString() << std::endl;
81+
oss << "\tColumns: " << first_rs->colCount() << std::endl;
82+
oss << "\tRows: " << rowCount() << std::endl;
83+
oss << "\tEntry count: " << total_entries << std::endl;
84+
const std::string did_output_columnar =
85+
first_rs->didOutputColumnar() ? "True" : "False;";
86+
oss << "\tColumnar: " << did_output_columnar << std::endl;
87+
oss << "\tLazy-fetched columns: " << first_rs->getNumColumnsLazyFetched() << std::endl;
88+
const std::string is_direct_columnar_conversion_possible =
89+
first_rs->isDirectColumnarConversionPossible() ? "True" : "False";
90+
oss << "\tDirect columnar conversion possible: "
91+
<< is_direct_columnar_conversion_possible << std::endl;
92+
93+
size_t num_columns_zero_copy_columnarizable{0};
94+
for (size_t col_idx = 0; col_idx < first_rs->colCount(); col_idx++) {
95+
if (first_rs->isZeroCopyColumnarConversionPossible(col_idx)) {
96+
num_columns_zero_copy_columnarizable++;
97+
}
98+
}
99+
oss << "\tZero-copy columnar conversion columns: "
100+
<< num_columns_zero_copy_columnarizable << std::endl;
101+
102+
oss << "\tHas permutation: "
103+
<< (first_rs->isPermutationBufferEmpty() ? "False" : "True") << std::endl;
104+
auto limit =
105+
last_rs->getLimit() ? row_count_ - last_rs->rowCount() + last_rs->getLimit() : 0;
106+
oss << "\tLimit: " << limit << std::endl;
107+
oss << "\tOffset: " << first_rs->getOffset() << std::endl;
108+
return oss.str();
109+
}
110+
111+
std::string ResultSetTableToken::memoryDescription() const {
112+
return resultSet(0)->toString();
113+
}
114+
115+
std::string ResultSetTableToken::contentToString(bool header) const {
116+
std::string res = resultSet(0)->contentToString(header);
117+
for (size_t rs_idx = 1; rs_idx < resultSetCount(); ++rs_idx) {
118+
res += resultSet(rs_idx)->contentToString(false);
119+
}
120+
return res;
121+
}
122+
70123
} // namespace hdk

omniscidb/ResultSetRegistry/ResultSetTableToken.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ class ResultSetTableToken : public std::enable_shared_from_this<ResultSetTableTo
6464
std::to_string(tableId()) + ")";
6565
}
6666

67+
std::string description() const;
68+
std::string memoryDescription() const;
69+
std::string contentToString(bool header) const;
70+
6771
private:
6872
void reset();
6973

python/pyhdk/_sql.pxd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ cdef extern from "omniscidb/ResultSetRegistry/ResultSetTableToken.h":
5656
cdef cppclass CResultSetTableToken "hdk::ResultSetTableToken":
5757
size_t rowCount()
5858
shared_ptr[CArrowTable] toArrow() except +
59+
string description()
60+
string memoryDescription()
61+
string contentToString(bool)
5962

6063
ctypedef shared_ptr[const CResultSetTableToken] CResultSetTableTokenPtr
6164

python/pyhdk/_sql.pyx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ cdef class ExecutionResult:
8787

8888
@property
8989
def desc(self):
90-
return self.c_result.getRows().get().summaryToString()
90+
cdef CResultSetTableTokenPtr c_token = self.c_result.getToken()
91+
return c_token.get().description()
9192

9293
@property
9394
def memory_desc(self):
94-
return self.c_result.getRows().get().toString()
95+
cdef CResultSetTableTokenPtr c_token = self.c_result.getToken()
96+
return c_token.get().memoryDescription()
9597

9698
@property
9799
def table_name(self):
@@ -152,7 +154,7 @@ cdef class ExecutionResult:
152154
for key, type_str in self.schema.items():
153155
res += f" {key}: {type_str}\n"
154156
res += "Data:\n"
155-
res += self.c_result.getRows().get().contentToString(False)
157+
res += self.c_result.getToken().get().contentToString(False)
156158
return res
157159

158160
def __repr__(self):

0 commit comments

Comments
 (0)