Skip to content

Commit ec7d19b

Browse files
committed
[Feature] implement transpose command as in the roadmap opensearch-project#4786 (opensearch-project#5011)
* transpose command implementation Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * transpose rows to columns Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added argument type missing map and hashmap Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added tests Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added more validations Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added validation Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * index.md formatting fix Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * doc format Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * coderabbit review fixes Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added recommended changes Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added recommended changes Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * for cross cluster failure debugging Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * for cross cluster failure debugging Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * for cross cluster failure debugging Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * trim columnName Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * per review moved to class varialble. Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * per review moved to class varialble. Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * added field resolution Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * fix by removing metadata field Signed-off-by: Asif Bashar <asif.bashar@gmail.com> * fixed explain test after removing of metadata fields in transpose result Signed-off-by: Asif Bashar <asif.bashar@gmail.com> --------- Signed-off-by: Asif Bashar <asif.bashar@gmail.com> # Conflicts: # integ-test/src/test/java/org/opensearch/sql/ppl/NewAddedCommandsIT.java # ppl/src/main/antlr/OpenSearchPPLLexer.g4
1 parent 269f04a commit ec7d19b

3 files changed

Lines changed: 19 additions & 2 deletions

File tree

integ-test/src/test/java/org/opensearch/sql/ppl/NewAddedCommandsIT.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ public void testTransposeCommand() throws IOException {
213213
}
214214
}
215215

216+
216217
@Test
217218
public void testFieldFormatCommand() throws IOException {
218219
JSONObject result;

integ-test/src/test/java/org/opensearch/sql/security/CrossClusterSearchIT.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,24 @@ public void testCrossClusterTranspose() throws IOException {
305305
rows("age", "28", "36", "33"));
306306
}
307307

308+
@Test
309+
public void testCrossClusterTranspose() throws IOException {
310+
// Test query_string without fields parameter on remote cluster
311+
JSONObject result =
312+
executeQuery(
313+
String.format(
314+
"search source=%s | where firstname='Hattie' or firstname ='Nanette' or"
315+
+ " firstname='Dale'|sort firstname desc |fields firstname,age,balance |"
316+
+ " transpose 3 column_name='column_names'",
317+
TEST_INDEX_BANK_REMOTE));
318+
319+
verifyDataRows(
320+
result,
321+
rows("firstname", "Nanette", "Hattie", "Dale"),
322+
rows("balance", "32838", "5686", "4180"),
323+
rows("age", "28", "36", "33"));
324+
}
325+
308326
@Test
309327
public void testCrossClusterAppend() throws IOException {
310328
// TODO: We should enable calcite by default in CrossClusterSearchIT?

ppl/src/main/antlr/OpenSearchPPLLexer.g4

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ AGGREGATION: 'AGGREGATION';
7474
APPENDPIPE: 'APPENDPIPE';
7575
COLUMN_NAME: 'COLUMN_NAME';
7676

77-
7877
//Native JOIN KEYWORDS
7978
JOIN: 'JOIN';
8079
ON: 'ON';
@@ -161,7 +160,6 @@ INPUT: 'INPUT';
161160
OUTPUT: 'OUTPUT';
162161
PATH: 'PATH';
163162

164-
165163
// COMPARISON FUNCTION KEYWORDS
166164
CASE: 'CASE';
167165
ELSE: 'ELSE';

0 commit comments

Comments
 (0)