forked from opensearch-project/sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
expand.rst
documentation and further updates to tests/implement…
…ation. Signed-off-by: currantw <[email protected]>
- Loading branch information
Showing
10 changed files
with
124 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,91 @@ | ||
============= | ||
flatten | ||
expand | ||
============= | ||
|
||
TODO #3016: Add documentation for expand command | ||
.. rubric:: Table of contents | ||
|
||
.. contents:: | ||
:local: | ||
:depth: 2 | ||
|
||
Description | ||
============ | ||
|
||
The ``expand`` command expands a field that contains an array of values to produce a seperate row for each value in the | ||
array. If the field does not contain an array, the row is not modified. | ||
|
||
Syntax | ||
============ | ||
|
||
``expand <field>`` | ||
|
||
* ``field``: reference to the field to flatten. | ||
|
||
Example 1: Expand a field | ||
========================= | ||
|
||
PPL query:: | ||
|
||
os> source=expand | expand team | fields city, team.name | ||
fetched rows / total rows = 7/7 | ||
+--------------+-------------------+ | ||
| city | team.name | | ||
|--------------+-------------------| | ||
| Seattle | Seattle Seahawks | | ||
| Seattle | Seattle Kraken | | ||
| Vancouver | Vancouver Canucks | | ||
| Vancouver | BC Lions | | ||
| San Antonio | San Antonio Spurs | | ||
| Null Team | null | | ||
| Missing Team | null | | ||
+--------------+-------------------+ | ||
|
||
Example 2: Expand a nested field | ||
================================= | ||
|
||
PPL query:: | ||
|
||
os> source=expand | where city = 'San Antonio' | expand team.title | fields team.name, team.title | ||
fetched rows / total rows = 5/5 | ||
+-------------------+------------+ | ||
| team.name | team.title | | ||
|-------------------+------------| | ||
| San Antonio Spurs | 1999 | | ||
| San Antonio Spurs | 2003 | | ||
| San Antonio Spurs | 2005 | | ||
| San Antonio Spurs | 2007 | | ||
| San Antonio Spurs | 2014 | | ||
+-------------------+------------+ | ||
|
||
Example 3: Expand multiple fields | ||
================================== | ||
|
||
PPL query:: | ||
|
||
os> source=expand | expand team | expand team.title | fields team.name, team.title | ||
fetched rows / total rows = 16/16 | ||
+-------------------+------------+ | ||
| team.name | team.title | | ||
|-------------------+------------| | ||
| Seattle Seahawks | 2014 | | ||
| Seattle Kraken | null | | ||
| Vancouver Canucks | null | | ||
| BC Lions | 1964 | | ||
| BC Lions | 1985 | | ||
| BC Lions | 1994 | | ||
| BC Lions | 2000 | | ||
| BC Lions | 2006 | | ||
| BC Lions | 2011 | | ||
| San Antonio Spurs | 1999 | | ||
| San Antonio Spurs | 2003 | | ||
| San Antonio Spurs | 2005 | | ||
| San Antonio Spurs | 2007 | | ||
| San Antonio Spurs | 2014 | | ||
| null | null | | ||
| null | null | | ||
+-------------------+------------+ | ||
|
||
Example 4: Expand and flatten | ||
============================= | ||
|
||
TODO #3016: Test once flatten merged. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{"name": "Seattle", "location": { "state": "Washington", "country": "United States", "coordinates": {"latitude": 47.6061, "longitude": -122.3328}}} | ||
{"name": "Vancouver", "location": { "province": "British Columbia", "country": "Canada", "coordinates": {"latitude": 49.2827, "longitude": -123.1207}}} | ||
{"name": "Null Location", "location": null} | ||
{"name": "Null Coordinates", "location": { "state": "Victoria", "country": "Australia", "coordinates": null}} | ||
{"city": "Seattle", "team":[{"name": "Seattle Seahawks", "title": 2014}, {"name": "Seattle Kraken", "title": null}]} | ||
{"city": "Vancouver", "team":[{"name": "Vancouver Canucks", "title": null}, {"name": "BC Lions", "title": [1964, 1985, 1994, 2000, 2006, 2011]}]} | ||
{"city": "San Antonio", "team": {"name": "San Antonio Spurs", "title": [1999, 2003, 2005, 2007, 2014]}} | ||
{"city": "Null Team", "team": null} | ||
{"city": "Missing Team"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
{"index":{"_id":"1"}} | ||
{"city": "Seattle", "team":[{"name": "Seattle Seahawks", "title": 2014}, {"name": "Seattle Kraken", "title": []}]} | ||
{"city": "Seattle", "team":[{"name": "Seattle Seahawks", "title": 2014}, {"name": "Seattle Kraken", "title": null}]} | ||
{"index":{"_id":"2"}} | ||
{"city": "Vancouver", "team":[{"name": "Vancouver Canucks", "title": null}, {"name": "BC Lions", "title": [1964, 1985, 1994, 2000, 2006, 2011]}]} | ||
{"index":{"_id":"3"}} | ||
{"city": "San Antonio", "team": {"name": "San Antonio Spurs", "title": [1999, 2003, 2005, 2007, 2014]}} | ||
{"index":{"_id":"4"}} | ||
{"city": "Empty Sports Team", "team": []} | ||
{"city": "Null Team", "team": null} | ||
{"index":{"_id":"5"}} | ||
{"city": "Null Sports Team", "team": null} | ||
{"index":{"_id":"6"}} | ||
{"city": "Missing Sports Team"} | ||
{"city": "Missing Team"} |