MasseGuillaume commented on code in PR #3262: URL: https://github.com/apache/calcite/pull/3262#discussion_r1237043630
########## site/_docs/reference.md: ########## @@ -2740,9 +2740,11 @@ BigQuery's type system uses confusingly different names for types and functions: | m | TO_BASE64(string) | Converts the *string* to base-64 encoded form and returns a encoded string | b m | FROM_BASE64(string) | Returns the decoded result of a base-64 *string* as a string | b o | LTRIM(string) | Returns *string* with all blanks removed from the start +| s | MAP_CONCAT(map [, map]*) | Concatenates one or more maps. If any input argument is `NULL` the function returns `NULL` Review Comment: https://github.com/apache/calcite/pull/3238#discussion_r1222473808 We should document somewhere that Calcite is using the LAST_WIN strategy. Ideally we could make this configurable, but that's annother PR/JIRA issue. ########## testkit/src/main/java/org/apache/calcite/test/SqlOperatorTest.java: ########## @@ -5646,6 +5646,33 @@ private static void checkIf(SqlOperatorFixture f) { + "'SORT_ARRAY\\(<ARRAY>, <BOOLEAN>\\)'", false); } + /** Tests {@code MAP_CONCAT} function from Spark. */ + @Test void testMapConcatFunc() { + final SqlOperatorFixture f0 = fixture(); + f0.setFor(SqlLibraryOperators.MAP_CONCAT); + f0.checkFails("^map_concat(map['foo', 1], map['bar', 2])^", + "No match found for function signature MAP_CONCAT\\(" + + "<\\(CHAR\\(3\\), INTEGER\\) MAP>, <\\(CHAR\\(3\\), INTEGER\\) MAP>\\)", false); + + final SqlOperatorFixture f = f0.withLibrary(SqlLibrary.SPARK); + f.checkScalar("map_concat(map['foo', 1], map['bar', 2])", "{foo=1, bar=2}", + "(CHAR(3) NOT NULL, INTEGER NOT NULL) MAP NOT NULL"); + f.checkScalar("map_concat(map['foo', 1], map['bar', 2], map['foo', 2])", "{foo=2, bar=2}", + "(CHAR(3) NOT NULL, INTEGER NOT NULL) MAP NOT NULL"); + f.checkScalar("map_concat(map[null, 1], map[null, 2])", "{null=2}", + "(NULL, INTEGER NOT NULL) MAP NOT NULL"); + f.checkScalar("map_concat(map[1, 2], map[1, null])", "{1=null}", + "(INTEGER NOT NULL, INTEGER) MAP NOT NULL"); + f.checkNull("map_concat(map['foo', 1], null)"); + f.checkType("map_concat(map['foo', 1], null)", "(CHAR(3) NOT NULL, INTEGER NOT NULL) MAP"); + f.checkNull("map_concat(null, map['foo', 1])"); + f.checkType("map_concat(null, map['foo', 1])", "(CHAR(3) NOT NULL, INTEGER NOT NULL) MAP"); + f.checkFails("^map_concat()^", INVALID_ARGUMENTS_NUMBER, false); Review Comment: ``` spark.sql("select map_concat()").show +------------+ |map_concat()| +------------+ | {}| +------------+ ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
