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

Yuming Wang commented on SPARK-21010:
-------------------------------------

The problem is that you define {{char(20)}}, {{legnth('413022199908088888')}} 
is 18, auto append 2 space, you can try {{varchar}}.

> Spark-Sql Can't  Handle char() type Well
> ----------------------------------------
>
>                 Key: SPARK-21010
>                 URL: https://issues.apache.org/jira/browse/SPARK-21010
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.6.1, 2.1.0, 2.1.1
>         Environment: spark1.6.1 hadoop-2.6.0-cdh5.4.2
>            Reporter: fengchaoge
>             Fix For: 2.1.1
>
>
> we create table in spark-sql like this :
> 1. create table cid_test (name string,id char(20)) ROW FORMAT DELIMITED 
> FIELDS TERMINATED BY ' ' stored as textfile;
> 2. LOAD DATA LOCAL INPATH '/home/hadoop/id.txt' OVERWRITE INTO TABLE  
> cid_test;
> content for id.txt:
> fengchaoge 413022199908088888
> 3. select * from cid_test where id='413022199908088888'; 
> 4. select * from cid_test where id='413022199908088888  ';
> In third step,we got nothing ,but in four step we got the right ring. we must 
> add two spaces in id if we want  the right value.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

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

Reply via email to