Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Invalidate metadata using Cloudera Impala JDBC driver

Solved Go to solution

Invalidate metadata using Cloudera Impala JDBC driver

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

Accepted Solutions

Re: Invalidate metadata using Cloudera Impala JDBC driver

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!

2 REPLIES 2

Re: Invalidate metadata using Cloudera Impala JDBC driver

Master Collaborator

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

Re: Invalidate metadata using Cloudera Impala JDBC driver

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!