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

ravi commented on PHOENIX-1315:
-------------------------------

Hi [~giacomotaylor]  I tried testing the latest code base against an index 
table . Below is the test method.
  It fails on a call to  ColumnInfo.fromString as the NAME and AGE columns from 
the INDEX table are passed in the format  0:NAME:VARCHAR  from 
ColumnInfoToStringEncoderDecoder . The condition check within ColumnInfo during 
parsing the given string is causing the issue . Do index table have columns 
internally represented as columnfamily:columnname ?  

{code}
@Test
    public void testDataFromIndexTable() throws Exception {    
        try {
                 //create the table
                 String ddl = "CREATE TABLE T"
                        + " (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR , 
AGE INTEGER ) IMMUTABLE_ROWS=true";
                        
                conn.createStatement().execute(ddl);
                
                //create a index table
                String indexDdl = " CREATE INDEX I  ON " + TABLE_NAME + " 
(NAME) INCLUDE (AGE) ";
                conn.createStatement().execute(indexDdl);
                
                //upsert the data.
                final String dml = "UPSERT INTO  T VALUES(?,?,?)";
                PreparedStatement stmt = conn.prepareStatement(dml);
                int rows = 20;
                for(int i = 0 ; i < rows; i++) {
                    stmt.setInt(1, i);
                    stmt.setString(2, "a"+i);
                    stmt.setInt(3, i * 5);
                    stmt.execute();
                }
                conn.commit();
            
                pigServer.registerQuery(String.format(
                        "A = load 'hbase://table/I' using " + 
PhoenixHBaseLoader.class.getName() + "('%s') AS (NAME:chararray,ID:int,AGE:int) 
;",                       zkQuorum));
                //pigServer.registerQuery("B = ORDER A BY AGE;");

                //below code only for viewing the exact stacktrace. will be 
removed once the issue is fixed.
                Iterator<Tuple> iterator = null;
                try {
                        iterator = pigServer.openIterator("A");
                } catch (Exception ex) {
                        ex.printStackTrace();
                }
                int i = 0;
                while (iterator.hasNext()) {
                    Tuple tuple = iterator.next();
                    String name = (String)tuple.get(0);
                    assertEquals("a" + i, name);
                    i++;
                }
            } finally {
                  dropTable("T");
                  dropTable("I");
            }
{code}



> Optimize query for Pig loader
> -----------------------------
>
>                 Key: PHOENIX-1315
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-1315
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: James Taylor
>            Assignee: maghamravikiran
>             Fix For: 4.2, 3.2
>
>         Attachments: PHOENIX-1315.patch, PHOENIX-1315_v2.patch, 
> PHOENIX-1315_v3.patch, PHOENIX-1315_v4.patch
>
>
> I came across this with a recent change I was making. Why is the call to 
> queryPlan.iterators() necessary in PhoenixInputFormat?
> {code}
>     private QueryPlan getQueryPlan(final JobContext context) throws 
> IOException {
>         Preconditions.checkNotNull(context);
>         if(queryPlan == null) {
>             try{
>                 final Connection connection = getConnection();
>                 final String selectStatement = getConf().getSelectStatement();
>                 Preconditions.checkNotNull(selectStatement);
>                 final Statement statement = connection.createStatement();
>                 final PhoenixStatement pstmt = 
> statement.unwrap(PhoenixStatement.class);
>                 this.queryPlan = pstmt.compileQuery(selectStatement);
>                 // FIXME: why is getting the iterator necessary here, as it 
> will
>                 // cause the query to run.
>                 this.queryPlan.iterator();
>             } catch(Exception exception) {
>                 LOG.error(String.format("Failed to get the query plan with 
> error [%s]",exception.getMessage()));
>                 throw new RuntimeException(exception);
>             }
>         }
>         return queryPlan;
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to