[fix](array-type) fix get_data_at for zero element array #13225

Co-authored-by: cambyzju <zhuxiaoli01@baidu.com>
This commit is contained in:
camby
2022-10-11 15:41:34 +08:00
committed by GitHub
parent eb60976c25
commit 4e4f8afa28
2 changed files with 6 additions and 4 deletions

View File

@ -150,9 +150,11 @@ StringRef ColumnArray::get_data_at(size_t n) const {
* For arrays of strings and arrays of arrays, the resulting chunk of memory may not be one-to-one correspondence with the elements,
* since it contains only the data laid in succession, but not the offsets.
*/
size_t offset_of_first_elem = offset_at(n);
StringRef first = get_data().get_data_at(offset_of_first_elem);
StringRef first;
if (offset_of_first_elem < get_data().size()) {
first = get_data().get_data_at(offset_of_first_elem);
}
size_t array_size = size_at(n);
if (array_size == 0) {

View File

@ -197,8 +197,8 @@ std::string VLiteral::debug_string() const {
out << "VLiteral (name = " << _expr_name;
out << ", type = " << _data_type->get_name();
out << ", value = ";
if (_column_ptr.get()->size() > 0) {
StringRef ref = _column_ptr.get()->get_data_at(0);
if (_column_ptr->size() > 0) {
StringRef ref = _column_ptr->get_data_at(0);
if (ref.data == nullptr) {
out << "null";
} else {