Skip to content

Commit d998587

Browse files
committed
Fix IT
Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 045baee commit d998587

1 file changed

Lines changed: 78 additions & 62 deletions

File tree

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

Lines changed: 78 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.util.Locale;
1919
import org.json.JSONObject;
2020
import org.junit.Test;
21+
import org.opensearch.sql.common.setting.Settings;
2122
import org.opensearch.sql.ppl.PPLIntegTestCase;
2223

2324
public class CalcitePPLAppendCommandIT extends PPLIntegTestCase {
@@ -90,71 +91,86 @@ public void testAppendEmptySearchCommand() throws IOException {
9091

9192
@Test
9293
public void testAppendEmptySearchWithJoin() throws IOException {
93-
List<String> emptySourceWithJoinPPLs =
94-
Arrays.asList(
95-
String.format(
96-
Locale.ROOT,
97-
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
98-
+ " join left=L right=R on L.gender = R.gender %s ]",
99-
TEST_INDEX_ACCOUNT,
100-
TEST_INDEX_ACCOUNT),
101-
String.format(
102-
Locale.ROOT,
103-
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
104-
+ " cross join left=L right=R on L.gender = R.gender %s ]",
105-
TEST_INDEX_ACCOUNT,
106-
TEST_INDEX_ACCOUNT),
107-
String.format(
108-
Locale.ROOT,
109-
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
110-
+ " left join left=L right=R on L.gender = R.gender %s ]",
111-
TEST_INDEX_ACCOUNT,
112-
TEST_INDEX_ACCOUNT),
113-
String.format(
114-
Locale.ROOT,
115-
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
116-
+ " semi join left=L right=R on L.gender = R.gender %s ]",
117-
TEST_INDEX_ACCOUNT,
118-
TEST_INDEX_ACCOUNT));
94+
withSettings(
95+
Settings.Key.CALCITE_SUPPORT_ALL_JOIN_TYPES,
96+
"true",
97+
() -> {
98+
List<String> emptySourceWithJoinPPLs =
99+
Arrays.asList(
100+
String.format(
101+
Locale.ROOT,
102+
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
103+
+ " join left=L right=R on L.gender = R.gender %s ]",
104+
TEST_INDEX_ACCOUNT,
105+
TEST_INDEX_ACCOUNT),
106+
String.format(
107+
Locale.ROOT,
108+
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
109+
+ " cross join left=L right=R on L.gender = R.gender %s ]",
110+
TEST_INDEX_ACCOUNT,
111+
TEST_INDEX_ACCOUNT),
112+
String.format(
113+
Locale.ROOT,
114+
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
115+
+ " left join left=L right=R on L.gender = R.gender %s ]",
116+
TEST_INDEX_ACCOUNT,
117+
TEST_INDEX_ACCOUNT),
118+
String.format(
119+
Locale.ROOT,
120+
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | "
121+
+ " semi join left=L right=R on L.gender = R.gender %s ]",
122+
TEST_INDEX_ACCOUNT,
123+
TEST_INDEX_ACCOUNT));
119124

120-
for (String ppl : emptySourceWithJoinPPLs) {
121-
JSONObject actual = executeQuery(ppl);
122-
verifySchemaInOrder(
123-
actual, schema("sum_age_by_gender", "bigint"), schema("gender", "string"));
124-
verifyDataRows(actual, rows(14947, "F"), rows(15224, "M"));
125-
}
125+
for (String ppl : emptySourceWithJoinPPLs) {
126+
JSONObject actual = null;
127+
try {
128+
actual = executeQuery(ppl);
129+
} catch (IOException e) {
130+
throw new RuntimeException(e);
131+
}
132+
verifySchemaInOrder(
133+
actual, schema("sum_age_by_gender", "bigint"), schema("gender", "string"));
134+
verifyDataRows(actual, rows(14947, "F"), rows(15224, "M"));
135+
}
126136

127-
List<String> emptySourceWithRightOrFullJoinPPLs =
128-
Arrays.asList(
129-
String.format(
130-
Locale.ROOT,
131-
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | where"
132-
+ " gender = 'F' | right join on gender = gender [source=%s | stats count() as"
133-
+ " cnt by gender ] ]",
134-
TEST_INDEX_ACCOUNT,
135-
TEST_INDEX_ACCOUNT),
136-
String.format(
137-
Locale.ROOT,
138-
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | where"
139-
+ " gender = 'F' | full join on gender = gender [source=%s | stats count() as"
140-
+ " cnt by gender ] ]",
141-
TEST_INDEX_ACCOUNT,
142-
TEST_INDEX_ACCOUNT));
137+
List<String> emptySourceWithRightOrFullJoinPPLs =
138+
Arrays.asList(
139+
String.format(
140+
Locale.ROOT,
141+
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | where"
142+
+ " gender = 'F' | right join on gender = gender [source=%s | stats"
143+
+ " count() as cnt by gender ] ]",
144+
TEST_INDEX_ACCOUNT,
145+
TEST_INDEX_ACCOUNT),
146+
String.format(
147+
Locale.ROOT,
148+
"source=%s | stats sum(age) as sum_age_by_gender by gender | append [ | where"
149+
+ " gender = 'F' | full join on gender = gender [source=%s | stats"
150+
+ " count() as cnt by gender ] ]",
151+
TEST_INDEX_ACCOUNT,
152+
TEST_INDEX_ACCOUNT));
143153

144-
for (String ppl : emptySourceWithRightOrFullJoinPPLs) {
145-
JSONObject actual = executeQuery(ppl);
146-
verifySchemaInOrder(
147-
actual,
148-
schema("sum_age_by_gender", "bigint"),
149-
schema("gender", "string"),
150-
schema("cnt", "bigint"));
151-
verifyDataRows(
152-
actual,
153-
rows(14947, "F", null),
154-
rows(15224, "M", null),
155-
rows(null, "F", 493),
156-
rows(null, "M", 507));
157-
}
154+
for (String ppl : emptySourceWithRightOrFullJoinPPLs) {
155+
JSONObject actual = null;
156+
try {
157+
actual = executeQuery(ppl);
158+
} catch (IOException e) {
159+
throw new RuntimeException(e);
160+
}
161+
verifySchemaInOrder(
162+
actual,
163+
schema("sum_age_by_gender", "bigint"),
164+
schema("gender", "string"),
165+
schema("cnt", "bigint"));
166+
verifyDataRows(
167+
actual,
168+
rows(14947, "F", null),
169+
rows(15224, "M", null),
170+
rows(null, "F", 493),
171+
rows(null, "M", 507));
172+
}
173+
});
158174
}
159175

160176
@Test

0 commit comments

Comments
 (0)