You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "zhishun luan (Jira)" <ji...@apache.org> on 2021/03/09 01:28:00 UTC

[jira] [Updated] (SPARK-34669) Spark SQL uses the function[ length()] to return the length of the string rather than the length of the character

     [ https://issues.apache.org/jira/browse/SPARK-34669?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

zhishun luan updated SPARK-34669:
---------------------------------
    Description: 
Such as the title.

For the function length (). MySQL and other relational databases, we get the byte length, but spark SQL gets the string length. For these two cases, please provide a new function to get the byte length, otherwise it is easy to mislead users

----------------------------------------------------------------------------------------
{code:java}
// code placeholder
SparkConf conf = new SparkConf();
conf.setMaster("local");
SparkSession session = SparkSession.builder().config(conf).getOrCreate();
session.sql("select length('测a')").show();

{code}
 

[result]

+-----------+
|length(测a)|

+-----------+
|2|

+-----------+

in mysql 

+-----------+
|length(测a)|

+-----------+
|4|

+-----------+

 

 

  was:
Such as the title.

For the function length (). MySQL and other relational databases, we get the byte length, but spark SQL gets the string length. For these two cases, please provide a new function to get the byte length, otherwise it is easy to mislead users

----------------------------------------------------------------------------------------
{code:java}
// code placeholder
SparkConf conf = new SparkConf();
conf.setMaster("local");
SparkSession session = SparkSession.builder().config(conf).getOrCreate();
session.sql("select length('我a')").show();

{code}
 

[result]

+-----------+
|length(测a)|
+-----------+
| 2|
+-----------+

in mysql 

+-----------+
|length(测a)|
+-----------+
| 4|
+-----------+

 

 


> Spark SQL uses the function[ length()] to return the length of the string rather than the length of the character
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-34669
>                 URL: https://issues.apache.org/jira/browse/SPARK-34669
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 3.1.1
>         Environment: spark 3.1.1,scala 2.12
>            Reporter: zhishun luan
>            Priority: Major
>
> Such as the title.
> For the function length (). MySQL and other relational databases, we get the byte length, but spark SQL gets the string length. For these two cases, please provide a new function to get the byte length, otherwise it is easy to mislead users
> ----------------------------------------------------------------------------------------
> {code:java}
> // code placeholder
> SparkConf conf = new SparkConf();
> conf.setMaster("local");
> SparkSession session = SparkSession.builder().config(conf).getOrCreate();
> session.sql("select length('测a')").show();
> {code}
>  
> [result]
> +-----------+
> |length(测a)|
> +-----------+
> |2|
> +-----------+
> in mysql 
> +-----------+
> |length(测a)|
> +-----------+
> |4|
> +-----------+
>  
>  



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

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