[GitHub] [spark] maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] Port strings.sql

2019-07-29 Thread GitBox
maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] 
Port strings.sql
URL: https://github.com/apache/spark/pull/24923#discussion_r308533221
 
 

 ##
 File path: sql/core/src/test/resources/sql-tests/results/pgSQL/strings.sql.out
 ##
 @@ -0,0 +1,718 @@
+-- Automatically generated by SQLQueryTestSuite
+-- Number of queries: 88
+
+
+-- !query 0
+SELECT 'first line'
+' - next line'
+   ' - third line'
+   AS `Three lines to one`
+-- !query 0 schema
+struct
+-- !query 0 output
+first line - next line - third line
+
+
+-- !query 1
+SELECT 'first line'
+' - next line' /* this comment is not allowed here */
+' - third line'
+   AS `Illegal comment within continuation`
+-- !query 1 schema
+struct
+-- !query 1 output
+first line - next line - third line
+
+
+-- !query 2
+SELECT binary('\\xDeAdBeEf')
+-- !query 2 schema
+struct
+-- !query 2 output
+\xDeAdBeEf
 
 Review comment:
   different output? 
https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/expected/strings.out#L160


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] Port strings.sql

2019-07-29 Thread GitBox
maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] 
Port strings.sql
URL: https://github.com/apache/spark/pull/24923#discussion_r308532011
 
 

 ##
 File path: sql/core/src/test/resources/sql-tests/results/pgSQL/strings.sql.out
 ##
 @@ -0,0 +1,718 @@
+-- Automatically generated by SQLQueryTestSuite
+-- Number of queries: 88
+
+
+-- !query 0
+SELECT 'first line'
+' - next line'
+   ' - third line'
+   AS `Three lines to one`
+-- !query 0 schema
+struct
+-- !query 0 output
+first line - next line - third line
+
+
+-- !query 1
+SELECT 'first line'
+' - next line' /* this comment is not allowed here */
+' - third line'
+   AS `Illegal comment within continuation`
+-- !query 1 schema
+struct
+-- !query 1 output
+first line - next line - third line
+
+
+-- !query 2
+SELECT binary('\\xDeAdBeEf')
+-- !query 2 schema
+struct
+-- !query 2 output
+\xDeAdBeEf
+
+
+-- !query 3
+SELECT binary('\\x De Ad Be Ef ')
+-- !query 3 schema
+struct
+-- !query 3 output
+\x De Ad Be Ef
 
 Review comment:
   different output? 
https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/expected/strings.out#L111


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] Port strings.sql

2019-07-29 Thread GitBox
maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] 
Port strings.sql
URL: https://github.com/apache/spark/pull/24923#discussion_r308532011
 
 

 ##
 File path: sql/core/src/test/resources/sql-tests/results/pgSQL/strings.sql.out
 ##
 @@ -0,0 +1,718 @@
+-- Automatically generated by SQLQueryTestSuite
+-- Number of queries: 88
+
+
+-- !query 0
+SELECT 'first line'
+' - next line'
+   ' - third line'
+   AS `Three lines to one`
+-- !query 0 schema
+struct
+-- !query 0 output
+first line - next line - third line
+
+
+-- !query 1
+SELECT 'first line'
+' - next line' /* this comment is not allowed here */
+' - third line'
+   AS `Illegal comment within continuation`
+-- !query 1 schema
+struct
+-- !query 1 output
+first line - next line - third line
+
+
+-- !query 2
+SELECT binary('\\xDeAdBeEf')
+-- !query 2 schema
+struct
+-- !query 2 output
+\xDeAdBeEf
+
+
+-- !query 3
+SELECT binary('\\x De Ad Be Ef ')
+-- !query 3 schema
+struct
+-- !query 3 output
+\x De Ad Be Ef
 
 Review comment:
   different output? 
https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/expected/strings.out#L111


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:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] Port strings.sql

2019-07-29 Thread GitBox
maropu commented on a change in pull request #24923: [SPARK-28071][SQL][TEST] 
Port strings.sql
URL: https://github.com/apache/spark/pull/24923#discussion_r308531894
 
 

 ##
 File path: sql/core/src/test/resources/sql-tests/inputs/pgSQL/strings.sql
 ##
 @@ -0,0 +1,656 @@
+--
+-- Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
+--
+-- STRINGS
+-- -- 
https://github.com/postgres/postgres/blob/REL_12_BETA1/src/test/regress/sql/strings.sql
+-- Test various data entry syntaxes.
+--
+
+-- [SPARK-28073] ANSI SQL: Character literals
+-- SQL string continuation syntax
+-- E021-03 character string literals
+-- SELECT 'first line'
+-- ' - next line'
+-- ' - third line'
+-- AS "Three lines to one";
+
+-- illegal string continuation syntax
+-- SELECT 'first line'
+-- ' - next line' /* this comment is not allowed here */
+-- ' - third line'
+-- AS "Illegal comment within continuation";
+
+-- Unicode escapes
+-- SET standard_conforming_strings TO on;
+
+SELECT U&'d\0061t\+61' AS U&"d\0061t\+61";
+SELECT U&'d!0061t\+61' UESCAPE '!' AS U&"d*0061t\+61" UESCAPE '*';
+
+SELECT U&' \' UESCAPE '!' AS "tricky";
+SELECT 'tricky' AS U&"\" UESCAPE '!';
+
+SELECT U&'wrong: \061';
+SELECT U&'wrong: \+0061';
+SELECT U&'wrong: +0061' UESCAPE '+';
+
+-- SET standard_conforming_strings TO off;
+
+SELECT U&'d\0061t\+61' AS U&"d\0061t\+61";
+SELECT U&'d!0061t\+61' UESCAPE '!' AS U&"d*0061t\+61" UESCAPE '*';
+
+SELECT U&' \' UESCAPE '!' AS "tricky";
+SELECT 'tricky' AS U&"\" UESCAPE '!';
+
+SELECT U&'wrong: \061';
+SELECT U&'wrong: \+0061';
+SELECT U&'wrong: +0061' UESCAPE '+';
+
+-- RESET standard_conforming_strings;
+
+-- Spark SQL only support escape mode
+-- bytea
+-- SET bytea_output TO hex;
+-- SELECT E'\\xDeAdBeEf'::bytea;
+-- SELECT E'\\x De Ad Be Ef '::bytea;
+-- SELECT E'\\xDeAdBeE'::bytea;
+-- SELECT E'\\xDeAdBeEx'::bytea;
+-- SELECT E'\\xDe00BeEf'::bytea;
+-- SELECT E'DeAdBeEf'::bytea;
+-- SELECT E'De\\000dBeEf'::bytea;
+-- SELECT E'De\123dBeEf'::bytea;
+-- SELECT E'De\\123dBeEf'::bytea;
+-- SELECT E'De\\678dBeEf'::bytea;
+
+-- SET bytea_output TO escape;
+SELECT binary('\\xDeAdBeEf');
+SELECT binary('\\x De Ad Be Ef ');
+SELECT binary('\\xDe00BeEf');
+SELECT binary('DeAdBeEf');
+SELECT binary('De\\000dBeEf');
+SELECT binary('De\\123dBeEf');
+
+-- Skip these tests because we do not have char/varchar type
+--
+-- test conversions between various string types
+-- E021-10 implicit casting among the character data types
+--
+
+-- SELECT CAST(f1 AS text) AS "text(char)" FROM CHAR_TBL;
+
+-- SELECT CAST(f1 AS text) AS "text(varchar)" FROM VARCHAR_TBL;
+
+-- SELECT CAST(name 'namefield' AS text) AS "text(name)";
+
+-- since this is an explicit cast, it should truncate w/o error:
+-- SELECT CAST(f1 AS char(10)) AS "char(text)" FROM TEXT_TBL;
+-- note: implicit-cast case is tested in char.sql
+
+-- SELECT CAST(f1 AS char(20)) AS "char(text)" FROM TEXT_TBL;
+
+-- SELECT CAST(f1 AS char(10)) AS "char(varchar)" FROM VARCHAR_TBL;
+
+-- SELECT CAST(name 'namefield' AS char(10)) AS "char(name)";
+
+-- SELECT CAST(f1 AS varchar) AS "varchar(text)" FROM TEXT_TBL;
+
+-- SELECT CAST(f1 AS varchar) AS "varchar(char)" FROM CHAR_TBL;
+
+-- SELECT CAST(name 'namefield' AS varchar) AS "varchar(name)";
+
+--
+-- test SQL string functions
+-- E### and T### are feature reference numbers from SQL99
+--
+
+-- E021-09 trim function
+SELECT TRIM(BOTH FROM '  bunch o blanks  ') = 'bunch o blanks' AS `bunch o 
blanks`;
+
+SELECT TRIM(LEADING FROM '  bunch o blanks  ') = 'bunch o blanks  ' AS `bunch 
o blanks  `;
+
+SELECT TRIM(TRAILING FROM '  bunch o blanks  ') = '  bunch o blanks' AS `  
bunch o blanks`;
+
+SELECT TRIM(BOTH 'x' FROM 'xsome Xsx') = 'some Xs' AS `some Xs`;
+
+-- E021-06 substring expression
+SELECT SUBSTRING('1234567890' FROM 3) = '34567890' AS `34567890`;
+
+SELECT SUBSTRING('1234567890' FROM 4 FOR 3) = '456' AS `456`;
+
+-- [SPARK-28076] Support regular expression substring
+-- T581 regular expression substring (with SQL's bizarre regexp syntax)
+-- SELECT SUBSTRING('abcdefg' FROM 'a#"(b_d)#"%' FOR '#') AS "bcd";
+
+-- No match should return NULL
+-- SELECT SUBSTRING('abcdefg' FROM '#"(b_d)#"%' FOR '#') IS NULL AS "True";
+
+-- Null inputs should return NULL
+-- SELECT SUBSTRING('abcdefg' FROM '%' FOR NULL) IS NULL AS "True";
+-- SELECT SUBSTRING(NULL FROM '%' FOR '#') IS NULL AS "True";
+-- SELECT SUBSTRING('abcdefg' FROM NULL FOR '#') IS NULL AS "True";
+
+-- The first and last parts should act non-greedy
+-- SELECT SUBSTRING('abcdefg' FROM 'a#"%#"g' FOR '#') AS "bcdef";
+-- SELECT SUBSTRING('abcdefg' FROM 'a*#"%#"g*' FOR '#') AS "abcdefg";
+
+-- Vertical bar in any part affects only that part
+-- SELECT SUBSTRING('abcdefg' FROM 'a|b#"%#"g' FOR '#') AS "bcdef";
+-- SELECT SUBSTRING('abcdefg' FROM 'a#"%#"x|g' FOR '#') AS "bcdef";
+-- SELECT SUBSTRING('abcdefg' FROM 'a#"%|ab#"g' FOR '#') AS "bcdef";
+
+-- Can't have more than two part separators
+-- SEL