[ 
https://issues.apache.org/jira/browse/SPARK-34179?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17273348#comment-17273348
 ] 

Attila Zsolt Piros edited comment on SPARK-34179 at 1/28/21, 6:09 AM:
----------------------------------------------------------------------

[~chetdb] The "https://spark.apache.org/docs/latest/api/sql/index.html"; is a 
link to the "latest" version which is NOT 2.4.5 but 3.0.1.

You should check the functions in 
https://spark.apache.org/docs/2.4.5/api/sql/index.html in case of 2.4.5 where 
there is no overlay functions at all.

Regarding the array_sort the only problem is in the text: "Since: 2.4.0", which 
was valid for the old example: """SELECT array_sort(array('b', 'd', null, 'c', 
'a'));""". If something needs to be corrected it might be this text as it is a 
little bit misleading even as it is true (the function itself was introduced in 
2.4.0). 




was (Author: attilapiros):
[~chetdb] The "https://spark.apache.org/docs/latest/api/sql/index.html"; is a 
link to the "latest" version which is NOT 2.4.5 but 3.0.1.

You should check the functions in 
https://spark.apache.org/docs/2.4.5/api/sql/index.html in case of 2.4.5. where 
there is no overlay functions at all.

Regarding the array_sort the only problem is in the text: "Since: 2.4.0", which 
was valid for the old example: """SELECT array_sort(array('b', 'd', null, 'c', 
'a'));""". If something needs to be corrected it might be this text as it is a 
little bit misleading even as it is true (the function itself was introduced in 
2.4.0). 



> examples provided in https://spark.apache.org/docs/latest/api/sql/index.html  
>  link not working
> -----------------------------------------------------------------------------------------------
>
>                 Key: SPARK-34179
>                 URL: https://issues.apache.org/jira/browse/SPARK-34179
>             Project: Spark
>          Issue Type: Bug
>          Components: docs
>    Affects Versions: 2.4.5
>         Environment: Spark 2.4.5
>            Reporter: Chetan Bhat
>            Priority: Minor
>
> *Issue 1 :*
> *array_sort examples provided in 
> [https://spark.apache.org/docs/latest/api/sql/index.html#array_sort] link not 
> working.*
>  
> SELECT array_sort(array(5, 6, 1), (left, right) -> case when left < right 
> then -1 when left > right then 1 else 0 end); –> *this example when executed 
> in spark-sql fails with below error*
> SELECT array_sort(array(5, 6, 1), (left, right) -> case when left < right 
> then -1 when left > right then 1 else 0 end);
>  Error in query:
>  extraneous input '->' expecting \{')', ','}(line 1, pos 48)
> == SQL ==
>  SELECT array_sort(array(5, 6, 1), (left, right) -> case when left < right 
> then -1 when left > right then 1 else 0 end)
>  ------------------------------------------------^^^
> spark-sql>
>  
> SELECT array_sort(array('bc', 'ab', 'dc'), (left, right) -> case when left is 
> null and right is null then 0 when left is null then -1 when right is null 
> then 1 when left < right then 1 when left > right then -1 else 0 end);  --> 
> *This example when executed fails with below error*
>  
> spark-sql>
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  > SELECT array_sort(array('bc', 'ab', 'dc'), (left, right) -> case when left 
> is null and right is null then 0 when left is null then -1 when right is null 
> then 1 when left < right then 1 when left > right then -1 else 0 end);
>  Error in query:
>  extraneous input '->' expecting \{')', ','}(line 1, pos 57)
> == SQL ==
>  SELECT array_sort(array('bc', 'ab', 'dc'), (left, right) -> case when left 
> is null and right is null then 0 when left is null then -1 when right is null 
> then 1 when left < right then 1 when left > right then -1 else 0 end)
>  ---------------------------------------------------------^^^
> spark-sql>
>  
> *Issue 2 :-*
> *Examples for overlay functions are not working in link - 
> https://spark.apache.org/docs/latest/api/sql/index.html*
>  
> spark-sql> SELECT overlay('Spark SQL' PLACING '_' FROM 6);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 27)
> == SQL ==
> SELECT overlay('Spark SQL' PLACING '_' FROM 6)
> ---------------------------^^^
> spark-sql> SELECT overlay('Spark SQL' PLACING 'CORE' FROM 7);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 27)
> == SQL ==
> SELECT overlay('Spark SQL' PLACING 'CORE' FROM 7)
> ---------------------------^^^
> spark-sql> SELECT overlay('Spark SQL' PLACING 'ANSI ' FROM 7 FOR 0);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 27)
> == SQL ==
> SELECT overlay('Spark SQL' PLACING 'ANSI ' FROM 7 FOR 0)
> ---------------------------^^^
> spark-sql> SELECT overlay('Spark SQL' PLACING 'tructured' FROM 2 FOR 4);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 27)
> == SQL ==
> SELECT overlay('Spark SQL' PLACING 'tructured' FROM 2 FOR 4)
> ---------------------------^^^
> spark-sql> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING encode('_', 
> 'utf-8') FROM 6);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 44)
> == SQL ==
> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING encode('_', 'utf-8') FROM 
> 6)
> --------------------------------------------^^^
> spark-sql> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING encode('CORE', 
> 'utf-8') FROM 7);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 44)
> == SQL ==
> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING encode('CORE', 'utf-8') 
> FROM 7)
> --------------------------------------------^^^
> spark-sql> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING encode('ANSI 
> ', 'utf-8') FROM 7 FOR 0);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 44)
> == SQL ==
> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING encode('ANSI ', 'utf-8') 
> FROM 7 FOR 0)
> --------------------------------------------^^^
> spark-sql> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING 
> encode('tructured', 'utf-8') FROM 2 FOR 4);
> Error in query:
> mismatched input 'PLACING' expecting \{')', ','}(line 1, pos 44)
> == SQL ==
> SELECT overlay(encode('Spark SQL', 'utf-8') PLACING encode('tructured', 
> 'utf-8') FROM 2 FOR 4)
> --------------------------------------------^^^



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

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

Reply via email to