Reply
Expert Contributor
Posts: 74
Registered: ‎11-24-2017
Accepted Solution

Invalidate metadata using Cloudera Impala JDBC driver

 

I have a java program where I need to do some Impala queries through JDBC, but I need to invalidate metadata before running these queries.

How can I do that trough Cloudera Impala jdbc driver?

 

I've tried the following:

 

            // invalidate metadata and rebuild index on Impala 
            try {
                Statement stmt = impalaConn.createStatement();
                try {
                    String query = "INVALIDATE METADATA;";
                    ResultSet resultSet = stmt.executeQuery(query);
                    while (resultSet.next()) {
                        // do something
                    }
                }                
                finally {
                    stmt.close();
                }
            }
            catch(SQLException ex) {
                while (ex != null)
                {
                    ex.printStackTrace();
                    ex = ex.getNextException();
                }
                System.exit(1);
            }

but I got this error:

 

java.sql.SQLDataException: [Simba][JDBC](11300) A ResultSet was expected but not generated from query "INVALIDATE METADATA;". Query not executed.
        at com.cloudera.impala.exceptions.ExceptionConverter.toSQLException(ExceptionConverter.java:136)
        at com.cloudera.impala.jdbc.common.SStatement.checkCondition(SStatement.java:2274)
        at com.cloudera.impala.jdbc.common.SStatement.executeNoParams(SStatement.java:2704)
        at com.cloudera.impala.jdbc.common.SStatement.executeQuery(SStatement.java:880)
        at ico.az.deploy.TestSuite.testTeradata(TestSuite.java:103)
        at ico.az.deploy.TestSuite.run(TestSuite.java:310)
        at ico.az.deploy.TestSuite.main(TestSuite.java:345)

I am using Cloudera_ImpalaJDBC4_2.5.5.1007 driver.

 

Thanks for any help!

 

 

 

 

Cloudera Employee
Posts: 368
Registered: ‎07-29-2015

Re: Invalidate metadata using Cloudera Impala JDBC driver

Hi @ludof,

 

 "INVALIDATE METADATA" doesn't return a result set (i.e. result rows), so I think you want to use the execute() method instead of executeQuery().

 

- Tim

Expert Contributor
Posts: 74
Registered: ‎11-24-2017

Re: Invalidate metadata using Cloudera Impala JDBC driver

I've finally solved using the executeUpdate method:

 

            // invalidate metadata and rebuild index on Impala 
            try {
                Statement stmt = impalaConn.createStatement();
                try {
                    String query = "INVALIDATE METADATA;";
                    int result = stmt.executeUpdate(query);
                    while (resultSet.next()) {
                        // do something
                    }
                }                
                finally {
                    stmt.close();
                }
            }
            catch(SQLException ex) {
                while (ex != null)
                {
                    ex.printStackTrace();
                    ex = ex.getNextException();
                }
                System.exit(1);
            }

Thanks for help!

Announcements