Skip to content

Commit

Permalink
update appendonly with overwrite for test names
Browse files Browse the repository at this point in the history
Signed-off-by: YANGDB <[email protected]>
  • Loading branch information
YANG-DB committed Dec 2, 2024
1 parent bc74c0c commit 8e6ec1b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ public static LogicalPlan lookup(
LogicalPlan input,
String indexName,
Map<ReferenceExpression, ReferenceExpression> matchFieldMap,
Boolean appendOnly,
Boolean overwrite,
Map<ReferenceExpression, ReferenceExpression> copyFields) {
return new LogicalLookup(input, indexName, matchFieldMap, appendOnly, copyFields);
return new LogicalLookup(input, indexName, matchFieldMap, overwrite, copyFields);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public static LookupOperator lookup(
PhysicalPlan input,
String indexName,
Map<ReferenceExpression, ReferenceExpression> matchFieldMap,
Boolean appendOnly,
Boolean overwrite,
Map<ReferenceExpression, ReferenceExpression> copyFieldMap,
BiFunction<String, Map<String, Object>, Map<String, Object>> lookupFunction) {
return new LookupOperator(
input, indexName, matchFieldMap, appendOnly, copyFieldMap, lookupFunction);
input, indexName, matchFieldMap, overwrite, copyFieldMap, lookupFunction);
}

public WindowOperator window(
Expand Down
8 changes: 4 additions & 4 deletions docs/user/ppl/cmd/lookup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Description
Syntax
============
lookup <lookup-index> <lookup-field> [AS <local-lookup-field>] ["," <lookup-field> [AS <local-lookup-field>]]... [appendonly=<bool>] [<source-field> [AS <local-source-field>]] ["," <source-field> [AS <local-source-field>]]...
lookup <lookup-index> <lookup-field> [AS <local-lookup-field>] ["," <lookup-field> [AS <local-lookup-field>]]... [overwrite=<bool>] [<source-field> [AS <local-source-field>]] ["," <source-field> [AS <local-source-field>]]...

* lookup-index: mandatory. the name of the lookup index. If more than one is provided, all of them must match.
* lookup-field: mandatory. the name of the lookup field. Must be existing in the lookup-index. It is used to match to a local field (in the current search) to get the lookup document. When there is no lookup document matching it is a no-op. If there is more than one an exception is thrown.
* local-lookup-field: optional. the name of a field in the current search to match against the lookup-field. **Default:** value of lookup-field.
* appendonly: optional. indicates if the values to copy over to the search result from the lookup document should overwrite existing values. If true no existing values are overwritten. **Default:** false.
* overwrite: optional. indicates if the values to copy over to the search result from the lookup document should overwrite existing values. If true no existing values are overwritten. **Default:** false.
* source-field: optional. the fields to copy over from the lookup document to the search result. If no such fields are given all fields are copied. **Default:** all fields
* local-source-field: optional. the final name of the field in the search result (if different from the field name in the lookup document). **Default:** value of source-field.

Expand Down Expand Up @@ -125,7 +125,7 @@ PPL query::
| 21 | NULL | finance | false |
+------------------+--------------+------------+--------+

os> source=accounts | lookup hr employee_number AS account_number, dep AS department appendonly=true;
os> source=accounts | lookup hr employee_number AS account_number, dep AS department overwrite=true;
fetched rows / total rows = 4/4
+------------------+----------+------------------+------------+-----------+---------+-----------------+
| account_number | gender | name | department | active | dep | employee_number |
Expand All @@ -136,7 +136,7 @@ PPL query::
| 21 | F | Mandy Smith | it | NULL | it | 21 |
+------------------+----------+------------------+------------+-----------+---------+-----------------+

os> source=accounts | lookup hr employee_number AS account_number, dep AS department appendonly=false;
os> source=accounts | lookup hr employee_number AS account_number, dep AS department overwrite=false;
fetched rows / total rows = 4/4
+------------------+----------+------------------+------------+-----------+---------+-----------------+
| account_number | gender | name | department | active | dep | employee_number |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void testLookupSelectedMultipleAttributes() throws IOException {
}

@Test
public void testLookupShouldAppendOnlyShouldBeFalseByDefault() throws IOException {
public void testLookupShouldOverwriteShouldBeFalseByDefault() throws IOException {
JSONObject result =
executeQuery(
String.format(
Expand Down Expand Up @@ -212,11 +212,11 @@ public void testLookupShouldAppendOnlyShouldBeFalseByDefault() throws IOExceptio
}

@Test
public void testLookupWithAppendOnlyFalse() throws IOException {
public void testLookupWithOverwriteFalse() throws IOException {
JSONObject result =
executeQuery(
String.format(
"source=%s | rename temperature as vendor | lookup %s did as device-id appendonly ="
"source=%s | rename temperature as vendor | lookup %s did as device-id overwrite ="
+ " true | sort @timestamp",
TEST_INDEX_IOT_READINGS, TEST_INDEX_IOT_SENSORS));
verifyDataRows(
Expand Down

0 comments on commit 8e6ec1b

Please sign in to comment.