-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28038][SQL][TEST] Port text.sql #24862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Test build #106464 has finished for PR 24862 at commit
|
|
Test build #107897 has finished for PR 24862 at commit
|
|
Test build #107899 has finished for PR 24862 at commit
|
|
Retest this please. |
| -- 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: If we strictly follow ANSI/SQL, we don't allow this implicit cast along with PostgresSQL.
cc: @gengliangwang
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this casting an integer to string? If yes, I think it is allowed in ANSI SQL and up-cast.
| -- 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: duplicate test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update it to select 'four: ' || 2+2;?
| 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you comment out this? (I just want to check current output...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of ANSI mode:
spark-sql> select left('12345', 2);
12
spark-sql> set spark.sql.parser.ansi.enabled=true;
spark.sql.parser.ansi.enabled true
spark-sql> select left('12345', 2);
Error in query:
no viable alternative at input 'left'(line 1, pos 7)
== SQL ==
select left('12345', 2)
-------^^^https://issues.apache.org/jira/browse/SPARK-28479
The output if disable ANSI mode:
Spark SQL:
spark-sql> select i, left('ahoj', i), right('ahoj', i) from range(-5, 6) t(i) order by i;
-5
-4
-3
-2
-1
0
1 a j
2 ah oj
3 aho hoj
4 ahoj ahoj
5 ahoj ahojPostgreSQL:
postgres=# select i, left('ahoj', i), right('ahoj', i) from generate_series(-5, 5) t(i) order by i;
i | left | right
----+------+-------
-5 | |
-4 | |
-3 | a | j
-2 | ah | oj
-1 | aho | hoj
0 | |
1 | a | j
2 | ah | oj
3 | aho | hoj
4 | ahoj | ahoj
5 | ahoj | ahoj
(11 rows)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see. Can you turn temporarily off the mode for the query here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
Test build #108355 has finished for PR 24862 at commit
|
|
Test build #108382 has finished for PR 24862 at commit
|
|
Merged to master. |
What changes were proposed in this pull request?
This PR is to port text.sql from PostgreSQL regression tests. https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/sql/text.sql
The expected results can be found in the link: https://github.com/postgres/postgres/blob/REL_12_BETA2/src/test/regress/expected/text.out
When porting the test cases, found a PostgreSQL specific features that do not exist in Spark SQL:
SPARK-28037: Add built-in String Functions: quote_literal
Also, found three inconsistent behavior:
SPARK-27930: Spark SQL's format_string can not fully support PostgreSQL's format
SPARK-28036: Built-in udf left/right has inconsistent behavior
SPARK-28033: String concatenation should low priority than other operators
How was this patch tested?
N/A