Open vikramsubramanian opened 4 months ago
Summary: Inconsistency in casting behavior for certain data types in the Kuzu query language.
To resolve the issue with the "Conversion exception: Unsupported casting function from BOOL to BOOL," you should:
LogicalTypeID::BOOL
in the vector_cast_functions.cpp
file that handles casting from bool
to bool
without changing the type. This case should be similar to the one for STRING
that uses CastToString
but instead should use an identity function or a no-op since the types are the same.cast
function checks if the source type and the target type are the same before attempting any conversion logic, and if they are the same, it should return the input value directly.BOOL
to BOOL
works as expected without throwing an exception.Here is a code snippet that could be added to the vector_cast_functions.cpp
file:
case LogicalTypeID::BOOL: {
func = ScalarFunction::UnaryCastExecFunction<bool, bool, CastToSame<bool>, EXECUTOR>;
} break;
And the CastToSame
template function:
template<typename T>
static T CastToSame(T value) {
return value;
}
Make sure to add this function in an appropriate location within the codebase, such as in a cast_functions.h
file if it exists, or directly in the vector_cast_functions.cpp
file if it's more suitable.
src/function/vector_cast_functions.cpp
This file contains the logic for casting between different types, which is directly related to the issue of casting inconsistency.
src/function/cast_from_string_functions.cpp
This file includes the functions for casting from strings, which might be relevant when investigating casting inconsistencies.
src/include/function/cast/functions/cast_from_string_functions.h
This header file declares functions for casting from strings, which could be relevant to the issue if the casting logic needs to be reviewed or modified.
I notice the following inconsistency:
I cannot do the following:
But I can do STRING to STRING or INT64 to INT64. For example:
)