Skip to content

Commit

Permalink
fix varchar(0) correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
seawinde committed Nov 24, 2023
1 parent c5f58dd commit d17ec3a
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1060,6 +1060,11 @@ public static ScalarType getAssignmentCompatibleType(
if (t1.type == PrimitiveType.STRING || t2.type == PrimitiveType.STRING) {
return createStringType();
}
int minLength = Math.min(t1.len, t2.len);
if (minLength < 0) {
// If < 0 which means max length, use firstly
return createVarcharType(minLength);
}
int length = Math.max(t1.len, t2.len);
return createVarcharType(length == 0 ? MAX_VARCHAR_LENGTH : length);
}
Expand Down

0 comments on commit d17ec3a

Please sign in to comment.