[ https://issues.apache.org/jira/browse/PHOENIX-1712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14378453#comment-14378453 ]
ASF GitHub Bot commented on PHOENIX-1712: ----------------------------------------- Github user gabrielreid commented on the pull request: https://github.com/apache/phoenix/pull/47#issuecomment-85666137 The tests you've added look good. It looks like the reason that you're getting issues with the DESC tests is because you're returning the SortOrder of the underlying column in the getSortOrder method. Just removing the getSortOrder method completely should resolve this. It looks like the filter tests also won't work. This will be because the function instance isn't correctly being deserialized/initialized on the server side. Adding in the following method will ensure that the initialization happens correctly: @Override public void readFields(DataInput input) throws IOException { super.readFields(input); init(); } I also took a closer look at the actual testing of the string searching functionality. It looks to me like this could be a lot more simple, although maybe I'm missing something. However, wouldn't it work to just do the following in the evaluate method: @Override public boolean evaluate(Tuple tuple, ImmutableBytesWritable ptr) { if (!getStringExpression().evaluate(tuple, ptr)) { return false; } String sourceStr = (String) PVarchar.INSTANCE.toObject(ptr, getStringExpression().getSortOrder()); int position = sourceStr.indexOf(strToSearch); ptr.set(PInteger.INSTANCE.toBytes(position)); return true; } Could you see if that works ok for all test cases, etc? It looks like the code in the `searchString` method is doing a lot of unnecessary array copying otherwise. > Implementing INSTR function > --------------------------- > > Key: PHOENIX-1712 > URL: https://issues.apache.org/jira/browse/PHOENIX-1712 > Project: Phoenix > Issue Type: Sub-task > Reporter: Naveen Madhire > Assignee: Naveen Madhire > Priority: Minor > Original Estimate: 40h > Remaining Estimate: 40h > > This is sub-task to implement a custom INSTR function just like in Oracle. -- This message was sent by Atlassian JIRA (v6.3.4#6332)