Skip to content

Commit

Permalink
Add python bindings for new types and getValue for float
Browse files Browse the repository at this point in the history
  • Loading branch information
mewim committed Apr 2, 2023
1 parent afed1c7 commit b736723
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/include/common/types/value.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ inline int64_t Value::getValue() const {
return val.int64Val;
}

/**
* @return float value.
*/
KUZU_API template<>
inline float Value::getValue() const {
assert(dataType.getTypeID() == FLOAT);
return val.floatVal;
}

/**
* @return double value.
*/
Expand Down
9 changes: 9 additions & 0 deletions tools/python_api/src_cpp/py_query_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,18 @@ py::object PyQueryResult::convertValueToPyObject(const Value& value) {
case BOOL: {
return py::cast(value.getValue<bool>());
}
case INT16: {
return py::cast(value.getValue<int16_t>());
}
case INT32: {
return py::cast(value.getValue<int32_t>());
}
case INT64: {
return py::cast(value.getValue<int64_t>());
}
case FLOAT: {
return py::cast(value.getValue<float>());
}
case DOUBLE: {
return py::cast(value.getValue<double>());
}
Expand Down

0 comments on commit b736723

Please sign in to comment.