Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array values are preserved (#1300) #3095

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/user/beyond/partiql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ Selecting top level for object fields, object fields of array value and nested f

os> SELECT city, accounts, projects FROM people;
fetched rows / total rows = 1/1
+-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------+
| city | accounts | projects |
|-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------|
| {'name': 'Seattle', 'location': {'latitude': 10.5}} | {'id': 1} | [{'name': 'AWS Redshift Spectrum querying'},{'name': 'AWS Redshift security'},{'name': 'AWS Aurora security'}] |
+-----------------------------------------------------+-----------+----------------------------------------------------------------------------------------------------------------+
+-----------------------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------------+
| city | accounts | projects |
|-----------------------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------------|
| {'name': 'Seattle', 'location': {'latitude': 10.5}} | [{'id': 1},{'id': 2}] | [{'name': 'AWS Redshift Spectrum querying'},{'name': 'AWS Redshift security'},{'name': 'AWS Aurora security'}] |
+-----------------------------------------------------+-----------------------+----------------------------------------------------------------------------------------------------------------+

Example 2: Selecting Deeper Levels
----------------------------------
Expand Down
10 changes: 5 additions & 5 deletions docs/user/ppl/general/datatypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ Select deeper level for object fields of array value which returns the first ele

os> source = people | fields accounts, accounts.id;
fetched rows / total rows = 1/1
+-----------+-------------+
| accounts | accounts.id |
|-----------+-------------|
| {'id': 1} | 1 |
+-----------+-------------+
+-----------------------+-------------+
| accounts | accounts.id |
|-----------------------+-------------|
| [{'id': 1},{'id': 2}] | 1 |
+-----------------------+-------------+
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testSelectObjectFieldOfArrayValuesItself() {
JSONObject response = new JSONObject(query("SELECT accounts FROM %s"));

// Only the first element of the list of is returned.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comments

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the default behaviour is to only use the first element of an array, this comment is still valid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the comment.

verifyDataRows(response, rows(new JSONObject("{\"id\": 1}")));
verifyDataRows(response, rows(new JSONArray("[{\"id\":1},{\"id\":2}]")));
penghuo marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public void test_nested_in_where_as_predicate_expression_with_multiple_condition
+ " nested(message.dayOfWeek) >= 4";
JSONObject result = executeJdbcRequest(query);
assertEquals(2, result.getInt("total"));
verifyDataRows(result, rows("c", "ab", 4), rows("zz", "aa", 6));
verifyDataRows(result, rows("c", "ab", 4), rows("zz", new JSONArray(List.of("aa", "bb")), 6));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,7 @@ public Iterator<ExprValue> iterator() {
*/
private void addParsedHitsToBuilder(
ImmutableMap.Builder<String, ExprValue> builder, SearchHit hit) {
builder.putAll(
exprValueFactory
.construct(
hit.getSourceAsString(),
!(hit.getInnerHits() == null || hit.getInnerHits().isEmpty()))
.tupleValue());
builder.putAll(exprValueFactory.construct(hit.getSourceAsString(), true).tupleValue());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ void search() {
new SearchHits(
new SearchHit[] {searchHit}, new TotalHits(1L, TotalHits.Relation.EQUAL_TO), 1.0F));
when(searchHit.getSourceAsString()).thenReturn("{\"id\", 1}");
when(searchHit.getInnerHits()).thenReturn(null);
when(factory.construct(any(), anyBoolean())).thenReturn(exprTupleValue);

// Mock second scroll request followed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ void search() throws IOException {
new SearchHits(
new SearchHit[] {searchHit}, new TotalHits(1L, TotalHits.Relation.EQUAL_TO), 1.0F));
when(searchHit.getSourceAsString()).thenReturn("{\"id\", 1}");
when(searchHit.getInnerHits()).thenReturn(null);
when(factory.construct(any(), anyBoolean())).thenReturn(exprTupleValue);

// Mock second scroll request followed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ void iterator() {

when(searchHit1.getSourceAsString()).thenReturn("{\"id1\", 1}");
when(searchHit2.getSourceAsString()).thenReturn("{\"id1\", 2}");
when(searchHit1.getInnerHits()).thenReturn(null);
when(searchHit2.getInnerHits()).thenReturn(null);
when(factory.construct(any(), anyBoolean()))
.thenReturn(exprTupleValue1)
.thenReturn(exprTupleValue2);
Expand Down Expand Up @@ -254,14 +252,6 @@ void iterator_with_inner_hits() {
new SearchHit[] {searchHit1},
new TotalHits(2L, TotalHits.Relation.EQUAL_TO),
1.0F));
when(searchHit1.getInnerHits())
.thenReturn(
Map.of(
"innerHit",
new SearchHits(
new SearchHit[] {searchHit1},
new TotalHits(2L, TotalHits.Relation.EQUAL_TO),
1.0F)));

when(factory.construct(any(), anyBoolean())).thenReturn(exprTupleValue1);

Expand Down