Bruno Dumon created PHOENIX-867:
-----------------------------------
Summary: Support length and scale parameters for CAST
Key: PHOENIX-867
URL: https://issues.apache.org/jira/browse/PHOENIX-867
Project: Phoenix
Issue Type: Improvement
Reporter: Bruno Dumon
PHOENIX-853 made the phoenix sql parser recognize length and scale arguments to
sql types in cast statements, thus you can do things like:
{noformat}
select cast(city as varchar(10)) from ...
{noformat}
However, while the parser doesn't stumble over them, these arguments are not
yet enforced.
First thing to do is to figure out the required behavior:
* for varchar it is cutting of the string at the specified length
* for numbers: not sure yet
* not to forget either: char and arrays
The implementation is basically: ExpressionCompiler should pass on length&scale
to CoerceExpression, which in turn should pass them on to
PDataType.coerceBytes().
Then in coerceBytes, we should enforce the parameters, but for performance
reasons we should try to do this only when really necessary.
Note that most expression evaluation in Phoenix happens directly on byte
arrays, cfr. e.g. LengthFunction and SubstrFunction.
--
This message was sent by Atlassian JIRA
(v6.2#6252)