LuciferYang commented on a change in pull request #34153:
URL: https://github.com/apache/spark/pull/34153#discussion_r719128295



##########
File path: 
sql/core/src/test/resources/sql-tests/results/postgreSQL/text.sql-jdk17.out
##########
@@ -0,0 +1,360 @@
+-- Automatically generated by SQLQueryTestSuite
+-- Number of queries: 42
+
+
+-- !query
+SELECT string('this is a text string') = string('this is a text string') AS 
true
+-- !query schema
+struct<true:boolean>
+-- !query output
+true
+
+
+-- !query
+SELECT string('this is a text string') = string('this is a text strin') AS 
`false`
+-- !query schema
+struct<false:boolean>
+-- !query output
+false
+
+
+-- !query
+CREATE TABLE TEXT_TBL (f1 string) USING parquet
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+INSERT INTO TEXT_TBL VALUES ('doh!')
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+INSERT INTO TEXT_TBL VALUES ('hi de ho neighbor')
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SELECT '' AS two, * FROM TEXT_TBL
+-- !query schema
+struct<two:string,f1:string>
+-- !query output
+       doh!
+       hi de ho neighbor
+
+
+-- !query
+select length(42)
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'length(42)' due to data type mismatch: argument 1 requires 
(string or binary) type, however, '42' is of int type.; line 1 pos 7
+
+
+-- !query
+select string('four: ') || 2+2
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat(CAST('four: ' AS STRING), 2)' due to data type 
mismatch: input to function concat should have been string, binary or array, 
but it's [string, int]; line 1 pos 7
+
+
+-- !query
+select 'four: ' || 2+2
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat('four: ', 2)' due to data type mismatch: input to 
function concat should have been string, binary or array, but it's [string, 
int]; line 1 pos 7
+
+
+-- !query
+select 3 || 4.0
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat(3, 4.0BD)' due to data type mismatch: input to function 
concat should have been string, binary or array, but it's [int, decimal(2,1)]; 
line 1 pos 7
+
+
+-- !query
+/*
+ * various string functions
+ */
+select concat('one')
+-- !query schema
+struct<concat(one):string>
+-- !query output
+one
+
+
+-- !query
+select concat(1,2,3,'hello',true, false, to_date('20100309','yyyyMMdd'))
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat(1, 2, 3, 'hello', true, false, to_date('20100309', 
'yyyyMMdd'))' due to data type mismatch: input to function concat should have 
been string, binary or array, but it's [int, int, int, string, boolean, 
boolean, date]; line 1 pos 7
+
+
+-- !query
+select concat_ws('#','one')
+-- !query schema
+struct<concat_ws(#, one):string>
+-- !query output
+one
+
+
+-- !query
+select concat_ws('#',1,2,3,'hello',true, false, to_date('20100309','yyyyMMdd'))
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat_ws('#', 1, 2, 3, 'hello', true, false, 
to_date('20100309', 'yyyyMMdd'))' due to data type mismatch: argument 2 
requires (array<string> or string) type, however, '1' is of int type. argument 
3 requires (array<string> or string) type, however, '2' is of int type. 
argument 4 requires (array<string> or string) type, however, '3' is of int 
type. argument 6 requires (array<string> or string) type, however, 'true' is of 
boolean type. argument 7 requires (array<string> or string) type, however, 
'false' is of boolean type. argument 8 requires (array<string> or string) type, 
however, 'to_date('20100309', 'yyyyMMdd')' is of date type.; line 1 pos 7
+
+
+-- !query
+select concat_ws(',',10,20,null,30)
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat_ws(',', 10, 20, NULL, 30)' due to data type mismatch: 
argument 2 requires (array<string> or string) type, however, '10' is of int 
type. argument 3 requires (array<string> or string) type, however, '20' is of 
int type. argument 4 requires (array<string> or string) type, however, 'NULL' 
is of void type. argument 5 requires (array<string> or string) type, however, 
'30' is of int type.; line 1 pos 7
+
+
+-- !query
+select concat_ws('',10,20,null,30)
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat_ws('', 10, 20, NULL, 30)' due to data type mismatch: 
argument 2 requires (array<string> or string) type, however, '10' is of int 
type. argument 3 requires (array<string> or string) type, however, '20' is of 
int type. argument 4 requires (array<string> or string) type, however, 'NULL' 
is of void type. argument 5 requires (array<string> or string) type, however, 
'30' is of int type.; line 1 pos 7
+
+
+-- !query
+select concat_ws(NULL,10,20,null,30) is null
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'concat_ws(CAST(NULL AS STRING), 10, 20, NULL, 30)' due to data 
type mismatch: argument 2 requires (array<string> or string) type, however, 
'10' is of int type. argument 3 requires (array<string> or string) type, 
however, '20' is of int type. argument 4 requires (array<string> or string) 
type, however, 'NULL' is of void type. argument 5 requires (array<string> or 
string) type, however, '30' is of int type.; line 1 pos 7
+
+
+-- !query
+select reverse('abcde')
+-- !query schema
+struct<reverse(abcde):string>
+-- !query output
+edcba
+
+
+-- !query
+select i, left('ahoj', i), right('ahoj', i) from range(-5, 6) t(i) order by i
+-- !query schema
+struct<>
+-- !query output
+org.apache.spark.sql.AnalysisException
+cannot resolve 'substring('ahoj', 1, t.i)' due to data type mismatch: argument 
3 requires int type, however, 't.i' is of bigint type.; line 1 pos 10
+
+
+-- !query
+/*
+ * format
+ */
+select format_string(NULL)
+-- !query schema
+struct<format_string(NULL):string>
+-- !query output
+NULL
+
+
+-- !query
+select format_string('Hello')
+-- !query schema
+struct<format_string(Hello):string>
+-- !query output
+Hello
+
+
+-- !query
+select format_string('Hello %s', 'World')
+-- !query schema
+struct<format_string(Hello %s, World):string>
+-- !query output
+Hello World
+
+
+-- !query
+select format_string('Hello %%')
+-- !query schema
+struct<format_string(Hello %%):string>
+-- !query output
+Hello %
+
+
+-- !query
+select format_string('Hello %%%%')
+-- !query schema
+struct<format_string(Hello %%%%):string>
+-- !query output
+Hello %%
+
+
+-- !query
+select format_string('Hello %s %s', 'World')
+-- !query schema
+struct<>
+-- !query output
+java.util.MissingFormatArgumentException
+Format specifier '%s'
+
+
+-- !query
+select format_string('Hello %s')
+-- !query schema
+struct<>
+-- !query output
+java.util.MissingFormatArgumentException
+Format specifier '%s'
+
+
+-- !query
+select format_string('Hello %x', 20)
+-- !query schema
+struct<format_string(Hello %x, 20):string>
+-- !query output
+Hello 14
+
+
+-- !query
+select format_string('%1$s %3$s', 1, 2, 3)
+-- !query schema
+struct<format_string(%1$s %3$s, 1, 2, 3):string>
+-- !query output
+1 3
+
+
+-- !query
+select format_string('%1$s %12$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
+-- !query schema
+struct<format_string(%1$s %12$s, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12):string>
+-- !query output
+1 12
+
+
+-- !query
+select format_string('%1$s %4$s', 1, 2, 3)
+-- !query schema
+struct<>
+-- !query output
+java.util.MissingFormatArgumentException
+Format specifier '%4$s'
+
+
+-- !query
+select format_string('%1$s %13$s', 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
+-- !query schema
+struct<>
+-- !query output
+java.util.MissingFormatArgumentException
+Format specifier '%13$s'
+
+
+-- !query
+select format_string('%0$s', 'Hello')
+-- !query schema
+struct<>
+-- !query output
+java.util.IllegalFormatArgumentIndexException
+Illegal format argument index = 0
+

Review comment:
       ```
   --PostgreSQL throw ERROR:  format specifies argument 0, but arguments are 
numbered from 1
   select format_string('%0$s', 'Hello');
   ```
   The SQL in `postgreSQL/text.sql` has this different behavior between Java8 
and Java17, but it seems that the behavior of Java 17 is expected, so do 
Independent verification here.
   




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to