[ 
https://issues.apache.org/jira/browse/PHOENIX-7527?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

chaijunjie updated PHOENIX-7527:
--------------------------------
    Summary: NPE thrown when extract table schema using sqlline.  (was: NPE 
thrown when exatact table schema use sqlline.)

> NPE thrown when extract table schema using 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
>            Assignee: chaijunjie
>            Priority: Major
>
> The sqlline use stmnt.execute and stmnt.getResultSet to get Data(see 
> [https://github.com/julianhyde/sqlline/blob/f7889ec6058ce404489ed0443755f5885e6258eb/src/main/java/sqlline/Commands.java#L1138]
> ), 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()) {
>             Assert.assertNotNull(rs);
>         }
>     }
> }{code}
>  
> ----------------------------------------------------------------------------
> I think the root cause is here 
> [https://github.com/apache/phoenix/blob/973778f9be425a41b430631097372f8ba8dc9c39/phoenix-core-client/src/main/java/org/apache/phoenix/jdbc/PhoenixStatement.java#L429C1-L431C68]
> , When execute Query, we just add "lastResultSet" to the statment in 
> lastQueryPlan's context, so the lastResultSet in this statment is null...



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

Reply via email to