gatorsmile commented on a change in pull request #24767: 
[WIP][SPARK-27918][SQL] Port boolean.sql
URL: https://github.com/apache/spark/pull/24767#discussion_r289695456
 
 

 ##########
 File path: sql/core/src/test/resources/sql-tests/inputs/pgSQL/boolean.sql
 ##########
 @@ -0,0 +1,265 @@
+--
+-- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+--
+--
+-- BOOLEAN
+-- 
https://github.com/postgres/postgres/blob/REL_12_BETA1/src/test/regress/sql/boolean.sql
+
+--
+-- sanity check - if this fails go insane!
+--
+SELECT 1 AS one;
+
+
+-- ******************testing built-in type bool********************
+
+-- check bool input syntax
+
+SELECT true AS true;
+
+SELECT false AS false;
+
+SELECT cast('t' as boolean) AS true;
+
+SELECT cast('   f           ' as boolean) AS false;
+
+SELECT cast('true' as boolean) AS true;
+
+SELECT cast('test' as boolean) AS error;
+
+SELECT cast('false' as boolean) AS false;
+
+SELECT cast('foo' as boolean) AS error;
+
+SELECT cast('y' as boolean) AS true;
+
+SELECT cast('yes' as boolean) AS true;
+
+SELECT cast('yeah' as boolean) AS error;
+
+SELECT cast('n' as boolean) AS false;
+
+SELECT cast('no' as boolean) AS false;
+
+SELECT cast('nay' as boolean) AS error;
+
+SELECT cast('on' as boolean) AS true;
+
+SELECT cast('off' as boolean) AS false;
+
+SELECT cast('of' as boolean) AS false;
+
+SELECT cast('o' as boolean) AS error;
+
+SELECT cast('on_' as boolean) AS error;
+
+SELECT cast('off_' as boolean) AS error;
+
+SELECT cast('1' as boolean) AS true;
+
+SELECT cast('11' as boolean) AS error;
+
+SELECT cast('0' as boolean) AS false;
+
+SELECT cast('000' as boolean) AS error;
+
+SELECT cast('' as boolean) AS error;
+
+-- and, or, not in qualifications
+
+SELECT cast('t' as boolean) or cast('f' as boolean) AS true;
+
+SELECT cast('t' as boolean) and cast('f' as boolean) AS false;
+
+SELECT not cast('f' as boolean) AS true;
+
+SELECT cast('t' as boolean) = cast('f' as boolean) AS false;
+
+SELECT cast('t' as boolean) <> cast('f' as boolean) AS true;
+
+SELECT cast('t' as boolean) > cast('f' as boolean) AS true;
+
+SELECT cast('t' as boolean) >= cast('f' as boolean) AS true;
+
+SELECT cast('f' as boolean) < cast('t' as boolean) AS true;
+
+SELECT cast('f' as boolean) <= cast('t' as boolean) AS true;
+
+-- explicit casts to/from text
+SELECT cast(cast('TrUe' as string) as boolean) AS true, cast(cast('fAlse' as 
string) as boolean) AS false;
+SELECT cast(cast('    true   ' as string) as boolean) AS true,
+       cast(cast('     FALSE' as string) as boolean) AS false;
+SELECT cast(cast(true as boolean) as string) AS true, cast(cast(false as 
boolean) as string) AS false;
+
+SELECT cast(cast('  tru e ' as string) as boolean) AS invalid;    -- error
+SELECT cast(cast('' as string) as boolean) AS invalid;            -- error
+
+CREATE TABLE BOOLTBL1 (f1 boolean) USING parquet;
+
+INSERT INTO BOOLTBL1 VALUES (cast('t' as boolean));
+
+INSERT INTO BOOLTBL1 VALUES (cast('True' as boolean));
+
+INSERT INTO BOOLTBL1 VALUES (cast('true' as boolean));
+
+
+-- BOOLTBL1 should be full of true's at this point
+SELECT '' AS t_3, BOOLTBL1.* FROM BOOLTBL1;
+
+
+SELECT '' AS t_3, BOOLTBL1.*
+   FROM BOOLTBL1
+   WHERE f1 = cast('true' as boolean);
+
+
+SELECT '' AS t_3, BOOLTBL1.*
+   FROM BOOLTBL1
+   WHERE f1 <> cast('false' as boolean);
+
+-- SELECT '' AS zero, BOOLTBL1.*
+--    FROM BOOLTBL1
+--    WHERE booleq(cast('false' as boolean), f1);
 
 Review comment:
   Is `booleq` PostgreSQL specific? 

----------------------------------------------------------------
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]

Reply via email to