wasabii commented on PR #5276:
URL: https://github.com/apache/calcite/pull/5276#issuecomment-5800216935
@mihaibudiu I'm going back to the drawing board on this one. I was
fundamentally wrong in what cast() needs to be a full cast function. It needs
the source type information. Even if it's a runtime cast...it needs to know a
specific value is a DATE, as opposed to just an Integer.
So I need to come up with a way to pass the values into cast() with their
type metadata. Without using RelDataType.
I'm thinking to wrap the entire input into cast() with a CastValue object or
something, which includes it's type information.
Variant does already have much of this information in the same way. But it
seems weird to require the user of cast() to wrap everything in a VariantValue.
And that doesn't really deal with arrays. Which I need to.
Here's a real world scenario:
`[1, 1.0, 1.2, "01"]`
`JSON_QUERY('foo' RETURNING VARCHAR ARRAY)`
This should return ["1", "1", "1.2", "01"]
1.0 is a NUMBER in JSON. And as a normal even number, it's natural SQL type
would just be INTEGER. So it SHOULD lose the decimal place on a varchar
conversion. "1.2" is a number, but truly is a fraction, so it should be
considered a FLOAT/DOUBLE, and thus render it's fractional component. The last
one is already a real string. So it just is what it is.
This means I need to have JSON_QUERY here pull the array from JSON, and
associate natural type information with it. And then run THAT through CAST,
which behaves normally. Which it needs that type information to do.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]