Skip to content

Commit a15babf

Browse files
authored
Add example for String concat in eval.rst (opensearch-project#4075)
* Add example for String concat in eval.rst Signed-off-by: Kai Huang <ahkcs@amazon.com> * mention calcite enabling Signed-off-by: Kai Huang <ahkcs@amazon.com> --------- Signed-off-by: Kai Huang <ahkcs@amazon.com>
1 parent c8d2694 commit a15babf

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

docs/user/ppl/cmd/eval.rst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,41 @@ PPL query::
7676
| 33 | 66 | 132 |
7777
+-----+-----------+-------+
7878

79+
Example 4: String concatenation with + operator(need to enable calcite)
80+
===============================================
81+
82+
The example shows how to use the + operator for string concatenation in eval command. You can concatenate string literals and field values.
83+
84+
PPL query example 1 - Concatenating a literal with a field::
85+
86+
source=accounts | eval greeting = 'Hello ' + firstname | fields firstname, greeting
87+
88+
Expected result::
89+
90+
+---------------+---------------------+
91+
| firstname | greeting |
92+
|---------------+---------------------|
93+
| Amber JOHnny | Hello Amber JOHnny |
94+
| Hattie | Hello Hattie |
95+
| Nanette | Hello Nanette |
96+
| Dale | Hello Dale |
97+
+---------------+---------------------+
98+
99+
PPL query example 2 - Multiple concatenations with type casting::
100+
101+
source=accounts | eval full_info = 'Name: ' + firstname + ', Age: ' + CAST(age AS STRING) | fields firstname, age, full_info
102+
103+
Expected result::
104+
105+
+---------------+-----+-------------------------------+
106+
| firstname | age | full_info |
107+
|---------------+-----+-------------------------------|
108+
| Amber JOHnny | 32 | Name: Amber JOHnny, Age: 32 |
109+
| Hattie | 36 | Name: Hattie, Age: 36 |
110+
| Nanette | 28 | Name: Nanette, Age: 28 |
111+
| Dale | 33 | Name: Dale, Age: 33 |
112+
+---------------+-----+-------------------------------+
113+
79114
Limitation
80115
==========
81116
The ``eval`` command is not rewritten to OpenSearch DSL, it is only executed on the coordination node.

0 commit comments

Comments
 (0)