Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,6 @@ public TestDocsV3Support() {
super("commands", "commands", CommandDocsTests.class, null, callbacksFromSystemProperty());
}

@Override
protected void renderSignature() throws IOException {
// Not implemented
}

@Override
protected void renderDocs() throws IOException {
// Not implemented
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,13 +560,18 @@ void writeToTempSnippetsDir(String subdir, String str) throws IOException {
callbacks.write(dir, name, "md", str, false);
}

void writeToTempKibanaDir(String subdir, String extension, String str) throws IOException {
protected void writeToTempKibanaDir(String subdir, String extension, String str) throws IOException {
// We have to write to a tempdir because it’s all test are allowed to write to. Gradle can move them.
Path dir = PathUtils.get(System.getProperty("java.io.tmpdir")).resolve("esql").resolve("kibana").resolve(subdir).resolve(category);
Path dir = PathUtils.get(System.getProperty("java.io.tmpdir")).resolve("esql").resolve("kibana").resolve(subdir);
if (category != null) {
dir = dir.resolve(category);
}
callbacks.write(dir, name, extension, str, true);
}

protected abstract void renderSignature() throws IOException;
public void renderSignature() throws IOException {
// Only functions and operators currently have signatures to render, so only they should override this method.
}

protected abstract void renderDocs() throws Exception;

Expand All @@ -586,7 +591,7 @@ private FunctionDocsSupport(String name, Class<?> testClass, Callbacks callbacks
}

@Override
protected void renderSignature() throws IOException {
public void renderSignature() throws IOException {
if (callbacks.supportsRendering() == false) {
return;
}
Expand Down Expand Up @@ -1003,11 +1008,6 @@ public CommandsDocsSupport(
this.observabilityTier = null;
}

@Override
public void renderSignature() throws IOException {
// Unimplemented until we make command docs dynamically generated
}

@Override
public void renderDocs() throws Exception {
// Currently we only render either signatures or kibana definition files,
Expand Down Expand Up @@ -1094,11 +1094,6 @@ public SettingsDocsSupport(QuerySettingDef<?> setting, Class<?> testClass, Callb
this.setting = setting;
}

@Override
public void renderSignature() throws IOException {
// Unimplemented until we make setting docs dynamically generated
}

@Override
public void renderDocs() throws Exception {
// TODO docs for settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import org.apache.lucene.util.BytesRef;
import org.elasticsearch.Build;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.LoggerMessageFormat;
import org.elasticsearch.common.lucene.BytesRefs;
import org.elasticsearch.common.settings.Settings;
Expand All @@ -32,6 +33,7 @@
import org.elasticsearch.xpack.esql.core.type.DataType;
import org.elasticsearch.xpack.esql.expression.Order;
import org.elasticsearch.xpack.esql.expression.UnresolvedNamePattern;
import org.elasticsearch.xpack.esql.expression.function.DocsV3Support;
import org.elasticsearch.xpack.esql.expression.function.EsqlFunctionRegistry;
import org.elasticsearch.xpack.esql.expression.function.UnresolvedFunction;
import org.elasticsearch.xpack.esql.expression.function.aggregate.FilteredExpression;
Expand Down Expand Up @@ -86,7 +88,9 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Stream;

Expand Down Expand Up @@ -4221,8 +4225,7 @@ public void testInlineCast() throws IOException {
.resolve("definition");
Files.createDirectories(dir);
Path file = dir.resolve("inline_cast.json");
try (XContentBuilder report = new XContentBuilder(JsonXContent.jsonXContent, Files.newOutputStream(file))) {
report.humanReadable(true).prettyPrint();
try (XContentBuilder report = JsonXContent.contentBuilder().humanReadable(true).prettyPrint().lfAtEnd()) {
report.startObject();
List<String> namesAndAliases = new ArrayList<>(DataType.namesAndAliases());
if (EsqlCapabilities.Cap.SPATIAL_GRID_TYPES.isEnabled() == false) {
Expand All @@ -4241,13 +4244,29 @@ public void testInlineCast() throws IOException {
org.elasticsearch.xpack.esql.core.expression.function.Function functionCall =
(org.elasticsearch.xpack.esql.core.expression.function.Function) row.fields().get(0).child();
assertThat(functionCall.dataType(), equalTo(expectedType));
report.field(nameOrAlias, registry.snapshotRegistry().functionName(functionCall.getClass()));
report.field(nameOrAlias, registry.snapshotRegistry().functionName(functionCall.getClass()).toLowerCase(Locale.ROOT));
}
report.endObject();
String rendered = Strings.toString(report);
(new TestInlineCastDocsSupport(rendered)).renderDocs();
}
logger.info("Wrote to file: {}", file);
}

private static class TestInlineCastDocsSupport extends DocsV3Support {
private final String rendered;

protected TestInlineCastDocsSupport(String rendered) {
super(null, "inline_cast", StatementParserTests.class, Set::of, new DocsV3Support.WriteCallbacks());
this.rendered = rendered;
}

@Override
protected void renderDocs() throws IOException {
this.writeToTempKibanaDir("definition", "json", rendered);
}
}

public void testTooBigQuery() {
StringBuilder query = new StringBuilder("FROM foo | EVAL a = a");
while (query.length() < EsqlParser.MAX_LENGTH) {
Expand Down
Loading