morrySnow commented on code in PR #64026:
URL: https://github.com/apache/doris/pull/64026#discussion_r3395404355
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExprUtils.java:
##########
@@ -85,6 +97,39 @@ public static LiteralExpr createLiteral(String value, Type
type) throws Analysis
return literalExpr;
}
+ private static LiteralExpr createFloatingPointLiteral(String value, Type
type) throws AnalysisException {
+ try {
+ return new FloatLiteral(Double.parseDouble(value), type);
+ } catch (NumberFormatException e) {
+ throw new AnalysisException("Invalid floating-point literal: " +
value, e);
+ }
+ }
+
+ private static LiteralExpr createDecimalLiteral(String value, Type type)
throws AnalysisException {
+ Preconditions.checkArgument(type instanceof ScalarType);
Review Comment:
error message
##########
fe/fe-catalog/src/main/java/org/apache/doris/analysis/ArrayLiteral.java:
##########
@@ -52,6 +52,18 @@ public boolean isMinValue() {
@Override
public int compareLiteral(LiteralExpr expr) {
Review Comment:
也许可以改个代码测试一下,什么时候compare literal 传入的 expr 的类型和 this 不一致。
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExprUtils.java:
##########
@@ -85,6 +97,39 @@ public static LiteralExpr createLiteral(String value, Type
type) throws Analysis
return literalExpr;
}
+ private static LiteralExpr createFloatingPointLiteral(String value, Type
type) throws AnalysisException {
+ try {
+ return new FloatLiteral(Double.parseDouble(value), type);
+ } catch (NumberFormatException e) {
+ throw new AnalysisException("Invalid floating-point literal: " +
value, e);
+ }
+ }
+
+ private static LiteralExpr createDecimalLiteral(String value, Type type)
throws AnalysisException {
+ Preconditions.checkArgument(type instanceof ScalarType);
+ ScalarType scalarType = (ScalarType) type;
+ BigDecimal decimalValue;
+ try {
+ decimalValue = new BigDecimal(value);
+ } catch (NumberFormatException e) {
+ throw new AnalysisException("Invalid floating-point literal: " +
value, e);
+ }
+ decimalValue = decimalValue.setScale(scalarType.getScalarScale(),
RoundingMode.HALF_UP);
+ DecimalLiteral literalExpr = new DecimalLiteral(decimalValue, type);
+ literalExpr.checkPrecisionAndScale(scalarType.getScalarPrecision(),
scalarType.getScalarScale());
+ return literalExpr;
+ }
+
+ private static LiteralExpr createTimestampTzLiteral(String value, Type
type) throws AnalysisException {
+ Preconditions.checkArgument(type instanceof ScalarType &&
type.isTimeStampTz());
Review Comment:
error message
##########
fe/fe-core/src/main/java/org/apache/doris/analysis/LiteralExprUtils.java:
##########
@@ -114,4 +159,24 @@ public static PlaceHolderExpr createPlaceHolderExpr(String
value, Type type) thr
Preconditions.checkArgument(!type.equals(Type.INVALID));
return new PlaceHolderExpr(LiteralExprUtils.createLiteral(value,
type));
}
+
+ public static String normalizePartitionValueString(String value, Type
type) throws AnalysisException {
Review Comment:
和partition相关的函数不应该放在这个文件里面
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]