Databrick JDBC Driver making "List Column SQL" Query Everytime

varunjaincse
New Contributor III

I am trying to use the Databricks JDBC Spark Driver to run sql queries on the SQL Warehouse

Sample connection String

String TOKEN = "<token>";
String HTTP_PATH = "/sql/1.0/warehouses/<sql-warehouse-id>";

final String connStr = "jdbc:spark://discover.cloud.databricks.com:443/default;" +
"TransportMode=http;SSL=1;" +
"HTTPPath=" + HTTP_PATH + ";" +
"AuthMech=11;" +
"Auth_Flow=0;" +
"Auth_AccessToken=" + TOKEN + ";";
try {
final Connection connection = DriverManager.getConnection(connStr);
final Statement statement = connection.createStatement();

final ResultSet rset = statement.executeQuery("SELECT count(*) FROM table_name limit 10");
int columnCount = rset.getMetaData().getColumnCount();

while (rset.next()) {
for (int i = 1; i <= columnCount; i++) {
System.out.print(rset.getString(i) + "\t");
}
System.out.println();
}

connection.close();
} catch (SQLException e) {
System.err.println(e);
}

Above code is always running two SQL on the Warehouse
1. Listing columns 'catalog : Spark, schemaPattern : <schema_name>, tablePattern : <table_name>, columnName : null' -- Take 15+ sec everytime
2. Actual query

I tried reusing the connection object it didn't work. Any idea what going on here?
Using Driver Version: 2.6.18