Mayil-AI-Sandbox / kuzudb_jan15

MIT License
0 stars 0 forks source link

Casting behavior inconsistency (hashtag2793) #24

Open vikramsubramanian opened 4 months ago

vikramsubramanian commented 4 months ago

I notice the following inconsistency:

I cannot do the following:

kuzu> RETURN cast(false, "BOOL") as bar;
Error: Conversion exception: Unsupported casting function from BOOL to BOOL.

But I can do STRING to STRING or INT64 to INT64. For example:

kuzu> RETURN cast("123", "STRING") as bar;
-------
| bar |
-------
| 123 |
-------

)

mayil-ai[bot] commented 4 months ago

Summary: Inconsistency in casting behavior for certain data types in the Kuzu query language.

Possible Solution

To resolve the issue with the "Conversion exception: Unsupported casting function from BOOL to BOOL," you should:

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.

Code snippets to check