phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruno Dumon (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-853) Support CAST(x as varchar(length)) syntax
Date Sun, 16 Mar 2014 19:40:42 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-853?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13937301#comment-13937301
] 

Bruno Dumon commented on PHOENIX-853:
-------------------------------------

I started looking into it a bit today, but I'm not yet ready to provide a patch.

In fact, the only thing I really need is Phoenix not to stumble over this syntax (= specifying
the length/scale args), without necessarily enforcing/applying them. But probably it's not
a good idea to put it in like that and then change the behavior later on...

PDataType.coerceBytes() already takes desiredMaxLength and desiredScale arguments, but they
are not used, so there is some work involved in implementing that for the various datatypes
(or at least for varchar, I'd need to check on the Optiq side if it produces these casts also
for other data types).

I'll have to check at work how much of a priority this is, but I guess I won't be able to
provide a patch before 3.0.

> Support CAST(x as varchar(length)) syntax
> -----------------------------------------
>
>                 Key: PHOENIX-853
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-853
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Bruno Dumon
>
> I would like Phoenix to recognize casts to varchars that specify lengths, e.g. cast(x
as varchar(10)). It is not an immediate goal to enforce the length, but at least to recongize
the syntax.
> (the reason I'm running into this is because I have sql generated by Optiq which uses
these kinds of constructs)
> I can easily hack the grammar to add this to the CAST grammar, but then I realize that
the data type specification one can put in a cast is the same as what you can put in a column
definition. Therefore, it would make more sense to introduce a separate rule to parse the
data type and reuse that in the cast and column_def rules.
> For arrays, the specification is currently not consistent:
>  * in column_def it is: ar=ARRAY? (lsq=LSQUARE (a=NUMBER)? RSQUARE)?
>  * in casts it is: ar=(ARRAY | (LSQUARE RSQUARE))? RPAREN
> I assume this is not on purpose and can be aligned.
> So in summary, what I'd like to do:
>  * introduce some object to hold the data type information, e.g. "DataTypeDef", which
splits of the pure data type parts from ColumnDef, ColumnDef would then contain a DataTypeDef
>  * introduce a separate parser rule to match the data type specification, and which returns
this new DataTypeDef object
>  * reuse this parser rule in the column_def and cast rules
>  * functionally, casts would stay the same for now
> Alternatively, I can just add "(LPAREN l=NUMBER (COMMA s=NUMBER)? RPAREN)?" to the cast
rule and be done with it.
> WDYT?



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message