[
https://issues.apache.org/jira/browse/PHOENIX-1705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14387980#comment-14387980
]
James Taylor commented on PHOENIX-1705:
---------------------------------------
Thanks for the revisions, [~Dumindux]. The reason to do error checking in the
constructor that may also be done in evaluate it to catch errors at compile
time instead of runtime. Compile-time occurs once per statement, while evaluate
is executed once per row. We have more information at runtime, so we can detect
if a VARCHAR is too big to fit into a CHAR(10) field then for example. At
compile time, though, we can detect that a CHAR(15) is too big to fit into a
CHAR(10) without even executing the query, so this is always much better.
For your latest patch, you'll want to replace this check in the constructor:
{code}
+ if (getBaseType().equals(PChar.INSTANCE) &&
getArrayExpr().getMaxLength() != null && getElementExpr().getMaxLength() !=
null &&
+ (getElementExpr().getMaxLength() >
getArrayExpr().getMaxLength())) {
+ throw new DataExceedsCapacityException("Input element max length
greater than max length of an array element");
+ }
{code}
with a call to PDataType.isSizeCompatible(). It does a similar check, but will
also check that the precision and scale of the element being appended fit into
the array given it's constraints (so, no, you shouldn't check only for the CHAR
type - always better to go through the general abstraction as new types may be
added later that have different constraint checks).
> implement ARRAY_APPEND built in function
> ----------------------------------------
>
> Key: PHOENIX-1705
> URL: https://issues.apache.org/jira/browse/PHOENIX-1705
> Project: Phoenix
> Issue Type: Sub-task
> Reporter: Dumindu Buddhika
> Assignee: Dumindu Buddhika
> Attachments:
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function1.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function2.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function3.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function4.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function5.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function6.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function7.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function8.patch,
> PHOENIX-1705_implement_ARRAY_APPEND_built_in_function9.patch
>
>
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)