Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fe/src/main/java/org/apache/doris/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ public Type castAllToCompatibleType(List<Expr> exprs) throws AnalysisException {
// TODO(zc)
compatibleType = Type.getCmpType(compatibleType, exprs.get(i).getType());
}
if (compatibleType == Type.VARCHAR) {
if (compatibleType.equals(Type.VARCHAR)) {
if (exprs.get(0).getType().isDateType()) {
compatibleType = Type.DATETIME;
}
Expand Down
4 changes: 2 additions & 2 deletions fe/src/main/java/org/apache/doris/analysis/CastExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public static void initBuiltins(FunctionSet functionSet) {
}
// Disable casting from boolean to decimal or datetime or date
if (fromType.isBoolean() &&
(toType == Type.DECIMAL || toType == Type.DECIMALV2 ||
toType == Type.DATETIME || toType == Type.DATE)) {
(toType.equals(Type.DECIMAL) || toType.equals(Type.DECIMALV2) ||
toType.equals(Type.DATETIME) || toType.equals(Type.DATE))) {
continue;
}
// Disable no-op casts
Expand Down
2 changes: 1 addition & 1 deletion fe/src/main/java/org/apache/doris/analysis/ColumnDef.java
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static void validateDefaultValue(Type type, String defaultValue) throws A
break;
case FLOAT:
FloatLiteral floatLiteral = new FloatLiteral(defaultValue);
if (floatLiteral.getType() == Type.DOUBLE) {
if (floatLiteral.getType().equals(Type.DOUBLE)) {
throw new AnalysisException("Default value will loose precision: " + defaultValue);
}
case DOUBLE:
Expand Down
41 changes: 21 additions & 20 deletions fe/src/main/java/org/apache/doris/analysis/DateLiteral.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@

package org.apache.doris.analysis;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.Objects;
import java.util.TimeZone;
import java.util.regex.Pattern;

import org.apache.doris.catalog.Catalog;
import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.Type;
Expand All @@ -35,6 +26,9 @@
import org.apache.doris.thrift.TDateLiteral;
import org.apache.doris.thrift.TExprNode;
import org.apache.doris.thrift.TExprNodeType;

import com.google.common.base.Preconditions;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joda.time.DateTime;
Expand All @@ -43,7 +37,14 @@
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.DateTimeFormatterBuilder;

import com.google.common.base.Preconditions;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Date;
import java.util.Objects;
import java.util.TimeZone;
import java.util.regex.Pattern;

public class DateLiteral extends LiteralExpr {
private static final Logger LOG = LogManager.getLogger(DateLiteral.class);
Expand Down Expand Up @@ -101,7 +102,7 @@ private DateLiteral() {
public DateLiteral(Type type, boolean isMax) throws AnalysisException {
super();
this.type = type;
if (type == Type.DATE) {
if (type.equals(Type.DATE)) {
if (isMax) {
copy(MAX_DATE);
} else {
Expand Down Expand Up @@ -131,7 +132,7 @@ public DateLiteral(long unixTimestamp, TimeZone timeZone, Type type) {
hour = dt.getHourOfDay();
minute = dt.getMinuteOfHour();
second = dt.getSecondOfMinute();
if (type == Type.DATE) {
if (type.equals(Type.DATE)) {
hour = 0;
minute = 0;
second = 0;
Expand Down Expand Up @@ -191,7 +192,7 @@ private void init(String s, Type type) throws AnalysisException {
try {
Preconditions.checkArgument(type.isDateType());
LocalDateTime dateTime;
if (type == Type.DATE) {
if (type.equals(Type.DATE)) {
if (s.split("-")[0].length() == 2) {
dateTime = DATE_FORMATTER_TWO_DIGIT.parseLocalDateTime(s);
} else {
Expand Down Expand Up @@ -247,9 +248,9 @@ public boolean isMinValue() {

@Override
public Object getRealValue() {
if (type == Type.DATE) {
if (type.equals(Type.DATE)) {
return year * 16 * 32L + month * 32 + day;
} else if (type == Type.DATETIME) {
} else if (type.equals(Type.DATETIME)) {
return (year * 10000 + month * 100 + day) * 1000000L + hour * 10000 + minute * 100 + second;
} else {
Preconditions.checkState(false, "invalid date type: " + type);
Expand Down Expand Up @@ -355,9 +356,9 @@ private long makePackedDatetime() {
public void write(DataOutput out) throws IOException {
super.write(out);
//set flag bit in meta, 0 is DATETIME and 1 is DATE
if (this.type == Type.DATETIME) {
if (this.type.equals(Type.DATETIME)) {
out.writeShort(DateLiteralType.DATETIME.value());
} else if (this.type == Type.DATE) {
} else if (this.type.equals(Type.DATE)) {
out.writeShort(DateLiteralType.DATE.value());
} else {
throw new IOException("Error date literal type : " + type);
Expand Down Expand Up @@ -439,7 +440,7 @@ public static DateLiteral dateParser(String date, String pattern) throws Analysi
//Return the date stored in the dateliteral as pattern format.
//eg : "%Y-%m-%d" or "%Y-%m-%d %H:%i:%s"
public String dateFormat(String pattern) throws AnalysisException {
if (type == Type.DATE) {
if (type.equals(Type.DATE)) {
return DATE_FORMATTER.parseLocalDateTime(getStringValue())
.toString(formatBuilder(pattern).toFormatter());
} else {
Expand Down Expand Up @@ -559,9 +560,9 @@ private static DateTimeFormatterBuilder formatBuilder(String pattern) throws Ana
}

public LocalDateTime getTimeFormatter() throws AnalysisException {
if (type == Type.DATE) {
if (type.equals(Type.DATE)) {
return DATE_FORMATTER.parseLocalDateTime(getStringValue());
} else if (type == Type.DATETIME) {
} else if (type.equals(Type.DATETIME)) {
return DATE_TIME_FORMATTER.parseLocalDateTime(getStringValue());
} else {
throw new AnalysisException("Not support date literal type");
Expand Down
2 changes: 1 addition & 1 deletion fe/src/main/java/org/apache/doris/analysis/Expr.java
Original file line number Diff line number Diff line change
Expand Up @@ -1441,7 +1441,7 @@ public static Expr pushNegationToOperands(Expr root) {
* Negates a boolean Expr.
*/
public Expr negate() {
Preconditions.checkState(type == Type.BOOLEAN);
Preconditions.checkState(type.equals(Type.BOOLEAN));
return new CompoundPredicate(CompoundPredicate.Operator.NOT, this, null);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void vectorizedAnalyze(Analyzer analyzer) {
// OpcodeRegistry.BuiltinFunction match = OpcodeRegistry.instance().getFunctionInfo(
// FunctionOperator.FILTER_IN, true, true, type);
// Preconditions.checkState(match != null);
// Preconditions.checkState(match.getReturnType() == Type.BOOLEAN);
// Preconditions.checkState(match.getReturnType().equals(Type.BOOLEAN));
// this.vectorOpcode = match.opcode;
// LOG.info(debugString() + " opcode: " + vectorOpcode);
}
Expand Down
21 changes: 11 additions & 10 deletions fe/src/main/java/org/apache/doris/analysis/LargeIntLiteral.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,6 @@

package org.apache.doris.analysis;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Objects;

import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.Type;
import org.apache.doris.common.AnalysisException;
Expand All @@ -34,9 +25,19 @@
import org.apache.doris.thrift.TExprNode;
import org.apache.doris.thrift.TExprNodeType;
import org.apache.doris.thrift.TLargeIntLiteral;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Objects;

// large int for the num that native types can not
public class LargeIntLiteral extends LiteralExpr {
private final static Logger LOG = LogManager.getLogger(LargeIntLiteral.class);
Expand Down Expand Up @@ -149,7 +150,7 @@ public int compareLiteral(LiteralExpr expr) {
if (expr == MaxLiteral.MAX_VALUE) {
return -1;
}
if (expr.type == Type.LARGEINT) {
if (expr.type.equals(Type.LARGEINT)) {
return value.compareTo(((LargeIntLiteral) expr).value);
} else {
BigInteger intValue = new BigInteger(((IntLiteral) expr).getStringValue());
Expand Down
6 changes: 3 additions & 3 deletions fe/src/main/java/org/apache/doris/analysis/SlotRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public SlotRef(SlotDescriptor desc) {
this.type = desc.getType();
// TODO(zc): label is meaningful
this.label = null;
if (this.type == Type.CHAR) {
if (this.type.equals(Type.CHAR)) {
this.type = Type.VARCHAR;
}
analysisDone();
Expand Down Expand Up @@ -124,15 +124,15 @@ public void computeOutputColumn(Analyzer analyzer) {
public void analyzeImpl(Analyzer analyzer) throws AnalysisException {
desc = analyzer.registerColumnRef(tblName, col);
type = desc.getType();
if (this.type == Type.CHAR) {
if (this.type.equals(Type.CHAR)) {
this.type = Type.VARCHAR;
}
if (!type.isSupported()) {
throw new AnalysisException(
"Unsupported type '" + type.toString() + "' in '" + toSql() + "'.");
}
numDistinctValues = desc.getStats().getNumDistinctValues();
if (type == Type.BOOLEAN) {
if (type.equals(Type.BOOLEAN)) {
selectivity = DEFAULT_SELECTIVITY;
}
}
Expand Down
30 changes: 15 additions & 15 deletions fe/src/main/java/org/apache/doris/catalog/FunctionSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ private void initAggregateBuiltins() {
null, false, true, true));

// count in multi distinct
if (t == Type.CHAR || t == Type.VARCHAR) {
if (t.equals(Type.CHAR) || t.equals(Type.VARCHAR)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_count", Lists.newArrayList(t),
Type.BIGINT,
Type.VARCHAR,
Expand All @@ -872,8 +872,8 @@ private void initAggregateBuiltins() {
null,
prefix + "30count_distinct_string_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
false, true, true));
} else if (t == Type.TINYINT || t == Type.SMALLINT || t == Type.INT
|| t == Type.BIGINT || t == Type.LARGEINT || t == Type.DOUBLE) {
} else if (t.equals(Type.TINYINT) || t.equals(Type.SMALLINT) || t.equals(Type.INT)
|| t.equals(Type.BIGINT) || t.equals(Type.LARGEINT) || t.equals(Type.DOUBLE)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_count", Lists.newArrayList(t),
Type.BIGINT,
Type.VARCHAR,
Expand All @@ -885,7 +885,7 @@ private void initAggregateBuiltins() {
null,
prefix + MULTI_DISTINCT_COUNT_FINALIZE_SYMBOL.get(t),
false, true, true));
} else if (t == Type.DATE || t == Type.DATETIME) {
} else if (t.equals(Type.DATE) || t.equals(Type.DATETIME)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_count", Lists.newArrayList(t),
Type.BIGINT,
Type.VARCHAR,
Expand All @@ -897,7 +897,7 @@ private void initAggregateBuiltins() {
null,
prefix + "28count_distinct_date_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
false, true, true));
} else if (t == Type.DECIMAL) {
} else if (t.equals(Type.DECIMAL)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_count", Lists.newArrayList(t),
Type.BIGINT,
Type.VARCHAR,
Expand All @@ -909,7 +909,7 @@ private void initAggregateBuiltins() {
null,
prefix + "31count_distinct_decimal_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
false, true, true));
} else if (t == Type.DECIMALV2) {
} else if (t.equals(Type.DECIMALV2)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_count", Lists.newArrayList(t),
Type.BIGINT,
Type.VARCHAR,
Expand All @@ -924,7 +924,7 @@ private void initAggregateBuiltins() {
}

// sum in multi distinct
if (t == Type.BIGINT || t == Type.LARGEINT || t == Type.DOUBLE) {
if (t.equals(Type.BIGINT) || t.equals(Type.LARGEINT) || t.equals(Type.DOUBLE)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_sum", Lists.newArrayList(t),
t,
Type.VARCHAR,
Expand All @@ -936,7 +936,7 @@ private void initAggregateBuiltins() {
null,
prefix + MULTI_DISTINCT_SUM_FINALIZE_SYMBOL.get(t),
false, true, true));
} else if (t == Type.DECIMAL) {
} else if (t.equals(Type.DECIMAL)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_sum", Lists.newArrayList(t),
MULTI_DISTINCT_SUM_RETURN_TYPE.get(t),
Type.VARCHAR,
Expand All @@ -948,7 +948,7 @@ private void initAggregateBuiltins() {
null,
prefix + "29sum_distinct_decimal_finalizeEPN9doris_udf15FunctionContextERKNS1_9StringValE",
false, true, true));
} else if (t == Type.DECIMALV2) {
} else if (t.equals(Type.DECIMALV2)) {
addBuiltin(AggregateFunction.createBuiltin("multi_distinct_sum", Lists.newArrayList(t),
MULTI_DISTINCT_SUM_RETURN_TYPE.get(t),
Type.VARCHAR,
Expand Down Expand Up @@ -1302,25 +1302,25 @@ private void initAggregateBuiltins() {
t.isStringType() ? initNullString : initNull,
prefix + FIRST_VALUE_UPDATE_SYMBOL.get(t),
null,
t == Type.VARCHAR ? stringValGetValue : null,
t == Type.VARCHAR ? stringValSerializeOrFinalize : null));
t.equals(Type.VARCHAR) ? stringValGetValue : null,
t.equals(Type.VARCHAR) ? stringValSerializeOrFinalize : null));
// Implements FIRST_VALUE for some windows that require rewrites during planning.
addBuiltin(AggregateFunction.createAnalyticBuiltin(
"first_value_rewrite", Lists.newArrayList(t, Type.BIGINT), t, t,
t.isStringType() ? initNullString : initNull,
prefix + FIRST_VALUE_REWRITE_UPDATE_SYMBOL.get(t),
null,
t == Type.VARCHAR ? stringValGetValue : null,
t == Type.VARCHAR ? stringValSerializeOrFinalize : null,
t.equals(Type.VARCHAR) ? stringValGetValue : null,
t.equals(Type.VARCHAR) ? stringValSerializeOrFinalize : null,
false));

addBuiltin(AggregateFunction.createAnalyticBuiltin(
"last_value", Lists.newArrayList(t), t, t,
t.isStringType() ? initNullString : initNull,
prefix + LAST_VALUE_UPDATE_SYMBOL.get(t),
prefix + LAST_VALUE_REMOVE_SYMBOL.get(t),
t == Type.VARCHAR ? stringValGetValue : null,
t == Type.VARCHAR ? stringValSerializeOrFinalize : null));
t.equals(Type.VARCHAR) ? stringValGetValue : null,
t.equals(Type.VARCHAR) ? stringValSerializeOrFinalize : null));

addBuiltin(AggregateFunction.createAnalyticBuiltin(
"lag", Lists.newArrayList(t, Type.BIGINT, t), t, t,
Expand Down
2 changes: 1 addition & 1 deletion fe/src/main/java/org/apache/doris/mysql/MysqlChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public MysqlChannel(SocketChannel channel) {
remoteIp = channel.getRemoteAddress().toString();
}
} catch (Exception e) {
LOG.warn("get remote host string failed: " + e.toString());
LOG.warn("get remote host string failed: ", e);
}
}
}
Expand Down
Loading