This is an automated email from the ASF dual-hosted git repository.
airborne pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new bb5533dfa22 [fix](ES Catalog)Only like on keyword can be applied to
wildcard query (#41176)
bb5533dfa22 is described below
commit bb5533dfa224f723b80423112c65bba6d15f2ccf
Author: qiye <[email protected]>
AuthorDate: Thu Nov 7 12:06:11 2024 +0800
[fix](ES Catalog)Only like on keyword can be applied to wildcard query
(#41176)
## Proposed changes
We map `text` and `keyword` both to `string` type in Doris. When enable
`like_push_down`, we translate like to wildcard query in ES, which will
lead unexpected result in `text` field. We should stick to `keyword`
with wildcard query.
1. Add `column2typeMap` in `EsTable` to save the mapping of column_name
to ES field data type.
2. Add new class `EsSchemaCacheValue` to get schema and column to type
map
3. Init `column2typeMap` when cache init and build query process of ES
external table
4. Support LIKE functionCallExpr for Nereids planner.
5. Add end to end like predicate test cases and UTs
---
.../java/org/apache/doris/catalog/EsTable.java | 5 +-
.../doris/datasource/es/EsExternalTable.java | 16 ++-
.../doris/datasource/es/EsSchemaCacheValue.java | 37 ++++++
.../org/apache/doris/datasource/es/EsUtil.java | 19 ++--
.../apache/doris/datasource/es/QueryBuilders.java | 102 ++++++++++-------
.../doris/datasource/es/source/EsScanNode.java | 6 +-
.../doris/external/elasticsearch/EsUtilTest.java | 7 +-
.../external/elasticsearch/QueryBuildersTest.java | 124 ++++++++++++++++-----
.../data/external_table_p0/es/test_es_query.out | 96 ++++++++++++++++
.../external_table_p0/es/test_es_query.groovy | 10 +-
10 files changed, 334 insertions(+), 88 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/catalog/EsTable.java
b/fe/fe-core/src/main/java/org/apache/doris/catalog/EsTable.java
index 83b49475a09..a3ed061ed48 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/EsTable.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/EsTable.java
@@ -119,6 +119,9 @@ public class EsTable extends Table implements
GsonPostProcessable {
// Periodically pull es metadata
private EsMetaStateTracker esMetaStateTracker;
+ // column name -> elasticsearch field data type
+ private Map<String, String> column2typeMap = new HashMap<>();
+
public EsTable() {
super(TableType.ELASTICSEARCH);
}
@@ -366,6 +369,6 @@ public class EsTable extends Table implements
GsonPostProcessable {
}
public List<Column> genColumnsFromEs() {
- return EsUtil.genColumnsFromEs(client, indexName, mappingType, false);
+ return EsUtil.genColumnsFromEs(client, indexName, mappingType, false,
column2typeMap);
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsExternalTable.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsExternalTable.java
index cfde5e794a3..4f05d6d29cd 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsExternalTable.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsExternalTable.java
@@ -25,7 +25,9 @@ import org.apache.doris.thrift.TEsTable;
import org.apache.doris.thrift.TTableDescriptor;
import org.apache.doris.thrift.TTableType;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
/**
@@ -73,13 +75,20 @@ public class EsExternalTable extends ExternalTable {
@Override
public Optional<SchemaCacheValue> initSchema() {
EsRestClient restClient = ((EsExternalCatalog)
catalog).getEsRestClient();
- return Optional.of(new SchemaCacheValue(
- EsUtil.genColumnsFromEs(restClient, name, null,
- ((EsExternalCatalog) catalog).enableMappingEsId())));
+ Map<String, String> column2typeMap = new HashMap<>();
+ List<Column> columns = EsUtil.genColumnsFromEs(restClient, name, null,
+ ((EsExternalCatalog) catalog).enableMappingEsId(),
column2typeMap);
+ return Optional.of(new EsSchemaCacheValue(columns, column2typeMap));
+ }
+
+ public Map<String, String> getColumn2type() {
+ Optional<SchemaCacheValue> schemaCacheValue = getSchemaCacheValue();
+ return schemaCacheValue.map(value -> ((EsSchemaCacheValue)
value).getColumn2typeMap()).orElse(null);
}
private EsTable toEsTable() {
List<Column> schema = getFullSchema();
+ Map<String, String> column2typeMap = getColumn2type();
EsExternalCatalog esCatalog = (EsExternalCatalog) catalog;
EsTable esTable = new EsTable(this.id, this.name, schema,
TableType.ES_EXTERNAL_TABLE);
esTable.setIndexName(name);
@@ -95,6 +104,7 @@ public class EsExternalTable extends ExternalTable {
esTable.setHosts(String.join(",", esCatalog.getNodes()));
esTable.syncTableMetaData();
esTable.setIncludeHiddenIndex(esCatalog.enableIncludeHiddenIndex());
+ esTable.setColumn2typeMap(column2typeMap);
return esTable;
}
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsSchemaCacheValue.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsSchemaCacheValue.java
new file mode 100644
index 00000000000..e53eae676e8
--- /dev/null
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsSchemaCacheValue.java
@@ -0,0 +1,37 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.datasource.es;
+
+import org.apache.doris.catalog.Column;
+import org.apache.doris.datasource.SchemaCacheValue;
+
+import java.util.List;
+import java.util.Map;
+
+public class EsSchemaCacheValue extends SchemaCacheValue {
+ public Map<String, String> column2typeMap;
+
+ public EsSchemaCacheValue(List<Column> columns, Map<String, String>
column2typeMap) {
+ super(columns);
+ this.column2typeMap = column2typeMap;
+ }
+
+ public Map<String, String> getColumn2typeMap() {
+ return column2typeMap;
+ }
+}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsUtil.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsUtil.java
index 0ee9bbd1f77..55fea86718a 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsUtil.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/EsUtil.java
@@ -189,18 +189,18 @@ public class EsUtil {
* Add mappingEsId config in es external catalog.
**/
public static List<Column> genColumnsFromEs(EsRestClient client, String
indexName, String mappingType,
- boolean mappingEsId) {
+ boolean mappingEsId, Map<String, String> column2typeMap) {
String mapping = client.getMapping(indexName);
ObjectNode mappings = getMapping(mapping);
// Get array_fields while removing _meta property.
List<String> arrayFields = new ArrayList<>();
ObjectNode rootSchema = getRootSchema(mappings, mappingType,
arrayFields);
- return genColumnsFromEs(indexName, mappingType, rootSchema,
mappingEsId, arrayFields);
+ return genColumnsFromEs(indexName, mappingType, rootSchema,
mappingEsId, arrayFields, column2typeMap);
}
@VisibleForTesting
public static List<Column> genColumnsFromEs(String indexName, String
mappingType, ObjectNode rootSchema,
- boolean mappingEsId, List<String> arrayFields) {
+ boolean mappingEsId, List<String> arrayFields, Map<String, String>
column2typeMap) {
List<Column> columns = new ArrayList<>();
if (mappingEsId) {
Column column = new Column();
@@ -220,7 +220,8 @@ public class EsUtil {
while (iterator.hasNext()) {
String fieldName = iterator.next();
ObjectNode fieldValue = (ObjectNode) mappingProps.get(fieldName);
- Column column = parseEsField(fieldName,
replaceFieldAlias(mappingProps, fieldValue), arrayFields);
+ Column column = parseEsField(fieldName,
replaceFieldAlias(mappingProps, fieldValue), arrayFields,
+ column2typeMap);
columns.add(column);
}
return columns;
@@ -245,7 +246,8 @@ public class EsUtil {
return fieldValue;
}
- private static Column parseEsField(String fieldName, ObjectNode
fieldValue, List<String> arrayFields) {
+ private static Column parseEsField(String fieldName, ObjectNode
fieldValue, List<String> arrayFields,
+ Map<String, String> column2typeMap) {
Column column = new Column();
column.setName(fieldName);
column.setIsKey(true);
@@ -256,6 +258,7 @@ public class EsUtil {
if (fieldValue.has("type")) {
String typeStr = fieldValue.get("type").asText();
column.setComment("Elasticsearch type is " + typeStr);
+ column2typeMap.put(fieldName, typeStr);
// reference
https://www.elastic.co/guide/en/elasticsearch/reference/8.3/sql-data-types.html
switch (typeStr) {
case "null":
@@ -298,15 +301,17 @@ public class EsUtil {
type = ScalarType.createStringType();
break;
case "nested":
- case "object":
type = Type.JSONB;
break;
default:
type = Type.UNSUPPORTED;
}
} else {
+ // When there is no explicit type in mapping, it indicates this
type is an `object` in Elasticsearch.
+ // reference:
https://www.elastic.co/guide/en/elasticsearch/reference/current/object.html
type = Type.JSONB;
- column.setComment("Elasticsearch no type");
+ column.setComment("Elasticsearch type is object");
+ column2typeMap.put(fieldName, "object");
}
if (arrayFields.contains(fieldName)) {
column.setType(ArrayType.create(type, true));
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/QueryBuilders.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/QueryBuilders.java
index 19930bb2b14..40c11362692 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/QueryBuilders.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/QueryBuilders.java
@@ -70,14 +70,14 @@ public final class QueryBuilders {
* Generate dsl from compound expr.
**/
private static QueryBuilder toCompoundEsDsl(Expr expr, List<Expr>
notPushDownList,
- Map<String, String> fieldsContext, BuilderOptions builderOptions) {
+ Map<String, String> fieldsContext, BuilderOptions builderOptions,
Map<String, String> column2typeMap) {
CompoundPredicate compoundPredicate = (CompoundPredicate) expr;
switch (compoundPredicate.getOp()) {
case AND: {
QueryBuilder left = toEsDsl(compoundPredicate.getChild(0),
notPushDownList, fieldsContext,
- builderOptions);
+ builderOptions, column2typeMap);
QueryBuilder right = toEsDsl(compoundPredicate.getChild(1),
notPushDownList, fieldsContext,
- builderOptions);
+ builderOptions, column2typeMap);
if (left != null && right != null) {
return QueryBuilders.boolQuery().must(left).must(right);
}
@@ -86,9 +86,9 @@ public final class QueryBuilders {
case OR: {
int beforeSize = notPushDownList.size();
QueryBuilder left = toEsDsl(compoundPredicate.getChild(0),
notPushDownList, fieldsContext,
- builderOptions);
+ builderOptions, column2typeMap);
QueryBuilder right = toEsDsl(compoundPredicate.getChild(1),
notPushDownList, fieldsContext,
- builderOptions);
+ builderOptions, column2typeMap);
int afterSize = notPushDownList.size();
if (left != null && right != null) {
return
QueryBuilders.boolQuery().should(left).should(right);
@@ -101,7 +101,7 @@ public final class QueryBuilders {
}
case NOT: {
QueryBuilder child = toEsDsl(compoundPredicate.getChild(0),
notPushDownList, fieldsContext,
- builderOptions);
+ builderOptions, column2typeMap);
if (child != null) {
return QueryBuilders.boolQuery().mustNot(child);
}
@@ -122,10 +122,10 @@ public final class QueryBuilders {
return expr;
}
- public static QueryBuilder toEsDsl(Expr expr) {
+ public static QueryBuilder toEsDsl(Expr expr, Map<String, String>
column2typeMap) {
return toEsDsl(expr, new ArrayList<>(), new HashMap<>(),
BuilderOptions.builder().likePushDown(Boolean.parseBoolean(EsResource.LIKE_PUSH_DOWN_DEFAULT_VALUE))
- .build());
+ .build(), column2typeMap);
}
private static TExprOpcode flipOpCode(TExprOpcode opCode) {
@@ -185,32 +185,44 @@ public final class QueryBuilders {
return
QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery(column));
}
- private static QueryBuilder parseLikePredicate(Expr expr, String column) {
- LikePredicate likePredicate = (LikePredicate) expr;
- if (likePredicate.getOp().equals(Operator.LIKE)) {
- char[] chars =
likePredicate.getChild(1).getStringValue().toCharArray();
- // example of translation :
- // abc_123 ===> abc?123
- // abc%ykz ===> abc*123
- // %abc123 ===> *abc123
- // _abc123 ===> ?abc123
- // \\_abc1 ===> \\_abc1
- // abc\\_123 ===> abc\\_123
- // abc\\%123 ===> abc\\%123
- // NOTE. user must input sql like 'abc\\_123' or 'abc\\%ykz'
- for (int i = 0; i < chars.length; i++) {
- if (chars[i] == '_' || chars[i] == '%') {
- if (i == 0) {
- chars[i] = (chars[i] == '_') ? '?' : '*';
- } else if (chars[i - 1] != '\\') {
- chars[i] = (chars[i] == '_') ? '?' : '*';
- }
- }
+ private static QueryBuilder parseLikeExpression(Expr expr, String column) {
+ String pattern;
+ if (expr instanceof LikePredicate) {
+ LikePredicate likePredicate = (LikePredicate) expr;
+ if (!likePredicate.getOp().equals(Operator.LIKE)) {
+ return QueryBuilders.wildcardQuery(column,
likePredicate.getChild(1).getStringValue());
+ }
+ pattern = likePredicate.getChild(1).getStringValue();
+ } else if (expr instanceof FunctionCallExpr) {
+ FunctionCallExpr functionCallExpr = (FunctionCallExpr) expr;
+ String fnName = functionCallExpr.getFnName().getFunction();
+ if (!fnName.equalsIgnoreCase("like")) {
+ return QueryBuilders.wildcardQuery(column,
functionCallExpr.getChild(1).getStringValue());
}
- return QueryBuilders.wildcardQuery(column, new String(chars));
+ pattern = functionCallExpr.getChild(1).getStringValue();
} else {
- return QueryBuilders.wildcardQuery(column,
likePredicate.getChild(1).getStringValue());
+ throw new IllegalArgumentException("Unsupported expression type");
+ }
+ char[] chars = pattern.toCharArray();
+ // example of translation :
+ // abc_123 ===> abc?123
+ // abc%ykz ===> abc*123
+ // %abc123 ===> *abc123
+ // _abc123 ===> ?abc123
+ // \\_abc1 ===> \\_abc1
+ // abc\\_123 ===> abc\\_123
+ // abc\\%123 ===> abc\\%123
+ // NOTE. user must input sql like 'abc\\_123' or 'abc\\%ykz'
+ for (int i = 0; i < chars.length; i++) {
+ if (chars[i] == '_' || chars[i] == '%') {
+ if (i == 0) {
+ chars[i] = (chars[i] == '_') ? '?' : '*';
+ } else if (chars[i - 1] != '\\') {
+ chars[i] = (chars[i] == '_') ? '?' : '*';
+ }
+ }
}
+ return QueryBuilders.wildcardQuery(column, new String(chars));
}
private static QueryBuilder parseInPredicate(Expr expr, String column,
boolean needDateCompat) {
@@ -257,18 +269,18 @@ public final class QueryBuilders {
* Doris expr to es dsl.
**/
public static QueryBuilder toEsDsl(Expr expr, List<Expr> notPushDownList,
Map<String, String> fieldsContext,
- BuilderOptions builderOptions) {
+ BuilderOptions builderOptions, Map<String, String> column2typeMap)
{
if (expr == null) {
return null;
}
// esquery functionCallExpr will be rewritten to castExpr in where
clause rewriter,
// so we get the functionCallExpr here.
if (expr instanceof CastExpr) {
- return toEsDsl(expr.getChild(0), notPushDownList, fieldsContext,
builderOptions);
+ return toEsDsl(expr.getChild(0), notPushDownList, fieldsContext,
builderOptions, column2typeMap);
}
// CompoundPredicate, `between` also converted to CompoundPredicate.
if (expr instanceof CompoundPredicate) {
- return toCompoundEsDsl(expr, notPushDownList, fieldsContext,
builderOptions);
+ return toCompoundEsDsl(expr, notPushDownList, fieldsContext,
builderOptions, column2typeMap);
}
TExprOpcode opCode = expr.getOpcode();
boolean isFlip = false;
@@ -287,6 +299,7 @@ public final class QueryBuilders {
return null;
}
+ String type = column2typeMap.get(column);
// Check whether the date type need compat, it must before keyword
replace.
List<String> needCompatDateFields =
builderOptions.getNeedCompatDateFields();
boolean needDateCompat = needCompatDateFields != null &&
needCompatDateFields.contains(column);
@@ -313,24 +326,29 @@ public final class QueryBuilders {
return parseIsNullPredicate(expr, column);
}
if (expr instanceof LikePredicate) {
- if (!builderOptions.isLikePushDown()) {
+ if (builderOptions.isLikePushDown() && "keyword".equals(type)) {
+ // only keyword can apply wildcard query
+ return parseLikeExpression(expr, column);
+ } else {
notPushDownList.add(expr);
return null;
- } else {
- return parseLikePredicate(expr, column);
}
}
if (expr instanceof InPredicate) {
return parseInPredicate(expr, column, needDateCompat);
}
if (expr instanceof FunctionCallExpr) {
- FunctionCallExpr functionCallExpr = (FunctionCallExpr) expr;
- // current only esquery functionCallExpr can be push down to ES
- if (!"esquery".equals(functionCallExpr.getFnName().getFunction()))
{
+ // current only esquery and like applied in keyword
functionCallExpr can be push down to ES
+ String fnName = ((FunctionCallExpr)
expr).getFnName().getFunction();
+ if ("esquery".equals(fnName)) {
+ return parseFunctionCallExpr(expr);
+ } else if (builderOptions.isLikePushDown() &&
"like".equalsIgnoreCase(fnName) && "keyword".equals(type)) {
+ return parseLikeExpression(expr, column);
+ } else if (builderOptions.isLikePushDown() &&
"regexp".equalsIgnoreCase(fnName)) {
+ return parseLikeExpression(expr, column);
+ } else {
notPushDownList.add(expr);
return null;
- } else {
- return parseFunctionCallExpr(expr);
}
}
return null;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/source/EsScanNode.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/source/EsScanNode.java
index a56c4473321..0afb426188e 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/es/source/EsScanNode.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/es/source/EsScanNode.java
@@ -365,10 +365,14 @@ public class EsScanNode extends ExternalScanNode {
boolean hasFilter = false;
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
List<Expr> notPushDownList = new ArrayList<>();
+ if (table.getColumn2typeMap() == null) {
+ table.genColumnsFromEs();
+ }
for (Expr expr : conjuncts) {
QueryBuilder queryBuilder = QueryBuilders.toEsDsl(expr,
notPushDownList, fieldsContext,
BuilderOptions.builder().likePushDown(table.isLikePushDown())
-
.needCompatDateFields(table.needCompatDateFields()).build());
+
.needCompatDateFields(table.needCompatDateFields()).build(),
+ table.getColumn2typeMap());
if (queryBuilder != null) {
hasFilter = true;
boolQueryBuilder.must(queryBuilder);
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java
b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java
index a58b785dbca..75a30453d75 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/EsUtilTest.java
@@ -39,6 +39,7 @@ import org.junit.rules.ExpectedException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
/**
@@ -226,7 +227,7 @@ public class EsUtilTest extends EsTestCase {
public void testDateType() throws IOException, URISyntaxException {
ObjectNode testDateFormat = EsUtil.getRootSchema(
EsUtil.getMapping(loadJsonFromFile("data/es/test_date_format.json")), null, new
ArrayList<>());
- List<Column> parseColumns =
EsUtil.genColumnsFromEs("test_date_format", null, testDateFormat, false, new
ArrayList<>());
+ List<Column> parseColumns =
EsUtil.genColumnsFromEs("test_date_format", null, testDateFormat, false, new
ArrayList<>(), new HashMap<>());
Assertions.assertEquals(8, parseColumns.size());
for (Column column : parseColumns) {
String name = column.getName();
@@ -259,7 +260,7 @@ public class EsUtilTest extends EsTestCase {
public void testFieldAlias() throws IOException, URISyntaxException {
ObjectNode testFieldAlias = EsUtil.getRootSchema(
EsUtil.getMapping(loadJsonFromFile("data/es/test_field_alias.json")), null, new
ArrayList<>());
- List<Column> parseColumns =
EsUtil.genColumnsFromEs("test_field_alias", null, testFieldAlias, true, new
ArrayList<>());
+ List<Column> parseColumns =
EsUtil.genColumnsFromEs("test_field_alias", null, testFieldAlias, true, new
ArrayList<>(), new HashMap<>());
Assertions.assertEquals("datetimev2(0)",
parseColumns.get(2).getType().toSql());
Assertions.assertEquals("text", parseColumns.get(4).getType().toSql());
}
@@ -269,7 +270,7 @@ public class EsUtilTest extends EsTestCase {
ObjectNode testFieldAlias = EsUtil.getRootSchema(
EsUtil.getMapping(loadJsonFromFile("data/es/es6_dynamic_complex_type.json")),
null, new ArrayList<>());
List<Column> columns = EsUtil.genColumnsFromEs("test_complex_type",
"complex_type", testFieldAlias, true,
- new ArrayList<>());
+ new ArrayList<>(), new HashMap<>());
Assertions.assertEquals(3, columns.size());
}
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/QueryBuildersTest.java
b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/QueryBuildersTest.java
index ca5344990e7..69eab5198aa 100644
---
a/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/QueryBuildersTest.java
+++
b/fe/fe-core/src/test/java/org/apache/doris/external/elasticsearch/QueryBuildersTest.java
@@ -71,30 +71,32 @@ public class QueryBuildersTest {
Expr ltExpr = new BinaryPredicate(Operator.LT, k1, intLiteral);
Expr gtExpr = new BinaryPredicate(Operator.GT, k1, intLiteral);
Expr efnExpr = new BinaryPredicate(Operator.EQ_FOR_NULL, new
SlotRef(null, "k1"), new IntLiteral(3));
- Assertions.assertEquals("{\"term\":{\"k1\":3}}",
QueryBuilders.toEsDsl(eqExpr).toJson());
+ Map<String, String> column2typeMap = new HashMap<>();
+ Assertions.assertEquals("{\"term\":{\"k1\":3}}",
QueryBuilders.toEsDsl(eqExpr, column2typeMap).toJson());
Assertions.assertEquals("{\"bool\":{\"must_not\":{\"term\":{\"k1\":3}}}}",
- QueryBuilders.toEsDsl(neExpr).toJson());
- Assertions.assertEquals("{\"range\":{\"k1\":{\"lte\":3}}}",
QueryBuilders.toEsDsl(leExpr).toJson());
- Assertions.assertEquals("{\"range\":{\"k1\":{\"gte\":3}}}",
QueryBuilders.toEsDsl(geExpr).toJson());
- Assertions.assertEquals("{\"range\":{\"k1\":{\"lt\":3}}}",
QueryBuilders.toEsDsl(ltExpr).toJson());
- Assertions.assertEquals("{\"range\":{\"k1\":{\"gt\":3}}}",
QueryBuilders.toEsDsl(gtExpr).toJson());
- Assertions.assertEquals("{\"term\":{\"k1\":3}}",
QueryBuilders.toEsDsl(efnExpr).toJson());
+ QueryBuilders.toEsDsl(neExpr, column2typeMap).toJson());
+ Assertions.assertEquals("{\"range\":{\"k1\":{\"lte\":3}}}",
QueryBuilders.toEsDsl(leExpr, column2typeMap).toJson());
+ Assertions.assertEquals("{\"range\":{\"k1\":{\"gte\":3}}}",
QueryBuilders.toEsDsl(geExpr, column2typeMap).toJson());
+ Assertions.assertEquals("{\"range\":{\"k1\":{\"lt\":3}}}",
QueryBuilders.toEsDsl(ltExpr, column2typeMap).toJson());
+ Assertions.assertEquals("{\"range\":{\"k1\":{\"gt\":3}}}",
QueryBuilders.toEsDsl(gtExpr, column2typeMap).toJson());
+ Assertions.assertEquals("{\"term\":{\"k1\":3}}",
QueryBuilders.toEsDsl(efnExpr, column2typeMap).toJson());
SlotRef k2 = new SlotRef(null, "k2");
Expr dateTimeLiteral = new StringLiteral("2023-02-19 22:00:00");
Expr dateTimeEqExpr = new BinaryPredicate(Operator.EQ, k2,
dateTimeLiteral);
Assertions.assertEquals("{\"term\":{\"k2\":\"2023-02-19T22:00:00.000+08:00\"}}",
QueryBuilders.toEsDsl(dateTimeEqExpr, new ArrayList<>(), new
HashMap<>(),
-
BuilderOptions.builder().needCompatDateFields(Lists.newArrayList("k2")).build()).toJson());
+
BuilderOptions.builder().needCompatDateFields(Lists.newArrayList("k2")).build(),
+ new HashMap<>()).toJson());
SlotRef k3 = new SlotRef(null, "k3");
Expr stringLiteral = new StringLiteral("");
Expr stringNeExpr = new BinaryPredicate(Operator.NE, k3,
stringLiteral);
Assertions.assertEquals("{\"bool\":{\"must\":{\"exists\":{\"field\":\"k3\"}},\"must_not\":{\"term\":{\"k3\":\"\"}}}}",
- QueryBuilders.toEsDsl(stringNeExpr).toJson());
+ QueryBuilders.toEsDsl(stringNeExpr, column2typeMap).toJson());
stringLiteral = new StringLiteral("message");
stringNeExpr = new BinaryPredicate(Operator.NE, k3, stringLiteral);
Assertions.assertEquals("{\"bool\":{\"must_not\":{\"term\":{\"k3\":\"message\"}}}}",
- QueryBuilders.toEsDsl(stringNeExpr).toJson());
+ QueryBuilders.toEsDsl(stringNeExpr, column2typeMap).toJson());
}
@Test
@@ -103,6 +105,7 @@ public class QueryBuildersTest {
IntLiteral intLiteral1 = new IntLiteral(3);
SlotRef k2 = new SlotRef(null, "k2");
IntLiteral intLiteral2 = new IntLiteral(5);
+ Map<String, String> column2typeMap = new HashMap<>();
BinaryPredicate binaryPredicate1 = new BinaryPredicate(Operator.EQ,
k1, intLiteral1);
BinaryPredicate binaryPredicate2 = new BinaryPredicate(Operator.GT,
k2, intLiteral2);
CompoundPredicate andPredicate = new
CompoundPredicate(CompoundPredicate.Operator.AND, binaryPredicate1,
@@ -111,21 +114,22 @@ public class QueryBuildersTest {
binaryPredicate2);
CompoundPredicate notPredicate = new
CompoundPredicate(CompoundPredicate.Operator.NOT, binaryPredicate1, null);
Assertions.assertEquals("{\"bool\":{\"must\":[{\"term\":{\"k1\":3}},{\"range\":{\"k2\":{\"gt\":5}}}]}}",
- QueryBuilders.toEsDsl(andPredicate).toJson());
+ QueryBuilders.toEsDsl(andPredicate, column2typeMap).toJson());
Assertions.assertEquals("{\"bool\":{\"should\":[{\"term\":{\"k1\":3}},{\"range\":{\"k2\":{\"gt\":5}}}]}}",
- QueryBuilders.toEsDsl(orPredicate).toJson());
+ QueryBuilders.toEsDsl(orPredicate, column2typeMap).toJson());
Assertions.assertEquals("{\"bool\":{\"must_not\":{\"term\":{\"k1\":3}}}}",
- QueryBuilders.toEsDsl(notPredicate).toJson());
+ QueryBuilders.toEsDsl(notPredicate, column2typeMap).toJson());
}
@Test
public void testIsNullPredicateConvertEsDsl() {
SlotRef k1 = new SlotRef(null, "k1");
+ Map<String, String> column2typeMap = new HashMap<>();
IsNullPredicate isNullPredicate = new IsNullPredicate(k1, false);
IsNullPredicate isNotNullPredicate = new IsNullPredicate(k1, true);
Assertions.assertEquals("{\"bool\":{\"must_not\":{\"exists\":{\"field\":\"k1\"}}}}",
- QueryBuilders.toEsDsl(isNullPredicate).toJson());
- Assertions.assertEquals("{\"exists\":{\"field\":\"k1\"}}",
QueryBuilders.toEsDsl(isNotNullPredicate).toJson());
+ QueryBuilders.toEsDsl(isNullPredicate,
column2typeMap).toJson());
+ Assertions.assertEquals("{\"exists\":{\"field\":\"k1\"}}",
QueryBuilders.toEsDsl(isNotNullPredicate, column2typeMap).toJson());
}
@Test
@@ -137,13 +141,28 @@ public class QueryBuildersTest {
LikePredicate likePredicate1 = new
LikePredicate(LikePredicate.Operator.LIKE, k1, stringLiteral1);
LikePredicate regexPredicate = new
LikePredicate(LikePredicate.Operator.REGEXP, k1, stringLiteral2);
LikePredicate likePredicate2 = new
LikePredicate(LikePredicate.Operator.LIKE, k1, stringLiteral3);
- Assertions.assertEquals("{\"wildcard\":{\"k1\":\"*1*\"}}",
QueryBuilders.toEsDsl(likePredicate1).toJson());
- Assertions.assertEquals("{\"wildcard\":{\"k1\":\"*1*\"}}",
QueryBuilders.toEsDsl(regexPredicate).toJson());
- Assertions.assertEquals("{\"wildcard\":{\"k1\":\"1?2\"}}",
QueryBuilders.toEsDsl(likePredicate2).toJson());
+ Map<String, String> column2typeMap = new HashMap<>();
+ column2typeMap.put("k1", "keyword");
+ Assertions.assertEquals("{\"wildcard\":{\"k1\":\"*1*\"}}",
QueryBuilders.toEsDsl(likePredicate1, column2typeMap).toJson());
+ Assertions.assertEquals("{\"wildcard\":{\"k1\":\"*1*\"}}",
QueryBuilders.toEsDsl(regexPredicate, column2typeMap).toJson());
+ Assertions.assertEquals("{\"wildcard\":{\"k1\":\"1?2\"}}",
QueryBuilders.toEsDsl(likePredicate2, column2typeMap).toJson());
List<Expr> notPushDownList = new ArrayList<>();
Assertions.assertNull(QueryBuilders.toEsDsl(likePredicate2,
notPushDownList, new HashMap<>(),
- BuilderOptions.builder().likePushDown(false).build()));
+ BuilderOptions.builder().likePushDown(false).build(),
column2typeMap));
Assertions.assertFalse(notPushDownList.isEmpty());
+
+ // like can not push down
+ column2typeMap.clear();
+ notPushDownList.clear();
+ column2typeMap.put("k1", "text");
+ Assertions.assertNull(QueryBuilders.toEsDsl(likePredicate1,
notPushDownList, new HashMap<>(),
+ BuilderOptions.builder().likePushDown(true).build(),
column2typeMap));
+ Assertions.assertNull(QueryBuilders.toEsDsl(likePredicate2,
notPushDownList, new HashMap<>(),
+ BuilderOptions.builder().likePushDown(true).build(),
column2typeMap));
+ Assertions.assertNull(QueryBuilders.toEsDsl(regexPredicate,
notPushDownList, new HashMap<>(),
+ BuilderOptions.builder().likePushDown(true).build(),
column2typeMap));
+
+ Assertions.assertEquals(3, notPushDownList.size());
}
@Test
@@ -156,9 +175,10 @@ public class QueryBuildersTest {
intLiterals.add(intLiteral2);
InPredicate isInPredicate = new InPredicate(k1, intLiterals, false);
InPredicate isNotInPredicate = new InPredicate(k1, intLiterals, true);
- Assertions.assertEquals("{\"terms\":{\"k1\":[3,5]}}",
QueryBuilders.toEsDsl(isInPredicate).toJson());
+ Map<String, String> column2typeMap = new HashMap<>();
+ Assertions.assertEquals("{\"terms\":{\"k1\":[3,5]}}",
QueryBuilders.toEsDsl(isInPredicate, column2typeMap).toJson());
Assertions.assertEquals("{\"bool\":{\"must_not\":{\"terms\":{\"k1\":[3,5]}}}}",
- QueryBuilders.toEsDsl(isNotInPredicate).toJson());
+ QueryBuilders.toEsDsl(isNotInPredicate,
column2typeMap).toJson());
}
@Test
@@ -166,11 +186,12 @@ public class QueryBuildersTest {
SlotRef k1 = new SlotRef(null, "k1");
String str = "{\"bool\":{\"must_not\":{\"terms\":{\"k1\":[3,5]}}}}";
StringLiteral stringLiteral = new StringLiteral(str);
+ Map<String, String> column2typeMap = new HashMap<>();
List<Expr> exprs = new ArrayList<>();
exprs.add(k1);
exprs.add(stringLiteral);
FunctionCallExpr functionCallExpr = new FunctionCallExpr("esquery",
exprs);
- Assertions.assertEquals(str,
QueryBuilders.toEsDsl(functionCallExpr).toJson());
+ Assertions.assertEquals(str, QueryBuilders.toEsDsl(functionCallExpr,
column2typeMap).toJson());
SlotRef k2 = new SlotRef(null, "k2");
IntLiteral intLiteral = new IntLiteral(5);
@@ -179,7 +200,44 @@ public class QueryBuildersTest {
functionCallExpr);
Assertions.assertEquals(
"{\"bool\":{\"must\":[{\"term\":{\"k2\":5}},{\"bool\":{\"must_not\":{\"terms\":{\"k1\":[3,5]}}}}]}}",
- QueryBuilders.toEsDsl(compoundPredicate).toJson());
+ QueryBuilders.toEsDsl(compoundPredicate,
column2typeMap).toJson());
+ }
+
+ @Test
+ public void testLikeFunctionCallConvertEsDsl() {
+ SlotRef k1 = new SlotRef(null, "k1");
+ String str1 = "text%";
+ StringLiteral stringLiteral1 = new StringLiteral(str1);
+ Map<String, String> column2typeMap = new HashMap<>();
+ column2typeMap.put("k1", "keyword");
+ List<Expr> exprs1 = new ArrayList<>();
+ exprs1.add(k1);
+ exprs1.add(stringLiteral1);
+ FunctionCallExpr likeFunctionCallExpr = new FunctionCallExpr("like",
exprs1);
+ Assertions.assertEquals("{\"wildcard\":{\"k1\":\"text*\"}}",
+ QueryBuilders.toEsDsl(likeFunctionCallExpr,
column2typeMap).toJson());
+
+ SlotRef k2 = new SlotRef(null, "k2");
+ String str2 = "text$";
+ StringLiteral stringLiteral2 = new StringLiteral(str2);
+ List<Expr> exprs2 = new ArrayList<>();
+ exprs2.add(k2);
+ exprs2.add(stringLiteral2);
+ FunctionCallExpr regexFunctionCallExpr = new
FunctionCallExpr("regexp", exprs2);
+ Assertions.assertEquals("{\"wildcard\":{\"k2\":\"text$\"}}",
+ QueryBuilders.toEsDsl(regexFunctionCallExpr,
column2typeMap).toJson());
+
+
+ column2typeMap.clear();
+ List<Expr> notPushDownList = new ArrayList<>();
+ column2typeMap.put("k1", "text");
+ Assertions.assertNull(QueryBuilders.toEsDsl(likeFunctionCallExpr,
notPushDownList, new HashMap<>(),
+ BuilderOptions.builder().likePushDown(true).build(),
column2typeMap));
+ Assertions.assertEquals("{\"wildcard\":{\"k2\":\"text$\"}}",
+ QueryBuilders.toEsDsl(regexFunctionCallExpr, notPushDownList,
new HashMap<>(),
+ BuilderOptions.builder().likePushDown(true).build(),
column2typeMap).toJson());
+
+ Assertions.assertEquals(1, notPushDownList.size());
}
@Test
@@ -189,8 +247,10 @@ public class QueryBuildersTest {
BinaryPredicate castPredicate = new BinaryPredicate(Operator.EQ,
castExpr, new IntLiteral(3));
List<Expr> notPushDownList = new ArrayList<>();
Map<String, String> fieldsContext = new HashMap<>();
+ Map<String, String> col2typeMap = new HashMap<>();
BuilderOptions builderOptions =
BuilderOptions.builder().likePushDown(true).build();
- Assertions.assertNull(QueryBuilders.toEsDsl(castPredicate,
notPushDownList, fieldsContext, builderOptions));
+ Assertions.assertNull(QueryBuilders.toEsDsl(castPredicate,
notPushDownList, fieldsContext, builderOptions,
+ col2typeMap));
Assertions.assertEquals(1, notPushDownList.size());
SlotRef k2 = new SlotRef(null, "k2");
@@ -199,7 +259,7 @@ public class QueryBuildersTest {
CompoundPredicate compoundPredicate = new
CompoundPredicate(CompoundPredicate.Operator.OR, castPredicate,
eqPredicate);
- QueryBuilders.toEsDsl(compoundPredicate, notPushDownList,
fieldsContext, builderOptions);
+ QueryBuilders.toEsDsl(compoundPredicate, notPushDownList,
fieldsContext, builderOptions, col2typeMap);
Assertions.assertEquals(3, notPushDownList.size());
SlotRef k3 = new SlotRef(null, "k3");
@@ -207,7 +267,7 @@ public class QueryBuildersTest {
CastExpr castDoubleExpr = new CastExpr(Type.DOUBLE, k3);
BinaryPredicate castDoublePredicate = new BinaryPredicate(Operator.GE,
castDoubleExpr,
new FloatLiteral(3.0, Type.DOUBLE));
- QueryBuilders.toEsDsl(castDoublePredicate, notPushDownList,
fieldsContext, builderOptions);
+ QueryBuilders.toEsDsl(castDoublePredicate, notPushDownList,
fieldsContext, builderOptions, col2typeMap);
Assertions.assertEquals(3, notPushDownList.size());
SlotRef k4 = new SlotRef(null, "k4");
@@ -215,25 +275,29 @@ public class QueryBuildersTest {
CastExpr castFloatExpr = new CastExpr(Type.FLOAT, k4);
BinaryPredicate castFloatPredicate = new BinaryPredicate(Operator.GE,
new FloatLiteral(3.0, Type.FLOAT),
castFloatExpr);
- QueryBuilders.QueryBuilder queryBuilder =
QueryBuilders.toEsDsl(castFloatPredicate, notPushDownList, fieldsContext,
builderOptions);
+ QueryBuilders.QueryBuilder queryBuilder =
QueryBuilders.toEsDsl(castFloatPredicate, notPushDownList,
+ fieldsContext, builderOptions, col2typeMap);
Assertions.assertEquals("{\"range\":{\"k4\":{\"lte\":3.0}}}",
queryBuilder.toJson());
Assertions.assertEquals(3, notPushDownList.size());
castFloatPredicate = new BinaryPredicate(Operator.LE, new
FloatLiteral(3.0, Type.FLOAT),
castFloatExpr);
- queryBuilder = QueryBuilders.toEsDsl(castFloatPredicate,
notPushDownList, fieldsContext, builderOptions);
+ queryBuilder = QueryBuilders.toEsDsl(castFloatPredicate,
notPushDownList, fieldsContext, builderOptions,
+ col2typeMap);
Assertions.assertEquals("{\"range\":{\"k4\":{\"gte\":3.0}}}",
queryBuilder.toJson());
Assertions.assertEquals(3, notPushDownList.size());
castFloatPredicate = new BinaryPredicate(Operator.LT, new
FloatLiteral(3.0, Type.FLOAT),
castFloatExpr);
- queryBuilder = QueryBuilders.toEsDsl(castFloatPredicate,
notPushDownList, fieldsContext, builderOptions);
+ queryBuilder = QueryBuilders.toEsDsl(castFloatPredicate,
notPushDownList, fieldsContext, builderOptions,
+ col2typeMap);
Assertions.assertEquals("{\"range\":{\"k4\":{\"gt\":3.0}}}",
queryBuilder.toJson());
Assertions.assertEquals(3, notPushDownList.size());
castFloatPredicate = new BinaryPredicate(Operator.GT, new
FloatLiteral(3.0, Type.FLOAT),
castFloatExpr);
- queryBuilder = QueryBuilders.toEsDsl(castFloatPredicate,
notPushDownList, fieldsContext, builderOptions);
+ queryBuilder = QueryBuilders.toEsDsl(castFloatPredicate,
notPushDownList, fieldsContext, builderOptions,
+ col2typeMap);
Assertions.assertEquals("{\"range\":{\"k4\":{\"lt\":3.0}}}",
queryBuilder.toJson());
Assertions.assertEquals(3, notPushDownList.size());
}
diff --git a/regression-test/data/external_table_p0/es/test_es_query.out
b/regression-test/data/external_table_p0/es/test_es_query.out
index 6d761babed7..312aef06652 100644
--- a/regression-test/data/external_table_p0/es/test_es_query.out
+++ b/regression-test/data/external_table_p0/es/test_es_query.out
@@ -220,6 +220,17 @@ Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
-- !sql_5_28 --
value1 value2
+-- !sql_5_29 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+
+-- !sql_5_30 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
-- !sql_6_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01
12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1,
2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"]
["a", "b", "c"] [-1, 0, 1, 2]
[{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128,
129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3]
[{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] \N
string1 text#1 3.14 2022-08-08T00:00 12345 2022-08-08T20:10:10
@@ -349,6 +360,17 @@ Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
-- !sql_6_28 --
value1 value2
+-- !sql_6_29 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+
+-- !sql_6_30 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
-- !sql_7_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01
12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1,
2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"]
["a", "b", "c"] [-1, 0, 1, 2]
[{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128,
129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3]
[{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] debug
\N This string can be quite lengthy string1 2022-08-08T20:10:10
[...]
@@ -517,6 +539,19 @@ Grace [34, 56, 78] ["table tennis", "badminton",
"athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
+-- !sql_7_35 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+
+-- !sql_7_36 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
-- !sql_7_50 --
value1 value2
@@ -685,6 +720,19 @@ Grace [34, 56, 78] ["table tennis", "badminton",
"athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
+-- !sql_8_33 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+
+-- !sql_8_34 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
-- !sql01 --
["2020-01-01 12:00:00", "2020-01-02 13:01:01"] [-1, 0, 1, 2] [0, 1, 2, 3]
["d", "e", "f"] [128, 129, -129, -130] ["192.168.0.1", "127.0.0.1"] string1
[1, 2, 3, 4] 2022-08-08 2022-08-08T12:10:10 text#1 ["2020-01-01",
"2020-01-02"] 3.14 [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1, 2, 3, 4]
["a", "b", "c"] [{"name":"Andy","age":18},{"name":"Tim","age":28}]
2022-08-08T12:10:10 2022-08-08T12:10:10 2022-08-08T20:10:10 [1, -2,
-3, 4] [1, 0, 1, 1] [32768, 32769, -32769, -32770] \N
[{"last":"Smith","first [...]
@@ -906,6 +954,17 @@ Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
-- !sql_5_28 --
value1 value2
+-- !sql_5_29 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+
+-- !sql_5_30 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
-- !sql_6_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01
12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1,
2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"]
["a", "b", "c"] [-1, 0, 1, 2]
[{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128,
129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3]
[{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] \N
string1 text#1 3.14 2022-08-08T00:00 12345 2022-08-08T20:10:10
@@ -1035,6 +1094,17 @@ Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
-- !sql_6_28 --
value1 value2
+-- !sql_6_29 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+
+-- !sql_6_30 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
-- !sql_7_02 --
[1, 0, 1, 1] [1, -2, -3, 4] ["2020-01-01", "2020-01-02"] ["2020-01-01
12:00:00", "2020-01-02 13:01:01"] [1, 2, 3, 4] [1, 1.1, 1.2, 1.3] [1,
2, 3, 4] [32768, 32769, -32769, -32770] ["192.168.0.1", "127.0.0.1"]
["a", "b", "c"] [-1, 0, 1, 2]
[{"name":"Andy","age":18},{"name":"Tim","age":28}] [1, 2, 3, 4] [128,
129, -129, -130] ["d", "e", "f"] [0, 1, 2, 3]
[{"last":"Smith","first":"John"},{"last":"White","first":"Alice"}] debug
\N This string can be quite lengthy string1 2022-08-08T20:10:10
[...]
@@ -1203,6 +1273,19 @@ Grace [34, 56, 78] ["table tennis", "badminton",
"athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
+-- !sql_7_35 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+
+-- !sql_7_36 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
-- !sql_7_50 --
value1 value2
@@ -1371,3 +1454,16 @@ Grace [34, 56, 78] ["table tennis", "badminton",
"athletics"]
Henry [23, 45, 67] ["archery", "fencing", "weightlifting"]
Ivy [12, 34, 56] ["judo", "karate", "taekwondo"]
+-- !sql_8_33 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+
+-- !sql_8_34 --
+string1 text#1
+string2 text2
+string3 text3_4*5
+string4 text3_4*5
+string_ignore_above_10 text_ignore_above_10
+
diff --git a/regression-test/suites/external_table_p0/es/test_es_query.groovy
b/regression-test/suites/external_table_p0/es/test_es_query.groovy
index d2478aeadd2..a73df1ed5e1 100644
--- a/regression-test/suites/external_table_p0/es/test_es_query.groovy
+++ b/regression-test/suites/external_table_p0/es/test_es_query.groovy
@@ -214,6 +214,8 @@ suite("test_es_query",
"p0,external,es,external_docker,external_docker_es") {
order_qt_sql_5_26 """select test6 from test2;"""
order_qt_sql_5_27 """select * from composite_type_array order by
name;"""
order_qt_sql_5_28 """select * from test3_20231005;"""
+ order_qt_sql_5_29 """select test1, test2 from test1 where test1
like 'string%';"""
+ order_qt_sql_5_30 """select test1, test2 from test1 where test2
like 'text%';"""
sql """switch test_es_query_es6"""
// order_qt_sql_6_01 """show tables"""
@@ -244,6 +246,8 @@ suite("test_es_query",
"p0,external,es,external_docker,external_docker_es") {
order_qt_sql_6_26 """select test6 from test2;"""
order_qt_sql_6_27 """select * from composite_type_array order by
name;"""
order_qt_sql_6_28 """select * from test3_20231005;"""
+ order_qt_sql_6_29 """select test1, test2 from test1 where test1
like 'string%';"""
+ order_qt_sql_6_30 """select test1, test2 from test1 where test2
like 'text%';"""
List<List<String>> tables6N = sql """show tables"""
boolean notContainHide = true
@@ -299,6 +303,8 @@ suite("test_es_query",
"p0,external,es,external_docker,external_docker_es") {
order_qt_sql_7_32 """select test6 from test1;"""
order_qt_sql_7_33 """select test6 from test2;"""
order_qt_sql_7_34 """select * from composite_type_array order by
name;"""
+ order_qt_sql_7_35 """select test1, test2 from test1 where test1
like 'string%';"""
+ order_qt_sql_7_36 """select test1, test2 from test1 where test2
like 'text%';"""
List<List<String>> tables7N = sql """show tables"""
boolean notContainHide7 = true
@@ -354,7 +360,9 @@ suite("test_es_query",
"p0,external,es,external_docker,external_docker_es") {
order_qt_sql_8_30 """select test6 from test1;"""
order_qt_sql_8_31 """select test6 from test2;"""
order_qt_sql_8_32 """select * from composite_type_array order by
name;"""
-
+ order_qt_sql_8_33 """select test1, test2 from test1 where test1
like 'string%';"""
+ order_qt_sql_8_34 """select test1, test2 from test1 where test2
like 'text%';"""
+
}
sql """set enable_es_parallel_scroll=true"""
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]