Skip to content

Commit f18c187

Browse files
authored
Implement ppl join command with Calcite (#3364)
Signed-off-by: Lantao Jin <ltjin@amazon.com>
1 parent 2971eae commit f18c187

File tree

14 files changed

+1872
-6
lines changed

14 files changed

+1872
-6
lines changed

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLJoinIT.java

Lines changed: 1316 additions & 0 deletions
Large diffs are not rendered by default.

integ-test/src/test/java/org/opensearch/sql/legacy/SQLIntegTestCase.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,19 @@
2121
import static org.opensearch.sql.legacy.TestUtils.getEmployeeNestedTypeIndexMapping;
2222
import static org.opensearch.sql.legacy.TestUtils.getGameOfThronesIndexMapping;
2323
import static org.opensearch.sql.legacy.TestUtils.getGeopointIndexMapping;
24+
import static org.opensearch.sql.legacy.TestUtils.getHobbiesIndexMapping;
2425
import static org.opensearch.sql.legacy.TestUtils.getJoinTypeIndexMapping;
2526
import static org.opensearch.sql.legacy.TestUtils.getLocationIndexMapping;
2627
import static org.opensearch.sql.legacy.TestUtils.getMappingFile;
2728
import static org.opensearch.sql.legacy.TestUtils.getNestedSimpleIndexMapping;
2829
import static org.opensearch.sql.legacy.TestUtils.getNestedTypeIndexMapping;
30+
import static org.opensearch.sql.legacy.TestUtils.getOccupationIndexMapping;
2931
import static org.opensearch.sql.legacy.TestUtils.getOdbcIndexMapping;
3032
import static org.opensearch.sql.legacy.TestUtils.getOrderIndexMapping;
3133
import static org.opensearch.sql.legacy.TestUtils.getPeople2IndexMapping;
3234
import static org.opensearch.sql.legacy.TestUtils.getPhraseIndexMapping;
3335
import static org.opensearch.sql.legacy.TestUtils.getResponseBody;
36+
import static org.opensearch.sql.legacy.TestUtils.getStateCountryIndexMapping;
3437
import static org.opensearch.sql.legacy.TestUtils.getStringIndexMapping;
3538
import static org.opensearch.sql.legacy.TestUtils.getUnexpandedObjectIndexMapping;
3639
import static org.opensearch.sql.legacy.TestUtils.getWeblogsIndexMapping;
@@ -745,7 +748,22 @@ public enum Index {
745748
TestsConstants.TEST_INDEX_GEOPOINT,
746749
"dates",
747750
getGeopointIndexMapping(),
748-
"src/test/resources/geopoints.json");
751+
"src/test/resources/geopoints.json"),
752+
STATE_COUNTRY(
753+
TestsConstants.TEST_INDEX_STATE_COUNTRY,
754+
"state_country",
755+
getStateCountryIndexMapping(),
756+
"src/test/resources/state_country.json"),
757+
OCCUPATION(
758+
TestsConstants.TEST_INDEX_OCCUPATION,
759+
"occupation",
760+
getOccupationIndexMapping(),
761+
"src/test/resources/occupation.json"),
762+
HOBBIES(
763+
TestsConstants.TEST_INDEX_HOBBIES,
764+
"hobbies",
765+
getHobbiesIndexMapping(),
766+
"src/test/resources/hobbies.json");
749767

750768
private final String name;
751769
private final String type;

integ-test/src/test/java/org/opensearch/sql/legacy/TestUtils.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,21 @@ public static String getGeopointIndexMapping() {
250250
return getMappingFile(mappingFile);
251251
}
252252

253+
public static String getStateCountryIndexMapping() {
254+
String mappingFile = "state_country_index_mapping.json";
255+
return getMappingFile(mappingFile);
256+
}
257+
258+
public static String getOccupationIndexMapping() {
259+
String mappingFile = "occupation_index_mapping.json";
260+
return getMappingFile(mappingFile);
261+
}
262+
263+
public static String getHobbiesIndexMapping() {
264+
String mappingFile = "hobbies_index_mapping.json";
265+
return getMappingFile(mappingFile);
266+
}
267+
253268
public static void loadBulk(Client client, String jsonPath, String defaultIndex)
254269
throws Exception {
255270
System.out.println(String.format("Loading file %s into opensearch cluster", jsonPath));

integ-test/src/test/java/org/opensearch/sql/legacy/TestsConstants.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ public class TestsConstants {
5959
public static final String TEST_INDEX_NESTED_WITH_NULLS = TEST_INDEX + "_nested_with_nulls";
6060
public static final String TEST_INDEX_GEOPOINT = TEST_INDEX + "_geopoint";
6161
public static final String DATASOURCES = ".ql-datasources";
62+
public static final String TEST_INDEX_STATE_COUNTRY = TEST_INDEX + "_state_country";
63+
public static final String TEST_INDEX_OCCUPATION = TEST_INDEX + "_occupation";
64+
public static final String TEST_INDEX_HOBBIES = TEST_INDEX + "_hobbies";
6265

6366
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
6467
public static final String TS_DATE_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS";
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{"index":{"_id":"1"}}
2+
{"name":"Jake","country":"USA","hobby":"Fishing","language":"English","year":2023,"month":4}
3+
{"index":{"_id":"2"}}
4+
{"name":"Hello","country":"USA","hobby":"Painting","language":"English","year":2023,"month":4}
5+
{"index":{"_id":"3"}}
6+
{"name":"John","country":"Canada","hobby":"Reading","language":"French","year":2023,"month":4}
7+
{"index":{"_id":"4"}}
8+
{"name":"Jim","country":"Canada","hobby":"Hiking","language":"English","year":2023,"month":4}
9+
{"index":{"_id":"5"}}
10+
{"name":"Peter","country":"Canada","hobby":"Gaming","language":"English","year":2023,"month":4}
11+
{"index":{"_id":"6"}}
12+
{"name":"Rick","country":"USA","hobby":"Swimming","language":"English","year":2023,"month":4}
13+
{"index":{"_id":"7"}}
14+
{"name":"David","country":"USA","hobby":"Gardening","language":"English","year":2023,"month":4}
15+
{"index":{"_id":"8"}}
16+
{"name":"Jane","country":"Canada","hobby":"Singing","language":"French","year":2023,"month":4}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"mappings": {
3+
"properties": {
4+
"name": {
5+
"type": "keyword"
6+
},
7+
"country": {
8+
"type": "text"
9+
},
10+
"hobby": {
11+
"type": "text"
12+
},
13+
"language": {
14+
"type": "keyword"
15+
},
16+
"year": {
17+
"type": "integer"
18+
},
19+
"month": {
20+
"type": "integer"
21+
}
22+
}
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"mappings": {
3+
"properties": {
4+
"name": {
5+
"type": "keyword"
6+
},
7+
"occupation": {
8+
"type": "text"
9+
},
10+
"country": {
11+
"type": "text"
12+
},
13+
"salary": {
14+
"type": "integer"
15+
},
16+
"year": {
17+
"type": "integer"
18+
},
19+
"month": {
20+
"type": "integer"
21+
}
22+
}
23+
}
24+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"mappings": {
3+
"properties": {
4+
"name": {
5+
"type": "keyword"
6+
},
7+
"age": {
8+
"type": "integer"
9+
},
10+
"state": {
11+
"type": "text",
12+
"fields": {
13+
"keyword": {
14+
"type": "keyword",
15+
"ignore_above": 256
16+
}
17+
}
18+
},
19+
"country": {
20+
"type": "text"
21+
},
22+
"year": {
23+
"type": "integer"
24+
},
25+
"month": {
26+
"type": "integer"
27+
}
28+
}
29+
}
30+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{"index":{"_id":"1"}}
2+
{"name":"Jake","occupation":"Engineer","country":"England","salary":100000,"year":2023,"month":4}
3+
{"index":{"_id":"2"}}
4+
{"name":"Hello","occupation":"Artist","country":"USA","salary":70000,"year":2023,"month":4}
5+
{"index":{"_id":"3"}}
6+
{"name":"John","occupation":"Doctor","country":"Canada","salary":120000,"year":2023,"month":4}
7+
{"index":{"_id":"4"}}
8+
{"name":"David","occupation":"Doctor","country":"USA","salary":120000,"year":2023,"month":4}
9+
{"index":{"_id":"5"}}
10+
{"name":"David","occupation":"Unemployed","country":"Canada","salary":0,"year":2023,"month":4}
11+
{"index":{"_id":"6"}}
12+
{"name":"Jane","occupation":"Scientist","country":"Canada","salary":90000,"year":2023,"month":4}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{"index":{"_id":"1"}}
2+
{"name":"Jake","age":70,"state":"California","country":"USA","year":2023,"month":4}
3+
{"index":{"_id":"2"}}
4+
{"name":"Hello","age":30,"state":"New York","country":"USA","year":2023,"month":4}
5+
{"index":{"_id":"3"}}
6+
{"name":"John","age":25,"state":"Ontario","country":"Canada","year":2023,"month":4}
7+
{"index":{"_id":"4"}}
8+
{"name":"Jane","age":20,"state":"Quebec","country":"Canada","year":2023,"month":4}
9+
{"index":{"_id":"5"}}
10+
{"name":"Jim","age":27,"state":"B.C","country":"Canada","year":2023,"month":4}
11+
{"index":{"_id":"6"}}
12+
{"name":"Peter","age":57,"state":"B.C","country":"Canada","year":2023,"month":4}
13+
{"index":{"_id":"7"}}
14+
{"name":"Rick","age":70,"state":"B.C","country":"Canada","year":2023,"month":4}
15+
{"index":{"_id":"8"}}
16+
{"name":"David","age":40,"state":"Washington","country":"USA","year":2023,"month":4}

0 commit comments

Comments
 (0)