Description
Select query from tenant owned view fails if using 4.16 client and 5.1 server.
Steps to reproduce:
- Create table (in this case we are creating T1)
- Create an index on that table (I1)
- Create a tenant view on the table (V1) (It doesn't need to be tenant view, verified that global view also fails)
- Run the following query: SELECT * FROM V1
This fails with the following exception:
0: jdbc:phoenix:localhost> select * V1; java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(String.java:1967) at org.apache.phoenix.util.IndexUtil.getDataColumnFamilyName(IndexUtil.java:188) at org.apache.phoenix.util.IndexUtil.getCaseSensitiveDataColumnFullName(IndexUtil.java:200) at org.apache.phoenix.util.IndexUtil.getIndexColumnExpressionStr(IndexUtil.java:722) at org.apache.phoenix.parse.IndexExpressionParseNodeRewriter.<init>(IndexExpressionParseNodeRewriter.java:59) at org.apache.phoenix.optimize.QueryOptimizer.addPlan(QueryOptimizer.java:346) at org.apache.phoenix.optimize.QueryOptimizer.getApplicablePlansForSingleFlatQuery(QueryOptimizer.java:241) at org.apache.phoenix.optimize.QueryOptimizer.getApplicablePlans(QueryOptimizer.java:138) at org.apache.phoenix.optimize.QueryOptimizer.optimize(QueryOptimizer.java:116) at org.apache.phoenix.optimize.QueryOptimizer.optimize(QueryOptimizer.java:102) at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:358) at org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:319) at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53) at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:319) at org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:311) at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:2060) at sqlline.Commands.executeSingleQuery(Commands.java:1054) at sqlline.Commands.execute(Commands.java:1003)
Lines may not exactly match with open source version since we have few additional changes on top of 4.16 open source branch.