Skip to content
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

Fix Bit Type default value bug #1148

Merged

Conversation

marsishandsome
Copy link
Collaborator

@marsishandsome marsishandsome commented Oct 15, 2019

What problem does this PR solve?

close #1147

see pingcap/tidb#12168

CREATE TABLE t_origin_default_value_1 (id bigint(20) NOT NULL, approved bit(8) NOT NULL DEFAULT b'11111111');
insert into t_origin_default_value_1(id) values (1), (2), (3);

CREATE TABLE t_origin_default_value_2 (id bigint(20) NOT NULL);
insert into t_origin_default_value_2(id) values (1), (2), (3);
alter table t_origin_default_value_2 add approved bit(8) NOT NULL DEFAULT b'11111111';
spark-sql> select * from t_origin_default_value_1;
1       255
2       255
3       255
Time taken: 0.144 seconds, Fetched 3 row(s)
spark-sql> select * from t_origin_default_value_2;                                                                      
19/10/15 10:49:14 ERROR SparkSQLDriver: Failed in [select * from t_origin_default_value_2]                              
java.lang.NumberFormatException: For input string: "�"                                                                  
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)                                
        at java.lang.Long.parseLong(Long.java:589)                                                                      
        at java.lang.Long.parseLong(Long.java:631)                                                                      
        at com.pingcap.tikv.types.IntegerType.getOriginDefaultValueNonNull(IntegerType.java:157)                        
        at com.pingcap.tikv.types.DataType.getOriginDefaultValue(DataType.java:327)                                     
        at com.pingcap.tikv.meta.TiColumnInfo.getOriginDefaultValueAsByteString(TiColumnInfo.java:192)                  
        at com.pingcap.tikv.meta.TiColumnInfo.toProtoBuilder(TiColumnInfo.java:315)                                     
        at com.pingcap.tikv.meta.TiColumnInfo.toProto(TiColumnInfo.java:304)                                            
        at com.pingcap.tikv.meta.TiDAGRequest.buildScan(TiDAGRequest.java:427)                                          
        at com.pingcap.tikv.meta.TiDAGRequest.buildTableScan(TiDAGRequest.java:276)                                     
        at com.pingcap.tikv.meta.TiDAGRequest.init(TiDAGRequest.java:969)                                               
        at com.pingcap.tikv.meta.TiDAGRequest.init(TiDAGRequest.java:974)                                               
        at com.pingcap.tikv.meta.TiDAGRequest.toString(TiDAGRequest.java:997)                                           
        at java.lang.String.valueOf(String.java:2994)      
        at java.lang.StringBuilder.append(StringBuilder.java:131) 

What is changed and how it works?

use defaultValueBit instead of originDefaultValue for Bit Type

Check List

Tests

  • Unit test

Related changes

  • Need to cherry-pick to the release branch
  • Need to be included in the release note

@marsishandsome
Copy link
Collaborator Author

/run-all-tests

@marsishandsome
Copy link
Collaborator Author

/run-all-tests tikv=v3.0.4 tidb=v3.0.4 pd=v3.0.4

@marsishandsome
Copy link
Collaborator Author

/run-all-tests tikv=v2.1.17 tidb=v2.1.17 pd=v2.1.17

Copy link
Contributor

@birdstorm birdstorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after resolving comments

@marsishandsome
Copy link
Collaborator Author

/run-all-tests tikv=v2.1.17 tidb=v2.1.17 pd=v2.1.17

@marsishandsome
Copy link
Collaborator Author

/run-all-tests tikv=v2.1.17 tidb=v2.1.17 pd=v2.1.17

@marsishandsome marsishandsome merged commit 3c6cae2 into pingcap:master Oct 15, 2019
marsishandsome added a commit to marsishandsome/tispark that referenced this pull request Oct 15, 2019
marsishandsome added a commit to marsishandsome/tispark that referenced this pull request Oct 15, 2019
wfxxh pushed a commit to wanfangdata/tispark that referenced this pull request Jun 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] tispark's getColDefaultValue logic for BitType is different with TiDB's
3 participants