From 1405773acb56af046d1f6ce40bd0cf4b61eb7ef1 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Wed, 20 Sep 2017 14:15:35 -0400 Subject: [PATCH] Fix serialization for HitExtractorProcessor Also get more information when SQL fails in IT. Original commit: elastic/x-pack-elasticsearch@09f6625274746d64c828434d9b3f3d4dc07ec95a --- .../org/elasticsearch/xpack/sql/RestSqlTestCase.java | 3 +-- .../org/elasticsearch/xpack/sql/cli/ExplainIT.java | 12 ++++++------ .../elasticsearch/xpack/sql/jdbc/DebugSqlSpec.java | 2 +- .../processor/runtime/HitExtractorProcessor.java | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/qa/sql/src/main/java/org/elasticsearch/xpack/sql/RestSqlTestCase.java b/qa/sql/src/main/java/org/elasticsearch/xpack/sql/RestSqlTestCase.java index c0674cd1327..d62b07b59b7 100644 --- a/qa/sql/src/main/java/org/elasticsearch/xpack/sql/RestSqlTestCase.java +++ b/qa/sql/src/main/java/org/elasticsearch/xpack/sql/RestSqlTestCase.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Map; import static java.util.Collections.emptyList; -import static java.util.Collections.emptyMap; import static java.util.Collections.singletonList; import static java.util.Collections.singletonMap; import static java.util.Collections.unmodifiableMap; @@ -161,7 +160,7 @@ public abstract class RestSqlTestCase extends ESRestTestCase { } private Map runSql(HttpEntity sql) throws IOException { - Response response = client().performRequest("POST", "/_sql", emptyMap(), sql); + Response response = client().performRequest("POST", "/_sql", singletonMap("error_trace", "true"), sql); try (InputStream content = response.getEntity().getContent()) { return XContentHelper.convertToMap(JsonXContent.jsonXContent, content, false); } diff --git a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/ExplainIT.java b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/ExplainIT.java index fb881ea7d77..c612bf53424 100644 --- a/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/ExplainIT.java +++ b/sql/cli/src/test/java/org/elasticsearch/xpack/sql/cli/ExplainIT.java @@ -27,14 +27,14 @@ public class ExplainIT extends CliIntegrationTestCase { assertThat(in.readLine(), startsWith("----------")); assertThat(in.readLine(), startsWith("Project[[test_field{r}#")); assertThat(in.readLine(), startsWith("\\_SubQueryAlias[test]")); - assertThat(in.readLine(), startsWith(" \\EsRelation[test][test_field{r}#")); + assertThat(in.readLine(), startsWith(" \\_EsRelation[test][test_field{r}#")); assertEquals("", in.readLine()); command("EXPLAIN (PLAN OPTIMIZED) SELECT * FROM test"); assertThat(in.readLine(), containsString("plan")); assertThat(in.readLine(), startsWith("----------")); assertThat(in.readLine(), startsWith("Project[[test_field{r}#")); - assertThat(in.readLine(), startsWith("\\EsRelation[test][test_field{r}#")); + assertThat(in.readLine(), startsWith("\\_EsRelation[test][test_field{r}#")); assertEquals("", in.readLine()); // TODO in this case we should probably remove the source filtering entirely. Right? It costs but we don't need it. @@ -71,7 +71,7 @@ public class ExplainIT extends CliIntegrationTestCase { assertThat(in.readLine(), startsWith("Project[[i{r}#")); assertThat(in.readLine(), startsWith("\\_Filter[i{r}#")); assertThat(in.readLine(), startsWith(" \\_SubQueryAlias[test]")); - assertThat(in.readLine(), startsWith(" \\EsRelation[test][i{r}#")); + assertThat(in.readLine(), startsWith(" \\_EsRelation[test][i{r}#")); assertEquals("", in.readLine()); command("EXPLAIN (PLAN OPTIMIZED) SELECT * FROM test WHERE i = 2"); @@ -79,7 +79,7 @@ public class ExplainIT extends CliIntegrationTestCase { assertThat(in.readLine(), startsWith("----------")); assertThat(in.readLine(), startsWith("Project[[i{r}#")); assertThat(in.readLine(), startsWith("\\_Filter[i{r}#")); - assertThat(in.readLine(), startsWith(" \\EsRelation[test][i{r}#")); + assertThat(in.readLine(), startsWith(" \\_EsRelation[test][i{r}#")); assertEquals("", in.readLine()); command("EXPLAIN (PLAN EXECUTABLE) SELECT * FROM test WHERE i = 2"); @@ -124,14 +124,14 @@ public class ExplainIT extends CliIntegrationTestCase { assertThat(in.readLine(), startsWith("----------")); assertThat(in.readLine(), startsWith("Aggregate[[],[COUNT(1)#")); assertThat(in.readLine(), startsWith("\\_SubQueryAlias[test]")); - assertThat(in.readLine(), startsWith(" \\EsRelation[test][i{r}#")); + assertThat(in.readLine(), startsWith(" \\_EsRelation[test][i{r}#")); assertEquals("", in.readLine()); command("EXPLAIN (PLAN OPTIMIZED) SELECT COUNT(*) FROM test"); assertThat(in.readLine(), containsString("plan")); assertThat(in.readLine(), startsWith("----------")); assertThat(in.readLine(), startsWith("Aggregate[[],[COUNT(1)#")); - assertThat(in.readLine(), startsWith("\\EsRelation[test][i{r}#")); + assertThat(in.readLine(), startsWith("\\_EsRelation[test][i{r}#")); assertEquals("", in.readLine()); command("EXPLAIN (PLAN EXECUTABLE) SELECT COUNT(*) FROM test"); diff --git a/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DebugSqlSpec.java b/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DebugSqlSpec.java index 3d958e9ce69..5894a12ebc4 100644 --- a/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DebugSqlSpec.java +++ b/sql/jdbc/src/test/java/org/elasticsearch/xpack/sql/jdbc/DebugSqlSpec.java @@ -15,7 +15,7 @@ import java.nio.file.Path; import java.util.List; @TestLogging(JdbcTestUtils.SQL_TRACE) -public class DebugSqlSpec extends SqlSpecIT { +public abstract class DebugSqlSpec extends SqlSpecIT { public static LocalH2 H2 = new LocalH2(); @ParametersFactory(argumentFormatting = PARAM_FORMATTING) diff --git a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/processor/runtime/HitExtractorProcessor.java b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/processor/runtime/HitExtractorProcessor.java index 898d54a1e2d..00b778b2396 100644 --- a/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/processor/runtime/HitExtractorProcessor.java +++ b/sql/server/src/main/java/org/elasticsearch/xpack/sql/expression/function/scalar/processor/runtime/HitExtractorProcessor.java @@ -34,7 +34,7 @@ public class HitExtractorProcessor implements Processor { @Override public void writeTo(StreamOutput out) throws IOException { - extractor.writeTo(out); + out.writeNamedWriteable(extractor); } @Override