Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Invalidate metadata using Cloudera Impala JDBC driver

avatar
Expert Contributor

 

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!

 

 

 

 

1 ACCEPTED SOLUTION

avatar
Expert Contributor

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!

View solution in original post

2 REPLIES 2

avatar

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

avatar
Expert Contributor

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!