From dab50f7b77474c0377a0d1eec81b9367187cb882 Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Mon, 8 Jan 2018 14:54:18 +0200 Subject: [PATCH] SQL: correct index name invocation Original commit: elastic/x-pack-elasticsearch@cec6dd6dd9b2bfc8aec8d4fd934bcc7e763a148b --- .../java/org/elasticsearch/xpack/sql/SqlActionIT.java | 10 +++++----- .../xpack/sql/plugin/RestSqlJdbcAction.java | 4 ++-- .../sql/plugin/TransportSqlListColumnsAction.java | 2 +- .../xpack/sql/plugin/TransportSqlListTablesAction.java | 5 ++--- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java index efa67f66461..190f685232e 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/sql/SqlActionIT.java @@ -66,14 +66,14 @@ public class SqlActionIT extends AbstractSqlIntegTestCase { SqlListTablesResponse response = client().prepareExecute(SqlListTablesAction.INSTANCE) .pattern("").get(); List tables = removeInternal(response.getTables()); - assertThat(tables, hasSize(3)); - assertThat(tables, containsInAnyOrder("foo", "bar", "baz")); + assertThat(tables, hasSize(4)); + assertThat(tables, containsInAnyOrder("foo", "bar", "baz", "broken")); response = client().prepareExecute(SqlListTablesAction.INSTANCE).pattern("b*").get(); tables = removeInternal(response.getTables()); - assertThat(tables, hasSize(2)); - assertThat(tables, containsInAnyOrder("bar", "baz")); + assertThat(tables, hasSize(3)); + assertThat(tables, containsInAnyOrder("bar", "baz", "broken")); response = client().prepareExecute(SqlListTablesAction.INSTANCE).pattern("not_found").get(); tables = removeInternal(response.getTables()); @@ -81,7 +81,7 @@ public class SqlActionIT extends AbstractSqlIntegTestCase { response = client().prepareExecute(SqlListTablesAction.INSTANCE).pattern("broken").get(); tables = removeInternal(response.getTables()); - assertThat(tables, emptyCollectionOf(String.class)); + assertThat(tables, hasSize(1)); } diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java index 80d3a77d8a3..07d47dbcc9c 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/RestSqlJdbcAction.java @@ -103,7 +103,7 @@ public class RestSqlJdbcAction extends AbstractSqlProtocolRestAction { private Consumer metaTable(MetaTableRequest request) { String indexPattern = hasText(request.pattern()) ? StringUtils.likeToIndexWildcard(request.pattern(), (char) 0) : "*"; - String regexPattern = hasText(request.pattern()) ? StringUtils.likeToJavaPattern(request.pattern(), (char) 0) : "*"; + String regexPattern = hasText(request.pattern()) ? StringUtils.likeToJavaPattern(request.pattern(), (char) 0) : null; return channel -> indexResolver.resolveNames(indexPattern, regexPattern, toActionListener(channel, list -> new MetaTableResponse(list.stream() @@ -113,7 +113,7 @@ public class RestSqlJdbcAction extends AbstractSqlProtocolRestAction { private Consumer metaColumn(MetaColumnRequest request) { String indexPattern = hasText(request.tablePattern()) ? StringUtils.likeToIndexWildcard(request.tablePattern(), (char) 0) : "*"; - String regexPattern = hasText(request.tablePattern()) ? StringUtils.likeToJavaPattern(request.tablePattern(), (char) 0) : "*"; + String regexPattern = hasText(request.tablePattern()) ? StringUtils.likeToJavaPattern(request.tablePattern(), (char) 0) : null; Pattern columnMatcher = hasText(request.columnPattern()) ? Pattern.compile( StringUtils.likeToJavaPattern(request.columnPattern(), (char) 0)) : null; diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlListColumnsAction.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlListColumnsAction.java index a3781dfd470..62bc45e4c63 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlListColumnsAction.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/plugin/TransportSqlListColumnsAction.java @@ -49,7 +49,7 @@ public class TransportSqlListColumnsAction extends HandledTransportAction listener.onResponse( new SqlListTablesResponse(set.stream()