Skip to content

Commit 0f39164

Browse files
committed
Add antoher test case for coalesce & disable coalesce's doctest
Signed-off-by: Yuanchun Shen <yuanchu@amazon.com>
1 parent 3f7a56b commit 0f39164

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

docs/user/ppl/functions/condition.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,13 @@ Version: 3.1.0
248248

249249
Usage: coalesce(field1, field2, ...) return the first non-null value in the argument list.
250250

251-
Argument type: all the supported data type, (NOTE : if parameters have different type, you will fail semantic check)
251+
Argument type: all the supported data type. The data types of all fields must be same.
252252

253253
Return type: any
254254

255255
Example::
256256

257-
os> source=accounts | eval result = coalesce(employer, firstname, lastname) | fields result, firstname, lastname, employer
257+
PPL source=accounts | eval result = coalesce(employer, firstname, lastname) | fields result, firstname, lastname, employer
258258
fetched rows / total rows = 4/4
259259
+---------+-----------+----------+----------+
260260
| result | firstname | lastname | employer |

integ-test/src/test/java/org/opensearch/sql/calcite/standalone/CalcitePPLConditionBuiltinFunctionIT.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,20 @@ public void testCoalesce() {
113113
JSONObject actual =
114114
executeQuery(
115115
String.format(
116-
"source=%s | where age = 10 | eval new_country = coalesce(name, state, country) | fields name, state, country, new_country",
116+
"source=%s | where age = 10 | eval new_country = coalesce(name, state, country),"
117+
+ " null = coalesce(name, state, name) | fields name, state, country,"
118+
+ " new_country, null",
117119
TEST_INDEX_STATE_COUNTRY_WITH_NULL));
118120

119-
verifySchema(actual, schema("name", "string"), schema("state", "string"), schema("country", "string"), schema("new_country", "string"));
120-
121-
verifyDataRows(
121+
verifySchema(
122122
actual,
123-
rows(null, null, "Canada", "Canada"));
123+
schema("name", "string"),
124+
schema("state", "string"),
125+
schema("country", "string"),
126+
schema("new_country", "string"),
127+
schema("null", "string"));
128+
129+
verifyDataRows(actual, rows(null, null, "Canada", "Canada", null));
124130
}
125131

126132
@Test

0 commit comments

Comments
 (0)