danny0405 commented on a change in pull request #2124:
URL: https://github.com/apache/calcite/pull/2124#discussion_r480745235
##########
File path: core/src/main/java/org/apache/calcite/rex/RexBuilder.java
##########
@@ -1383,7 +1521,15 @@ public RexNode makeLiteral(Object value, RelDataType
type,
final SqlTypeName sqlTypeName = type.getSqlTypeName();
switch (sqlTypeName) {
case CHAR:
- return makeCharLiteral(padRight((NlsString) value, type.getPrecision()));
+ int precision = type.getPrecision();
+ NlsString nlsString = (NlsString) value;
+ if (trim) {
+ nlsString = nlsString.rtrim();
+ precision = nlsString.getValue().length();
+ } else {
+ nlsString = padRight(nlsString, precision);
+ }
+ return makeCharLiteral(padRight(nlsString, precision));
case VARCHAR:
Review comment:
If no `trim`, the `padRight` is invoked 2 times.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]