Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more types to arrow export #2419

Merged
merged 1 commit into from
Nov 15, 2023
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
2 changes: 1 addition & 1 deletion src/binder/binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ std::unique_ptr<LogicalType> Binder::bindDataType(const std::string& dataType) {
if (boundType.getLogicalTypeID() == LogicalTypeID::FIXED_LIST) {
auto validNumericTypes = LogicalTypeUtils::getNumericalLogicalTypeIDs();
auto childType = FixedListType::getChildType(&boundType);
auto numElementsInList = FixedListType::getNumElementsInList(&boundType);
auto numElementsInList = FixedListType::getNumValuesInList(&boundType);
if (find(validNumericTypes.begin(), validNumericTypes.end(),
childType->getLogicalTypeID()) == validNumericTypes.end()) {
throw BinderException("The child type of a fixed list must be a numeric type. Given: " +
Expand Down
2 changes: 1 addition & 1 deletion src/c_api/data_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ uint64_t kuzu_data_type_get_fixed_num_elements_in_list(kuzu_logical_type* data_t
if (parent_type->getLogicalTypeID() != LogicalTypeID::FIXED_LIST) {
return 0;
}
return FixedListType::getNumElementsInList(static_cast<LogicalType*>(data_type->_data_type));
return FixedListType::getNumValuesInList(static_cast<LogicalType*>(data_type->_data_type));
}
41 changes: 36 additions & 5 deletions src/common/arrow/arrow_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <cstring>

#include "common/arrow/arrow_row_batch.h"
#include "common/exception/internal.h"

namespace kuzu {
namespace common {
Expand Down Expand Up @@ -69,6 +68,9 @@
case LogicalTypeID::BOOL: {
child.format = "b";
} break;
case LogicalTypeID::INT128: {
child.format = "d:38,0";
} break;

Check warning on line 73 in src/common/arrow/arrow_converter.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_converter.cpp#L71-L73

Added lines #L71 - L73 were not covered by tests
case LogicalTypeID::INT64: {
child.format = "l";
} break;
Expand All @@ -78,9 +80,27 @@
case LogicalTypeID::INT16: {
child.format = "s";
} break;
case LogicalTypeID::INT8: {
child.format = "c";
} break;
case LogicalTypeID::UINT64: {
child.format = "L";
} break;
case LogicalTypeID::UINT32: {
child.format = "I";
} break;
case LogicalTypeID::UINT16: {
child.format = "S";
} break;
case LogicalTypeID::UINT8: {
child.format = "C";
} break;

Check warning on line 97 in src/common/arrow/arrow_converter.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_converter.cpp#L83-L97

Added lines #L83 - L97 were not covered by tests
case LogicalTypeID::DOUBLE: {
child.format = "g";
} break;
case LogicalTypeID::FLOAT: {
child.format = "f";
} break;

Check warning on line 103 in src/common/arrow/arrow_converter.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_converter.cpp#L101-L103

Added lines #L101 - L103 were not covered by tests
case LogicalTypeID::DATE: {
child.format = "tdD";
} break;
Expand All @@ -105,16 +125,27 @@
child.children[0]->name = "l";
setArrowFormat(rootHolder, **child.children, *typeInfo.childrenTypesInfo[0]);
} break;
case LogicalTypeID::FIXED_LIST: {
auto numValuesPerList = "+w:" + std::to_string(typeInfo.numValuesPerList);
child.format = copyName(rootHolder, numValuesPerList);
child.n_children = 1;
rootHolder.nestedChildren.emplace_back();
rootHolder.nestedChildren.back().resize(1);
rootHolder.nestedChildrenPtr.emplace_back();
rootHolder.nestedChildrenPtr.back().push_back(&rootHolder.nestedChildren.back()[0]);
initializeChild(rootHolder.nestedChildren.back()[0]);
child.children = &rootHolder.nestedChildrenPtr.back()[0];
child.children[0]->name = "l";
setArrowFormat(rootHolder, **child.children, *typeInfo.childrenTypesInfo[0]);
} break;
case LogicalTypeID::STRUCT:

Check warning on line 141 in src/common/arrow/arrow_converter.cpp

View check run for this annotation

Codecov / codecov/patch

src/common/arrow/arrow_converter.cpp#L128-L141

Added lines #L128 - L141 were not covered by tests
case LogicalTypeID::INTERNAL_ID:
case LogicalTypeID::NODE:
case LogicalTypeID::REL: {
setArrowFormatForStruct(rootHolder, child, typeInfo);
} break;
// LCOV_EXCL_START
default:
throw InternalException(
"Unsupported Arrow type " + LogicalTypeUtils::toString(typeInfo.typeID));
// LCOV_EXCL_STOP
KU_UNREACHABLE;
}
}

Expand Down
Loading