Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit 09132da

Browse files
authored
Revert changes ahead of develop branch in master (#551)
* Revert "Rename release notes to use 4 digit versions (#547)" This reverts commit 33c6d3e. * Revert "Opendistro Release 1.9.0 (#532)" This reverts commit 254f2e0. * Revert "Bug fix, support long type for aggregation (#522)" This reverts commit fb2ed91.
1 parent 33c6d3e commit 09132da

File tree

49 files changed

+144
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+144
-297
lines changed

build.gradle

+3-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
buildscript {
1717
ext {
18-
es_version = "7.8.0"
18+
es_version = "7.7.0"
1919
}
2020
// This isn't applying from repositories.gradle so repeating it here
2121
repositories {
@@ -40,7 +40,7 @@ repositories {
4040
}
4141

4242
ext {
43-
opendistroVersion = '1.9.0'
43+
opendistroVersion = '1.8.0'
4444
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
4545
}
4646

@@ -97,10 +97,6 @@ licenseHeaders {
9797
excludes = ['com/amazon/opendistroforelasticsearch/sql/antlr/parser/**']
9898
}
9999

100-
tasks.withType(licenseHeaders.class) {
101-
additionalLicense 'AL ', 'Apache', 'Licensed under the Apache License, Version 2.0 (the "License")'
102-
}
103-
104100
// TODO: need to fix java doc to enable JavaDoc
105101
javadoc.enabled = false
106102
esplugin {
@@ -276,16 +272,14 @@ dependencies {
276272
testCompile group: "org.elasticsearch.client", name: 'transport', version: "${es_version}"
277273

278274
// JDBC drivers for comparison test. Somehow Apache Derby throws security permission exception.
279-
testCompile group: 'com.amazon.opendistroforelasticsearch.client', name: 'opendistro-sql-jdbc', version: '1.8.0.0'
275+
testCompile group: 'com.amazon.opendistroforelasticsearch.client', name: 'opendistro-sql-jdbc', version: '1.3.0.0'
280276
testCompile group: 'com.h2database', name: 'h2', version: '1.4.200'
281277
testCompile group: 'org.xerial', name: 'sqlite-jdbc', version: '3.28.0'
282278
//testCompile group: 'org.apache.derby', name: 'derby', version: '10.15.1.3'
283279
}
284280

285281
apply plugin: 'nebula.ospackage'
286282

287-
validateNebulaPom.enabled = false
288-
289283
// This is afterEvaluate because the bundlePlugin ZIP task is updated afterEvaluate and changes the ZIP name to match the plugin name
290284
afterEvaluate {
291285
ospackage {

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# permissions and limitations under the License.
1414
#
1515

16-
version=1.9.0
16+
version=1.8.0

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# permissions and limitations under the License.
1414
#
1515

16-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
16+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-all.zip
1717
distributionBase=GRADLE_USER_HOME
1818
distributionPath=wrapper/dists
1919
zipStorePath=wrapper/dists

release-notes/opendistro-elasticsearch-sql.release-notes-1.9.0.0.md

-16
This file was deleted.

src/main/java/com/amazon/opendistroforelasticsearch/sql/esdomain/LocalClusterState.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ public void setClusterService(ClusterService clusterService) {
109109
this.clusterService = clusterService;
110110

111111
clusterService.addListener(event -> {
112-
if (event.metadataChanged()) {
112+
if (event.metaDataChanged()) {
113113
// State in cluster service is already changed to event.state() before listener fired
114114
if (LOG.isDebugEnabled()) {
115115
LOG.debug("Metadata in cluster state changed: {}",
116-
new IndexMappings(clusterService.state().metadata()));
116+
new IndexMappings(clusterService.state().metaData()));
117117
}
118118
cache.invalidateAll();
119119
}
@@ -169,8 +169,8 @@ public IndexMappings getFieldMappings(String[] indices, String[] types) {
169169
}
170170

171171
/**
172-
* Get field mappings by index expressions, type and field filter. Because IndexMetadata/MappingMetadata
173-
* is hard to convert to FieldMappingMetadata, custom mapping domain objects are being used here. In future,
172+
* Get field mappings by index expressions, type and field filter. Because IndexMetaData/MappingMetaData
173+
* is hard to convert to FieldMappingMetaData, custom mapping domain objects are being used here. In future,
174174
* it should be moved to domain model layer for all ES specific knowledge.
175175
* <p>
176176
* Note that cluster state may be change inside ES so it's possible to read different state in 2 accesses
@@ -222,7 +222,7 @@ private IndexMappings findMappings(ClusterState state, String[] indices, String[
222222
Function<String, Predicate<String>> fieldFilter) throws IOException {
223223
LOG.debug("Cache didn't help. Load and parse mapping in cluster state");
224224
return new IndexMappings(
225-
state.metadata().findMappings(indices, types, fieldFilter)
225+
state.metaData().findMappings(indices, types, fieldFilter)
226226
);
227227
}
228228

src/main/java/com/amazon/opendistroforelasticsearch/sql/esdomain/mapping/FieldMapping.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Map;
2222

2323
import static java.util.Collections.emptyMap;
24-
import static org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetadata;
24+
import static org.elasticsearch.action.admin.indices.mapping.get.GetFieldMappingsResponse.FieldMappingMetaData;
2525

2626
/**
2727
* Field mapping that parses native ES mapping.
@@ -39,7 +39,7 @@ public class FieldMapping {
3939
/**
4040
* Native mapping information returned from ES
4141
*/
42-
private final Map<String, FieldMappingMetadata> typeMappings;
42+
private final Map<String, FieldMappingMetaData> typeMappings;
4343

4444
/**
4545
* Maps a field name to Field object that specified in query explicitly
@@ -51,7 +51,7 @@ public FieldMapping(String fieldName) {
5151
}
5252

5353
public FieldMapping(String fieldName,
54-
Map<String, FieldMappingMetadata> typeMappings,
54+
Map<String, FieldMappingMetaData> typeMappings,
5555
Map<String, Field> specifiedFieldByNames) {
5656

5757
this.fieldName = fieldName;
@@ -119,16 +119,16 @@ public String path() {
119119
}
120120

121121
/**
122-
* Used to retrieve the type of fields from metadata map structures for both regular and nested fields
122+
* Used to retrieve the type of fields from metaData map structures for both regular and nested fields
123123
*/
124124
@SuppressWarnings("unchecked")
125125
public String type() {
126-
FieldMappingMetadata metadata = typeMappings.get(fieldName);
127-
Map<String, Object> source = metadata.sourceAsMap();
126+
FieldMappingMetaData metaData = typeMappings.get(fieldName);
127+
Map<String, Object> source = metaData.sourceAsMap();
128128
String[] fieldPath = fieldName.split("\\.");
129129

130130
/*
131-
* When field is not nested the metadata source is fieldName -> type
131+
* When field is not nested the metaData source is fieldName -> type
132132
* When it is nested or contains "." in general (ex. fieldName.nestedName) the source is nestedName -> type
133133
*/
134134
String root = (fieldPath.length == 1) ? fieldName : fieldPath[1];

src/main/java/com/amazon/opendistroforelasticsearch/sql/esdomain/mapping/FieldMappings.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
package com.amazon.opendistroforelasticsearch.sql.esdomain.mapping;
1717

18-
import org.elasticsearch.cluster.metadata.MappingMetadata;
18+
import org.elasticsearch.cluster.metadata.MappingMetaData;
1919
import org.json.JSONObject;
2020

2121
import java.util.HashMap;
@@ -61,7 +61,7 @@ public class FieldMappings implements Mappings<Map<String, Object>> {
6161
*/
6262
private final Map<String, Object> fieldMappings;
6363

64-
public FieldMappings(MappingMetadata mappings) {
64+
public FieldMappings(MappingMetaData mappings) {
6565
fieldMappings = mappings.sourceAsMap();
6666
}
6767

src/main/java/com/amazon/opendistroforelasticsearch/sql/esdomain/mapping/IndexMappings.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
package com.amazon.opendistroforelasticsearch.sql.esdomain.mapping;
1717

18-
import org.elasticsearch.cluster.metadata.MappingMetadata;
19-
import org.elasticsearch.cluster.metadata.Metadata;
18+
import org.elasticsearch.cluster.metadata.MappingMetaData;
19+
import org.elasticsearch.cluster.metadata.MetaData;
2020
import org.elasticsearch.common.collect.ImmutableOpenMap;
2121

2222
import java.util.Map;
@@ -55,12 +55,12 @@ public IndexMappings() {
5555
this.indexMappings = emptyMap();
5656
}
5757

58-
public IndexMappings(Metadata metadata) {
59-
this.indexMappings = buildMappings(metadata.indices(),
60-
indexMetadata -> new TypeMappings(indexMetadata.getMappings()));
58+
public IndexMappings(MetaData metaData) {
59+
this.indexMappings = buildMappings(metaData.indices(),
60+
indexMetaData -> new TypeMappings(indexMetaData.getMappings()));
6161
}
6262

63-
public IndexMappings(ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> mappings) {
63+
public IndexMappings(ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetaData>> mappings) {
6464
this.indexMappings = buildMappings(mappings, TypeMappings::new);
6565
}
6666

src/main/java/com/amazon/opendistroforelasticsearch/sql/esdomain/mapping/TypeMappings.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
package com.amazon.opendistroforelasticsearch.sql.esdomain.mapping;
1717

18-
import org.elasticsearch.cluster.metadata.MappingMetadata;
18+
import org.elasticsearch.cluster.metadata.MappingMetaData;
1919
import org.elasticsearch.common.collect.ImmutableOpenMap;
2020

2121
import java.util.Map;
@@ -36,7 +36,7 @@ public class TypeMappings implements Mappings<FieldMappings> {
3636
*/
3737
private final Map<String, FieldMappings> typeMappings;
3838

39-
public TypeMappings(ImmutableOpenMap<String, MappingMetadata> mappings) {
39+
public TypeMappings(ImmutableOpenMap<String, MappingMetaData> mappings) {
4040
typeMappings = buildMappings(mappings, FieldMappings::new);
4141
}
4242

src/main/java/com/amazon/opendistroforelasticsearch/sql/executor/AsyncRestExecutor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private void async(Client client, Map<String, String> params, QueryAction queryA
143143

144144
// Preserve context of calling thread to ensure headers of requests are forwarded when running blocking actions
145145
threadPool.schedule(
146-
LogUtils.withCurrentContext(runnable),
146+
threadPool.preserveContext(LogUtils.withCurrentContext(runnable)),
147147
new TimeValue(0L),
148148
SQL_WORKER_THREAD_POOL_NAME
149149
);

src/main/java/com/amazon/opendistroforelasticsearch/sql/executor/GetIndexRequestRestListener.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
2020
import org.elasticsearch.action.admin.indices.get.GetIndexRequest;
2121
import org.elasticsearch.action.admin.indices.get.GetIndexResponse;
22-
import org.elasticsearch.cluster.metadata.AliasMetadata;
23-
import org.elasticsearch.cluster.metadata.MappingMetadata;
22+
import org.elasticsearch.cluster.metadata.AliasMetaData;
23+
import org.elasticsearch.cluster.metadata.MappingMetaData;
2424
import org.elasticsearch.common.collect.ImmutableOpenMap;
2525
import org.elasticsearch.common.settings.Settings;
2626
import org.elasticsearch.common.xcontent.ToXContent;
@@ -77,22 +77,22 @@ public RestResponse buildResponse(GetIndexResponse getIndexResponse, XContentBui
7777
return new BytesRestResponse(RestStatus.OK, builder);
7878
}
7979

80-
private void writeAliases(List<AliasMetadata> aliases, XContentBuilder builder, ToXContent.Params params)
80+
private void writeAliases(List<AliasMetaData> aliases, XContentBuilder builder, ToXContent.Params params)
8181
throws IOException {
8282
builder.startObject(Fields.ALIASES);
8383
if (aliases != null) {
84-
for (AliasMetadata alias : aliases) {
85-
AliasMetadata.Builder.toXContent(alias, builder, params);
84+
for (AliasMetaData alias : aliases) {
85+
AliasMetaData.Builder.toXContent(alias, builder, params);
8686
}
8787
}
8888
builder.endObject();
8989
}
9090

91-
private void writeMappings(ImmutableOpenMap<String, MappingMetadata> mappings,
91+
private void writeMappings(ImmutableOpenMap<String, MappingMetaData> mappings,
9292
XContentBuilder builder, ToXContent.Params params) throws IOException {
9393
builder.startObject(Fields.MAPPINGS);
9494
if (mappings != null) {
95-
for (ObjectObjectCursor<String, MappingMetadata> typeEntry : mappings) {
95+
for (ObjectObjectCursor<String, MappingMetaData> typeEntry : mappings) {
9696
builder.field(typeEntry.key);
9797
builder.map(typeEntry.value.sourceAsMap());
9898
}
@@ -114,4 +114,4 @@ static class Fields {
114114
static final String SETTINGS = "settings";
115115
static final String WARMERS = "warmers";
116116
}
117-
}
117+
}

src/main/java/com/amazon/opendistroforelasticsearch/sql/executor/cursor/CursorAsyncRestExecutor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private void async(Client client, Map<String, String> params, RestChannel channe
9393

9494
// Preserve context of calling thread to ensure headers of requests are forwarded when running blocking actions
9595
threadPool.schedule(
96-
LogUtils.withCurrentContext(runnable),
96+
threadPool.preserveContext(LogUtils.withCurrentContext(runnable)),
9797
new TimeValue(0L),
9898
SQL_WORKER_THREAD_POOL_NAME
9999
);

src/main/java/com/amazon/opendistroforelasticsearch/sql/executor/format/BindingTupleResultSet.java

+4-12
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,19 @@
2020
import com.amazon.opendistroforelasticsearch.sql.query.planner.core.ColumnNode;
2121
import com.google.common.annotations.VisibleForTesting;
2222

23-
import java.util.Date;
2423
import java.util.HashMap;
2524
import java.util.List;
2625
import java.util.Map;
2726
import java.util.stream.Collectors;
2827

29-
import static com.amazon.opendistroforelasticsearch.sql.executor.format.DateFieldFormatter.FORMAT_JDBC;
30-
3128
/**
3229
* The definition of BindingTuple ResultSet.
3330
*/
3431
public class BindingTupleResultSet extends ResultSet {
3532

3633
public BindingTupleResultSet(List<ColumnNode> columnNodes, List<BindingTuple> bindingTuples) {
3734
this.schema = buildSchema(columnNodes);
38-
this.dataRows = buildDataRows(columnNodes, bindingTuples);
35+
this.dataRows = buildDataRows(bindingTuples);
3936
}
4037

4138
@VisibleForTesting
@@ -50,17 +47,12 @@ public static Schema buildSchema(List<ColumnNode> columnNodes) {
5047
}
5148

5249
@VisibleForTesting
53-
public static DataRows buildDataRows(List<ColumnNode> columnNodes, List<BindingTuple> bindingTuples) {
50+
public static DataRows buildDataRows(List<BindingTuple> bindingTuples) {
5451
List<DataRows.Row> rowList = bindingTuples.stream().map(tuple -> {
5552
Map<String, ExprValue> bindingMap = tuple.getBindingMap();
5653
Map<String, Object> rowMap = new HashMap<>();
57-
for (ColumnNode column : columnNodes) {
58-
String columnName = column.columnName();
59-
Object value = bindingMap.get(columnName).value();
60-
if (column.getType() == Schema.Type.DATE) {
61-
value = DateFormat.getFormattedDate(new Date((Long) value), FORMAT_JDBC);
62-
}
63-
rowMap.put(columnName, value);
54+
for (String s : bindingMap.keySet()) {
55+
rowMap.put(s, bindingMap.get(s).value());
6456
}
6557
return new DataRows.Row(rowMap);
6658
}).collect(Collectors.toList());

src/main/java/com/amazon/opendistroforelasticsearch/sql/executor/format/DateFieldFormatter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
public class DateFieldFormatter {
4141
private static final Logger LOG = LogManager.getLogger(DateFieldFormatter.class);
42-
public static final String FORMAT_JDBC = "yyyy-MM-dd HH:mm:ss.SSS";
42+
private static final String FORMAT_JDBC = "yyyy-MM-dd HH:mm:ss.SSS";
4343
private static final String FORMAT_DELIMITER = "\\|\\|";
4444

4545
private static final String FORMAT_DOT_DATE_AND_TIME = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";

0 commit comments

Comments
 (0)