Skip to content

Commit 70d2c7c

Browse files
authored
Add support for index aliases for SYS COLUMNS command (#53672)
(cherry picked from commit f65e4d6)
1 parent a2e92d0 commit 70d2c7c

File tree

7 files changed

+658
-53
lines changed

7 files changed

+658
-53
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
package org.elasticsearch.xpack.sql.qa.single_node;
8+
9+
import org.elasticsearch.xpack.sql.qa.jdbc.SysColumnsTestCase;
10+
11+
public class SysColumnsIT extends SysColumnsTestCase {
12+
13+
}

x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/jdbc/SysColumnsTestCase.java

Lines changed: 358 additions & 0 deletions
Large diffs are not rendered by default.

x-pack/plugin/sql/qa/src/main/resources/single-node-only/command-sys.csv-spec

Lines changed: 57 additions & 31 deletions
Large diffs are not rendered by default.

x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolver.java

Lines changed: 215 additions & 20 deletions
Large diffs are not rendered by default.

x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/type/InvalidMappedField.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
package org.elasticsearch.xpack.sql.type;
88

99
import org.elasticsearch.xpack.sql.SqlIllegalArgumentException;
10+
import org.elasticsearch.xpack.sql.util.StringUtils;
1011

1112
import java.util.Objects;
1213

@@ -25,6 +26,11 @@ public InvalidMappedField(String name, String errorMessage) {
2526
this.errorMessage = errorMessage;
2627
}
2728

29+
public InvalidMappedField(String name) {
30+
super(name, DataType.UNSUPPORTED, emptyMap(), false);
31+
this.errorMessage = StringUtils.EMPTY;
32+
}
33+
2834
public String errorMessage() {
2935
return errorMessage;
3036
}

x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/util/CollectionUtils.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,11 @@ public static <T> List<T> combine(Collection<? extends T> left, T... entries) {
7272
}
7373
return list;
7474
}
75+
76+
public static int mapSize(int size) {
77+
if (size < 2) {
78+
return size + 1;
79+
}
80+
return (int) (size / 0.75f + 1f);
81+
}
7582
}

x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolverTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ public static IndexResolution merge(EsIndex... indices) {
315315
}
316316

317317
public static List<EsIndex> separate(EsIndex... indices) {
318-
return IndexResolver.separateMappings("*", null, Stream.of(indices).map(EsIndex::name).toArray(String[]::new),
319-
fromMappings(indices));
318+
return IndexResolver.separateMappings(null, Stream.of(indices).map(EsIndex::name).toArray(String[]::new),
319+
fromMappings(indices), null);
320320
}
321321

322322
public static Map<String, Map<String, FieldCapabilities>> fromMappings(EsIndex... indices) {

0 commit comments

Comments
 (0)