Skip to content

Commit f483247

Browse files
authored
Support script pushdown in sort-on-measure pushdown rewriting (#4749)
* Support script pushdown in sort-on-measure pushdown rewriting Signed-off-by: Lantao Jin <[email protected]> * fix IT Signed-off-by: Lantao Jin <[email protected]> * Merge remote-tracking branch 'upstream/main' into issues/4738 * remove system.out.print Signed-off-by: Lantao Jin <[email protected]> * Fix IT Signed-off-by: Lantao Jin <[email protected]>
1 parent 55bef39 commit f483247

File tree

27 files changed

+452
-50
lines changed

27 files changed

+452
-50
lines changed

common/src/main/java/org/opensearch/sql/common/grok/GrokCompiler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ public Grok compile(final String pattern, ZoneId defaultTimeZone, boolean namedO
185185
(group.get("subname") != null ? group.get("subname") : group.get("name")));
186186
namedRegex =
187187
StringUtils.replace(namedRegex, "%{" + group.get("name") + "}", replacement, 1);
188-
// System.out.println(_expanded_pattern);
189188
index++;
190189
}
191190
}

common/src/test/java/org/opensearch/sql/common/grok/ApacheDataTypeTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ public void test002_httpd_access_semi() throws GrokException {
4949
+ " HTTP/%{NUMBER:httpversion;float})?|%{DATA:rawrequest})\" %{NUMBER:response;int}"
5050
+ " (?:%{NUMBER:bytes;long}|-)");
5151

52-
System.out.println(line);
5352
Match gm = grok.match(line);
5453
Map<String, Object> map = gm.capture();
5554

common/src/test/java/org/opensearch/sql/common/grok/ApacheTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public void test001_httpd_access() throws GrokException, IOException {
3838

3939
BufferedReader br = new BufferedReader(new FileReader(LOG_FILE));
4040
String line;
41-
System.out.println("Starting test with httpd log");
4241
while ((line = br.readLine()) != null) {
4342
Match gm = grok.match(line);
4443
final Map<String, Object> capture = gm.capture();
@@ -50,7 +49,6 @@ public void test001_httpd_access() throws GrokException, IOException {
5049
@Test
5150
public void test002_nasa_httpd_access() throws GrokException, IOException {
5251
Grok grok = compiler.compile("%{COMMONAPACHELOG}");
53-
System.out.println("Starting test with nasa log -- may take a while");
5452
BufferedReader br;
5553
String line;
5654
File dir = new File(LOG_DIR_NASA);

common/src/test/java/org/opensearch/sql/common/grok/GrokTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ public void test013_IpSet() throws Throwable {
317317
try (FileReader fr = new FileReader(Resources.getResource(ResourceManager.IP).getFile());
318318
BufferedReader br = new BufferedReader(fr)) {
319319
String line;
320-
System.out.println("Starting test with ip");
321320
while ((line = br.readLine()) != null) {
322321
Match gm = grok.match(line);
323322
final Map<String, Object> map = gm.capture();

common/src/test/java/org/opensearch/sql/common/grok/MessagesTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public void test001_linux_messages() throws GrokException, IOException {
2929
new BufferedReader(
3030
new FileReader(Resources.getResource(ResourceManager.MESSAGES).getFile()));
3131
String line;
32-
System.out.println("Starting test with linux messages log -- may take a while");
3332
while ((line = br.readLine()) != null) {
3433
Match gm = grok.match(line);
3534
Map<String, Object> map = gm.capture();

core/src/test/java/org/opensearch/sql/calcite/utils/BinUtilsTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,21 +106,13 @@ public void testParseSpanStringWithExtendedTimeUnits() {
106106
public void testMonthUnitDetection() {
107107
// Specifically test that 1mon is detected as "mon" not "m"
108108
String result = SpanParser.extractTimeUnit("1mon");
109-
System.out.println("Result for '1mon': " + result);
110109
assertEquals("mon", result);
111110
}
112111

113112
@Test
114113
public void testFullMonthParsingChain() {
115114
// Test the full parsing chain for 1mon
116115
var spanInfo = SpanParser.parse("1mon");
117-
System.out.println(
118-
"SpanInfo: type="
119-
+ spanInfo.getType()
120-
+ ", value="
121-
+ spanInfo.getValue()
122-
+ ", unit="
123-
+ spanInfo.getUnit());
124116
assertEquals(SpanType.TIME, spanInfo.getType());
125117
assertEquals(1.0, spanInfo.getValue(), 0.001);
126118
assertEquals("mon", spanInfo.getUnit());

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteExplainIT.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,17 @@ public void testExplainSortOnMeasure() throws IOException {
11491149
TEST_INDEX_BANK)));
11501150
}
11511151

1152+
@Test
1153+
public void testExplainSortOnMeasureWithScript() throws IOException {
1154+
enabledOnlyWhenPushdownIsEnabled();
1155+
String expected = loadExpectedPlan("explain_agg_sort_on_measure_script.yaml");
1156+
assertYamlEqualsIgnoreId(
1157+
expected,
1158+
explainQueryYaml(
1159+
"source=opensearch-sql_test_index_account | eval new_state = lower(state) | "
1160+
+ "stats bucket_nullable=false count() by new_state | sort `count()`"));
1161+
}
1162+
11521163
@Test
11531164
public void testExplainSortOnMeasureMultiTerms() throws IOException {
11541165
enabledOnlyWhenPushdownIsEnabled();
@@ -1160,6 +1171,18 @@ public void testExplainSortOnMeasureMultiTerms() throws IOException {
11601171
+ " gender, state | sort `count()`"));
11611172
}
11621173

1174+
@Test
1175+
public void testExplainSortOnMeasureMultiTermsWithScript() throws IOException {
1176+
enabledOnlyWhenPushdownIsEnabled();
1177+
String expected = loadExpectedPlan("explain_agg_sort_on_measure_multi_terms_script.yaml");
1178+
assertYamlEqualsIgnoreId(
1179+
expected,
1180+
explainQueryYaml(
1181+
"source=opensearch-sql_test_index_account | eval new_gender = lower(gender), new_state"
1182+
+ " = lower(state) | stats bucket_nullable=false count() by new_gender, new_state |"
1183+
+ " sort `count()`"));
1184+
}
1185+
11631186
@Test
11641187
public void testExplainCompositeMultiBucketsAutoDateThenSortOnMeasureNotPushdown()
11651188
throws IOException {

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteFillNullCommandIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ public void testFillNullWithStringOnNumericAndStringMixedFields() {
137137
"source=%s | fields num0, str2 | fillnull value='test' num0 str2",
138138
TEST_INDEX_CALCS)));
139139

140-
System.out.println("Debugging error message: " + t);
141140
verifyErrorMessageContains(
142141
t,
143142
"fillnull failed: replacement value type VARCHAR is not compatible with field 'num0' "

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalciteMVAppendFunctionIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ public void testMvappendWithIntAndDouble() throws IOException {
9797
executeQuery(
9898
source(TEST_INDEX_BANK, "eval result = mvappend(1, 2.5) | head 1 | fields result"));
9999

100-
System.out.println(actual);
101-
102100
verifySchema(actual, schema("result", "array"));
103101
verifyDataRows(actual, rows(List.of(1, 2.5)));
104102
}

integ-test/src/test/java/org/opensearch/sql/calcite/remote/CalcitePPLPatternsIT.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ public void testBrainAggregationModeWithGroupByClause_ShowNumberedToken() throws
428428
+ " mode=aggregation show_numbered_token=true max_sample_count=5"
429429
+ " variable_count_threshold=2 frequency_threshold_percentage=0.2",
430430
TEST_INDEX_HDFS_LOGS));
431-
System.out.println(result);
432431
verifySchema(
433432
result,
434433
schema("level", "string"),

0 commit comments

Comments
 (0)