Zkplo commented on code in PR #10970:
URL: https://github.com/apache/inlong/pull/10970#discussion_r1740276250


##########
inlong-sdk/transform-sdk/src/main/java/org/apache/inlong/sdk/transform/process/parser/SignParser.java:
##########
@@ -21,29 +21,40 @@
 import org.apache.inlong.sdk.transform.process.Context;
 import org.apache.inlong.sdk.transform.process.operator.OperatorTools;
 
+import lombok.extern.slf4j.Slf4j;
 import net.sf.jsqlparser.expression.SignedExpression;
 
 import java.math.BigDecimal;
 
 /**
  * SignParser
- * 
  */
+@Slf4j
 @TransformParser(values = SignedExpression.class)
 public class SignParser implements ValueParser {
 
-    private final Integer sign;
+    private final char sign;
     private final ValueParser number;
 
     public SignParser(SignedExpression expr) {
-        sign = expr.getSign() == '-' ? -1 : 1;
+        sign = expr.getSign();
         number = OperatorTools.buildParser(expr.getExpression());
     }
 
     @Override
     public Object parse(SourceData sourceData, int rowIndex, Context context) {
-        Object numberObject = number.parse(sourceData, rowIndex, context);
-        BigDecimal numberValue = OperatorTools.parseBigDecimal(numberObject);
-        return numberValue.multiply(new BigDecimal(sign));
+        try {
+            Object numberObject = number.parse(sourceData, rowIndex, context);
+            BigDecimal numberValue = 
OperatorTools.parseBigDecimal(numberObject);
+            switch (sign) {
+                case '-':
+                    return numberValue.multiply(new BigDecimal(-1));
+                case '~':
+                    return 
Long.toUnsignedString(numberValue.toBigInteger().not().longValue());

Review Comment:
   According to the official documentation of MySQL: 
https://dev.mysql.com/doc/refman/8.4/en/bit-functions.html . Bit operations are 
defined on 64 bit unsigned integers, so "~-4" is equal to "3", but "~4" is no 
longer equal to "3" , but is equal to "1844674407909551612" .



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@inlong.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to