diff --git a/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/MetaColumnRequest.java b/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/MetaColumnRequest.java index f2d15fe0951..a5ec38278c6 100644 --- a/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/MetaColumnRequest.java +++ b/sql-clients/jdbc-proto/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/protocol/MetaColumnRequest.java @@ -50,6 +50,6 @@ public class MetaColumnRequest extends Request { @Override public String toString() { - return format(Locale.ROOT, "MetaColumn[index=%, table=%s, column=%s", type, column); + return "MetaColumn[index=" + index + ", type=" + type + " column=" + column + "]"; } } \ No newline at end of file diff --git a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcDatabaseMetaData.java b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcDatabaseMetaData.java index fdb8c9873be..7d42a546b21 100644 --- a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcDatabaseMetaData.java +++ b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/jdbc/JdbcDatabaseMetaData.java @@ -826,7 +826,7 @@ class JdbcDatabaseMetaData implements DatabaseMetaData, JdbcWrapper { row[ 3] = col.name; row[ 4] = col.type; row[ 5] = JdbcUtils.nameOf(col.type); - row[ 6] = col.position; + row[ 6] = col.position; // NOCOMMIT this doesn't seem right row[ 7] = null; row[ 8] = null; row[ 9] = 10; diff --git a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/HttpClient.java b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/HttpClient.java index 53081974c34..79d53e70a64 100644 --- a/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/HttpClient.java +++ b/sql-clients/jdbc/src/main/java/org/elasticsearch/xpack/sql/jdbc/net/client/HttpClient.java @@ -57,7 +57,7 @@ class HttpClient { } BytesArray put(DataOutputConsumer os) throws SQLException { - return put("_jdbc/", os); + return put("_jdbc?error_trace=true", os); // NOCOMMIT Do something with the error trace. Useful for filing bugs and debugging. } BytesArray put(String path, DataOutputConsumer os) throws SQLException { // NOCOMMIT remove path? diff --git a/sql-clients/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DatabaseMetaDataIT.java b/sql-clients/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DatabaseMetaDataIT.java index c04c883b6b9..4e8772f044c 100644 --- a/sql-clients/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DatabaseMetaDataIT.java +++ b/sql-clients/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DatabaseMetaDataIT.java @@ -11,8 +11,6 @@ import java.sql.ResultSetMetaData; import java.sql.SQLException; import java.sql.Types; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.startsWith; /** @@ -167,13 +165,30 @@ public class DatabaseMetaDataIT extends JdbcIntegrationTestCase { assertEquals("test.doc", results.getString(i++)); assertEquals("name", results.getString(i++)); assertEquals(Types.VARCHAR, results.getInt(i++)); + assertEquals("VARCHAR", results.getString(i++)); + assertEquals(1, results.getInt(i++)); + assertEquals(null, results.getString(i++)); + assertEquals(null, results.getString(i++)); + assertEquals(10, results.getInt(i++)); // NOCOMMIT 10 seems wrong to hard code for stuff like strings + // NOCOMMIT I think it'd be more correct to return DatabaseMetaData.columnNullable because all fields are nullable in es + assertEquals(DatabaseMetaData.columnNullableUnknown, results.getInt(i++)); assertEquals(null, results.getString(i++)); assertEquals(null, results.getString(i++)); assertEquals(null, results.getString(i++)); assertEquals(null, results.getString(i++)); assertEquals(null, results.getString(i++)); + assertEquals(1, results.getInt(i++)); + assertEquals("", results.getString(i++)); + assertEquals(null, results.getString(i++)); + assertEquals(null, results.getString(i++)); + assertEquals(null, results.getString(i++)); + assertEquals(null, results.getString(i++)); + assertEquals("", results.getString(i++)); + assertEquals("", results.getString(i++)); assertFalse(results.next()); }); + + // NOCOMMIT add some more columns and test that. } private static void assertColumn(String name, String type, ResultSetMetaData meta, int index) throws SQLException { diff --git a/sql-clients/net-client/src/main/java/org/elasticsearch/xpack/sql/net/client/jre/JreHttpUrlConnection.java b/sql-clients/net-client/src/main/java/org/elasticsearch/xpack/sql/net/client/jre/JreHttpUrlConnection.java index 0c82b0c2e40..131972afd03 100644 --- a/sql-clients/net-client/src/main/java/org/elasticsearch/xpack/sql/net/client/jre/JreHttpUrlConnection.java +++ b/sql-clients/net-client/src/main/java/org/elasticsearch/xpack/sql/net/client/jre/JreHttpUrlConnection.java @@ -71,7 +71,6 @@ public class JreHttpUrlConnection implements Closeable { if (err == null) { response = "server did not return a response"; } else { - // NOCOMMIT figure out why this returns weird characters. Can reproduce with unauthorized. response = new String(IOUtils.asBytes(err).bytes(), StandardCharsets.UTF_8); } throw new ClientException("Protocol/client error; server returned [" + con.getResponseMessage() + "]: " + response);