Jackie-Jiang commented on code in PR #11763: URL: https://github.com/apache/pinot/pull/11763#discussion_r1358913092
########## pinot-common/src/main/java/org/apache/pinot/common/request/context/LiteralContext.java: ########## @@ -18,179 +18,231 @@ */ package org.apache.pinot.common.request.context; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Preconditions; import java.math.BigDecimal; -import java.math.BigInteger; import java.sql.Timestamp; import java.util.Objects; import javax.annotation.Nullable; -import org.apache.commons.lang3.math.NumberUtils; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; import org.apache.pinot.common.request.Literal; import org.apache.pinot.common.utils.PinotDataType; -import org.apache.pinot.spi.data.FieldSpec; +import org.apache.pinot.spi.data.FieldSpec.DataType; import org.apache.pinot.spi.utils.BigDecimalUtils; +import org.apache.pinot.spi.utils.CommonConstants.NullValuePlaceHolder; /** * The {@code LiteralContext} class represents a literal in the query. * <p>This includes both value and type information. We translate thrift literal to this representation in server. - * Currently, only Boolean literal is correctly encoded in thrift and passed in. - * All integers are encoded as LONG in thrift, and the other numerical types are encoded as DOUBLE. - * The remaining types are encoded as STRING. */ public class LiteralContext { // TODO: Support all of the types for sql. - private final FieldSpec.DataType _type; + private final DataType _type; private final Object _value; - private final BigDecimal _bigDecimalValue; - private static BigDecimal getBigDecimalValue(FieldSpec.DataType type, Object value) { - switch (type) { - case BIG_DECIMAL: - return (BigDecimal) value; - case BOOLEAN: - return PinotDataType.BOOLEAN.toBigDecimal(value); - case TIMESTAMP: - return PinotDataType.TIMESTAMP.toBigDecimal(Timestamp.valueOf(value.toString())); - default: - if (type.isNumeric()) { - return new BigDecimal(value.toString()); - } - return BigDecimal.ZERO; - } - } + /** + * A transient field used for the type conversion, and is not included in {@link #equals} and {@link #hashCode}. + */ + private final transient PinotDataType _pinotDataType; Review Comment: `transient` is not `volatile`, but seems this is causing more confusion, so removed the `transient` -- 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...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org