use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class ItemFuncIf method valStr.
@Override
public String valStr() {
if (fieldType() == FieldTypes.MYSQL_TYPE_DATETIME || fieldType() == FieldTypes.MYSQL_TYPE_TIMESTAMP) {
return valStringFromDatetime();
} else if (fieldType() == FieldTypes.MYSQL_TYPE_DATE) {
return valStringFromDate();
} else if (fieldType() == FieldTypes.MYSQL_TYPE_TIME) {
return valStringFromTime();
} else {
Item item = args.get(0).valBool() ? args.get(1) : args.get(2);
String res;
if ((res = item.valStr()) != null) {
nullValue = false;
return res;
}
}
nullValue = true;
return null;
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class ItemFuncIf method valDecimal.
@Override
public BigDecimal valDecimal() {
Item arg = args.get(0).valBool() ? args.get(1) : args.get(2);
BigDecimal value = arg.valDecimal();
nullValue = arg.isNullValue();
return value;
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class ItemFuncGroupConcat method add.
@Override
public boolean add(RowDataPacket row, Object tranObject) {
if (alwaysNull)
return false;
StringBuilder rowStr = new StringBuilder();
for (int i = 0; i < getArgCount(); i++) {
Item item = args.get(i);
String s = item.valStr();
if (item.isNull())
return false;
rowStr.append(s);
}
nullValue = false;
if (resultSb.length() > 0)
resultSb.append(seperator);
resultSb.append(rowStr);
return false;
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class ItemSum method fixFields.
@Override
public final ItemSum fixFields(NameResolutionContext context) {
getReferTables().clear();
for (int index = 0; index < getArgCount(); index++) {
Item arg = args.get(index);
Item fixedArg = arg.fixFields(context);
if (fixedArg == null)
return null;
args.set(index, fixedArg);
getReferTables().addAll(fixedArg.getReferTables());
withIsNull = withIsNull || fixedArg.isWithIsNull();
withSubQuery = withSubQuery || fixedArg.isWithSubQuery();
}
return this;
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class ItemSumAvg method toExpression.
@Override
public SQLExpr toExpression() {
Item arg0 = args.get(0);
SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
aggregate.addArgument(arg0.toExpression());
if (hasWithDistinct()) {
aggregate.setOption(SQLAggregateOption.DISTINCT);
}
return aggregate;
}
Aggregations