wangyum commented on a change in pull request #24862: [WIP][SPARK-28038][SQL][TEST] Port text.sql URL: https://github.com/apache/spark/pull/24862#discussion_r293358428
########## File path: sql/core/src/test/resources/sql-tests/inputs/pgSQL/text.sql ########## @@ -0,0 +1,131 @@ +-- +-- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group +-- +-- +-- TEXT +-- https://github.com/postgres/postgres/blob/REL_12_BETA1/src/test/regress/sql/text.sql + +SELECT string('this is a text string') = string('this is a text string') AS true; + +SELECT string('this is a text string') = string('this is a text strin') AS false; + +CREATE TABLE TEXT_TBL (f1 string) USING parquet; + +INSERT INTO TEXT_TBL VALUES ('doh!'); +INSERT INTO TEXT_TBL VALUES ('hi de ho neighbor'); + +SELECT '' AS two, * FROM TEXT_TBL; + +-- As of 8.3 we have removed most implicit casts to text, so that for example +-- this no longer works: +-- Spark SQL implicit cast integer to string +select length(42); + +-- But as a special exception for usability's sake, we still allow implicit +-- casting to text in concatenations, so long as the other input is text or +-- an unknown literal. So these work: +-- [SPARK-28033] String concatenation low priority than other arithmeticBinary +select string('four: ') || 2+2; +select string('four: ') || 2+2; + +-- but not this: +-- Spark SQL implicit cast both side to string +select 3 || 4.0; + +/* + * various string functions + */ +select concat('one'); +-- Spark SQL does not support YYYYMMDD, we replace it to yyyyMMdd +select concat(1,2,3,'hello',true, false, to_date('20100309','yyyyMMdd')); +select concat_ws('#','one'); +select concat_ws('#',1,2,3,'hello',true, false, to_date('20100309','yyyyMMdd')); +select concat_ws(',',10,20,null,30); +select concat_ws('',10,20,null,30); +select concat_ws(NULL,10,20,null,30) is null; +select reverse('abcde'); +-- [SPARK-28036] Built-in udf left/right has inconsistent behavior +select i, left('ahoj', i), right('ahoj', i) from range(-5, 5) t(i) order by i; +-- [SPARK-28037] Add built-in String Functions: quote_literal +select quote_literal(''); +select quote_literal('abc'''); +select quote_literal(e'\\'); +-- check variadic labeled argument +select concat(variadic array[1,2,3]); Review comment: Do we need to test `variadic` labeled argument? ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
