[
https://issues.apache.org/jira/browse/PHOENIX-4884?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16599289#comment-16599289
]
Josh Elser commented on PHOENIX-4884:
-------------------------------------
{quote}Just FYI, this is the correct way of doing it:
{quote}
Was this aimed at my "TODO" comment? If so, I meant about the action INSTR was
taking for a zero-length 2nd-argument. I wasn't sure if that was a defined
implementation detail (if search string is empty, always return 0) or if that
was something Phoenix just happened to be doing. Thinking about it more, I
guess it makes no sense to have an empty search string... Let me drop that TODO
:)
{code:java}
sourceStr = (String)child.toObject(ptr, child.getSortOrder());{code}
I think this was a typo and you meant {{PVarChar.INSTANCE.toObject(..)}}. At
least that's what I have here now. I don't see a {{toObject}} in the type
hierarchy of {{Expression}}.
Throwing up a v2. Hopefully I got your suggestions correctly!
> INSTR function should work seamlessly with literal and non-literal arguments
> ----------------------------------------------------------------------------
>
> Key: PHOENIX-4884
> URL: https://issues.apache.org/jira/browse/PHOENIX-4884
> Project: Phoenix
> Issue Type: Bug
> Reporter: Josh Elser
> Assignee: Josh Elser
> Priority: Major
> Fix For: 4.15.0, 5.1.0
>
> Attachments: PHOENIX-4884.001.patch
>
>
> INSTR's documentation reads as though it should support an expression or a
> literal for either argument. At least, it doesn't say that it only supports
> one or the other.
> However, the implementation only handles the case of {{INSTR(expr,
> literal)}}. We can pretty easily make this better and work with any
> combination:
> e.g. {{INSTR(literal, expr)}}, {{INSTR(expr, expr)}}, {{INSTR(literal,
> literal)}}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)