From 23cc0f6976a9bfd22203a1a7a948e2f6aee86e87 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Tue, 28 Mar 2023 10:29:51 -0700 Subject: [PATCH] Replace non-ASCII characters in code and docs. (#1365) * Replace non-ASCII characters in code and docs. Signed-off-by: Yury-Fridlyand * Recover unicode characters in grok tests. Signed-off-by: Yury-Fridlyand * Removed some non-English comments. Signed-off-by: Yury-Fridlyand * Remove non-English comments from ITs. Signed-off-by: Yury-Fridlyand --------- Signed-off-by: Yury-Fridlyand --- .../opensearch/sql/common/grok/BasicTest.java | 8 +- .../expression/datetime/DateTimeFunction.java | 2 +- docs/user/dql/functions.rst | 6 +- docs/user/ppl/functions/datetime.rst | 6 +- .../opensearch/sql/legacy/MethodQueryIT.java | 78 +++++++++++++++---- .../sql/legacy/domain/Condition.java | 2 +- .../opensearch/sql/legacy/domain/Field.java | 2 +- .../sql/legacy/domain/MethodField.java | 2 +- .../opensearch/sql/legacy/domain/Order.java | 2 +- .../sql/legacy/domain/SearchResult.java | 6 +- .../opensearch/sql/legacy/domain/Select.java | 2 +- .../esdomain/mapping/FieldMappings.java | 4 +- .../sql/legacy/parser/FieldMaker.java | 2 +- .../sql/legacy/query/maker/AggMaker.java | 8 +- .../sql/legacy/query/maker/Maker.java | 2 +- .../sql/legacy/query/maker/QueryMaker.java | 4 +- 16 files changed, 93 insertions(+), 43 deletions(-) diff --git a/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java b/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java index f84d156cab..26df7ba57e 100644 --- a/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java +++ b/common/src/test/java/org/opensearch/sql/common/grok/BasicTest.java @@ -113,22 +113,22 @@ public void test006_testLoadPatternFromFileIso_8859_1() throws IOException, Grok try (FileOutputStream fis = new FileOutputStream(temp); BufferedWriter bw = new BufferedWriter( new OutputStreamWriter(fis, StandardCharsets.ISO_8859_1))) { - bw.write("TEST §"); + bw.write("TEST \\u2022"); } GrokCompiler compiler = GrokCompiler.newInstance(); compiler.register(new FileInputStream(temp), StandardCharsets.ISO_8859_1); Grok grok = compiler.compile("%{TEST}"); - assertEquals("(?§)", grok.getNamedRegex()); + assertEquals("(?\\u2022)", grok.getNamedRegex()); } @Test public void test007_testLoadPatternFromReader() throws IOException, GrokException { - Reader reader = new StringReader("TEST €"); + Reader reader = new StringReader("TEST \\u20AC"); GrokCompiler compiler = GrokCompiler.newInstance(); compiler.register(reader); Grok grok = compiler.compile("%{TEST}"); - assertEquals("(?€)", grok.getNamedRegex()); + assertEquals("(?\\u20AC)", grok.getNamedRegex()); } } diff --git a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java index 36541009f7..ae35b4b41f 100644 --- a/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java +++ b/core/src/main/java/org/opensearch/sql/expression/datetime/DateTimeFunction.java @@ -557,7 +557,7 @@ private DefaultFunctionResolver dayOfMonth(BuiltinFunctionName name) { /** * DAYOFWEEK(STRING/DATE/DATETIME/TIME/TIMESTAMP). - * return the weekday index for date (1 = Sunday, 2 = Monday, …, 7 = Saturday). + * return the weekday index for date (1 = Sunday, 2 = Monday, ..., 7 = Saturday). */ private DefaultFunctionResolver dayOfWeek(FunctionName name) { return define(name, diff --git a/docs/user/dql/functions.rst b/docs/user/dql/functions.rst index 9b8a08492d..6283bc70e1 100644 --- a/docs/user/dql/functions.rst +++ b/docs/user/dql/functions.rst @@ -1508,7 +1508,7 @@ If an argument of type TIME is provided, the local date is used. * - %c - Month, numeric (0..12) * - %D - - Day of the month with English suffix (0th, 1st, 2nd, 3rd, …) + - Day of the month with English suffix (0th, 1st, 2nd, 3rd, ...) * - %d - Day of the month, numeric (00..31) * - %e @@ -1734,7 +1734,7 @@ DAYOFWEEK Description >>>>>>>>>>> -Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, …, 7 = Saturday). +Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, ..., 7 = Saturday). The `day_of_week` function is also provided as an alias. @@ -2915,7 +2915,7 @@ The functions `weekofyear` and `week_of_year` is also provided as an alias. * - Mode - First day of week - Range - - Week 1 is the first week … + - Week 1 is the first week ... * - 0 - Sunday - 0-53 diff --git a/docs/user/ppl/functions/datetime.rst b/docs/user/ppl/functions/datetime.rst index 646b7d65ad..48152de811 100644 --- a/docs/user/ppl/functions/datetime.rst +++ b/docs/user/ppl/functions/datetime.rst @@ -440,7 +440,7 @@ If an argument of type TIME is provided, the local date is used. * - %c - Month, numeric (0..12) * - %D - - Day of the month with English suffix (0th, 1st, 2nd, 3rd, …) + - Day of the month with English suffix (0th, 1st, 2nd, 3rd, ...) * - %d - Day of the month, numeric (00..31) * - %e @@ -694,7 +694,7 @@ DAYOFWEEK Description >>>>>>>>>>> -Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, …, 7 = Saturday). +Usage: dayofweek(date) returns the weekday index for date (1 = Sunday, 2 = Monday, ..., 7 = Saturday). Argument type: STRING/DATE/DATETIME/TIMESTAMP @@ -1505,7 +1505,7 @@ Usage: week(date[, mode]) returns the week number for date. If the mode argument * - Mode - First day of week - Range - - Week 1 is the first week … + - Week 1 is the first week ... * - 0 - Sunday - 0-53 diff --git a/integ-test/src/test/java/org/opensearch/sql/legacy/MethodQueryIT.java b/integ-test/src/test/java/org/opensearch/sql/legacy/MethodQueryIT.java index fdbbb0f6ba..680058d844 100644 --- a/integ-test/src/test/java/org/opensearch/sql/legacy/MethodQueryIT.java +++ b/integ-test/src/test/java/org/opensearch/sql/legacy/MethodQueryIT.java @@ -27,8 +27,12 @@ protected void init() throws Exception { } /** - * query 搜索就是 , lucene 原生的搜素方式 注意这个例子中value可以随便命名 "query" : - * {query_string" : {"query" : "address:880 Holmes Lane"} + * query + * "query" : { + * query_string" : { + * "query" : "address:880 Holmes Lane" + * } + * } * * @throws IOException */ @@ -43,8 +47,15 @@ public void queryTest() throws IOException { } /** - * matchQuery 是利用分词结果进行单个字段的搜索. "query" : { "match" : { "address" : - * {"query":"880 Holmes Lane", "type" : "boolean" } } } + * matchQuery + * "query" : { + * "match" : { + * "address" : { + * "query" : "880 Holmes Lane", + * "type" : "boolean" + * } + * } + * } * * @throws IOException */ @@ -58,11 +69,45 @@ public void matchQueryTest() throws IOException { } /** - * matchQuery 是利用分词结果进行单个字段的搜索. "query" : { "bool" : { "must" : { "bool" : { - * "should" : [ { "constant_score" : { "query" : { "match" : { "address" : { - * "query" : "Lane", "type" : "boolean" } } }, "boost" : 100.0 } }, { - * "constant_score" : { "query" : { "match" : { "address" : { "query" : - * "Street", "type" : "boolean" } } }, "boost" : 0.5 } } ] } } } } + * matchQuery + * { + * "query": { + * "bool": { + * "must": { + * "bool": { + * "should": [ + * { + * "constant_score": { + * "query": { + * "match": { + * "address": { + * "query": "Lane", + * "type": "boolean" + * } + * } + * }, + * "boost": 100 + * } + * }, + * { + * "constant_score": { + * "query": { + * "match": { + * "address": { + * "query": "Street", + * "type": "boolean" + * } + * } + * }, + * "boost": 0.5 + * } + * } + * ] + * } + * } + * } + * } + * } * * @throws IOException */ @@ -102,8 +147,13 @@ public void negativeRegexpQueryTest() throws IOException { } /** - * wildcardQuery 是用通配符的方式查找某个term  比如例子中 l*e means leae ltae .... - * "wildcard": { "address" : { "wildcard" : "l*e" } } + * wildcardQuery + * l*e means leae ltae ... + * "wildcard": { + * "address" : { + * "wildcard" : "l*e" + * } + * } * * @throws IOException */ @@ -117,10 +167,10 @@ public void wildcardQueryTest() throws IOException { } /** - * matchPhraseQueryTest 短语查询完全匹配. + * matchPhraseQuery * "address" : { - * "query" : "671 Bristol Street", - * "type" : "phrase" + * "query" : "671 Bristol Street", + * "type" : "phrase" * } * * @throws IOException diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java index 793fb271a6..ff6b016ddb 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Condition.java @@ -18,7 +18,7 @@ import org.opensearch.sql.legacy.utils.StringUtils; /** - * 过滤条件 + * * * @author ansj */ diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Field.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Field.java index 856f590510..1b6be05f20 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Field.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Field.java @@ -13,7 +13,7 @@ import org.opensearch.sql.legacy.parser.NestedType; /** - * 搜索域 + * * * @author ansj */ diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/MethodField.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/MethodField.java index 62eff626c4..4529c4344c 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/MethodField.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/MethodField.java @@ -14,7 +14,7 @@ import org.opensearch.sql.legacy.utils.Util; /** - * 搜索域 + * * * @author ansj */ diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java index 2aee7cdabf..2a9be3ce91 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Order.java @@ -7,7 +7,7 @@ package org.opensearch.sql.legacy.domain; /** - * 排序规则 + * * * @author ansj */ diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/SearchResult.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/SearchResult.java index 655da9848c..5b7b73a910 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/SearchResult.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/SearchResult.java @@ -30,7 +30,7 @@ public class SearchResult { /** - * 查询结果 + * */ private List> results; @@ -82,7 +82,7 @@ public SearchResult(SearchResponse resp, Select select) throws SqlParseException } /** - * 讲es的field域转换为你Object + * * * @param fields * @return @@ -101,7 +101,7 @@ private Map toFieldsMap(Map fields) { } /** - * 讲es的field域转换为你Object + * * * @param fields * @return diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java index 485efc1a2b..8a6d3b265d 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/domain/Select.java @@ -18,7 +18,7 @@ /** - * 将sql语句转换为select 对象 + * sql select * * @author ansj */ diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/esdomain/mapping/FieldMappings.java b/legacy/src/main/java/org/opensearch/sql/legacy/esdomain/mapping/FieldMappings.java index 257e397478..6f73da62e4 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/esdomain/mapping/FieldMappings.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/esdomain/mapping/FieldMappings.java @@ -27,10 +27,10 @@ * 'type': integer * }, * 'state': { - * 'type': text, + * 'type': text * } * 'name': { - * 'type': text, + * 'type': text * 'fields': { * 'keyword': { * 'type': keyword, diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java b/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java index 0f5a2af631..89e9a16d1c 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/parser/FieldMaker.java @@ -41,7 +41,7 @@ import org.opensearch.sql.legacy.utils.Util; /** - * 一些具有参数的一般在 select 函数.或者group by 函数 + * * * @author ansj */ diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java index c7ab574a38..7960d80669 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/AggMaker.java @@ -72,7 +72,7 @@ public class AggMaker { private Where where; /** - * 分组查的聚合函数 + * * * @param field * @return @@ -535,7 +535,7 @@ private ValuesSourceAggregationBuilder dateRange(MethodField field) { } /** - * 按照时间范围分组 + * * * @param field * @return @@ -663,7 +663,7 @@ private HistogramAggregationBuilder histogram(MethodField field) throws SqlParse } /** - * 构建范围查询 + * * * @param field * @return @@ -723,7 +723,7 @@ private ValuesSourceAggregationBuilder makeCountAgg(MethodField field) { } /** - * TOPHITS查询 + * TOPHITS * * @param field * @return diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/Maker.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/Maker.java index 409288503a..08018d94de 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/Maker.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/Maker.java @@ -93,7 +93,7 @@ protected Maker(Boolean isQuery) { } /** - * 构建过滤条件 + * * * @param cond * @return diff --git a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/QueryMaker.java b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/QueryMaker.java index d6d2f1e58e..f36bca2686 100644 --- a/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/QueryMaker.java +++ b/legacy/src/main/java/org/opensearch/sql/legacy/query/maker/QueryMaker.java @@ -19,7 +19,7 @@ public class QueryMaker extends Maker { /** - * 将where条件构建成query + * * * @param where * @return @@ -58,7 +58,7 @@ private void explanWhere(BoolQueryBuilder boolQuery, Where where) throws SqlPars } /** - * 增加嵌套插 + * * * @param boolQuery * @param where