chaijunjie created PHOENIX-7527:
-----------------------------------

             Summary: NPE thrown when exatact Table Schema use sqlline.
                 Key: PHOENIX-7527
                 URL: https://issues.apache.org/jira/browse/PHOENIX-7527
             Project: Phoenix
          Issue Type: Bug
    Affects Versions: 5.2.1
            Reporter: chaijunjie


The sqlline use stmnt.execute and stmnt.getResultSet to get Data, it is 
different with our IT in ShowCreateTableIT, when do this way, the lastResultSet 
will be null...

test:

 
{code:java}
0: jdbc:phoenix:> SHOW CREATE TABLE TEST;
java.lang.NullPointerException
    at sqlline.Rows.<init>(Rows.java:53)
    at sqlline.BufferedRows.<init>(BufferedRows.java:47)
    at sqlline.SqlLine.print(SqlLine.java:1672)
    at sqlline.Commands.executeSingleQuery(Commands.java:1063)
    at sqlline.Commands.execute(Commands.java:1003)
    at sqlline.Commands.sql(Commands.java:967)
    at sqlline.SqlLine.dispatch(SqlLine.java:734)
    at sqlline.SqlLine.begin(SqlLine.java:541)
    at sqlline.SqlLine.start(SqlLine.java:267)
    at sqlline.SqlLine.main(SqlLine.java:206)
  {code}
 

 

UT:

could add this to org.apache.phoenix.end2end.ShowCreateTableIT to reproduce it.

 
{code:java}
@Test
public void testShowCreateTableUpperCase2() throws Exception {
    Properties props = new Properties();
    Connection conn = DriverManager.getConnection(getUrl(), props);
    String tableName = generateUniqueName();
    String schemaName = generateUniqueName();
    String tableFullName = SchemaUtil.getQualifiedTableName(schemaName, 
tableName);
    String ddl = "CREATE TABLE " + tableFullName + "(K VARCHAR NOT NULL PRIMARY 
KEY, INT INTEGER)";
    conn.createStatement().execute(ddl);

    Statement statement = conn.createStatement();
    boolean execute = statement.execute("SHOW CREATE TABLE " + tableFullName);
    if (execute){
        try (ResultSet rs = statement.getResultSet()) {
            String string = rs.getString(1);
            System.out.println(string);
        }
    }
} {code}
 

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to