Search in sources :

Example 91 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class TestMySQLItemVisitor method testWhere.

// TODO:ORDER BY /GROUP BY position
@Test
public void testWhere() {
    MySqlSelectQueryBlock query = getQuery("select col1,col2  from table1 where a =1 ");
    SQLExpr expr = query.getWhere();
    MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
    expr.accept(v);
    Item item = v.getItem();
    Assert.assertEquals(true, "a = 1".equals(item.getItemName()));
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) MySqlSelectQueryBlock(com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock) SQLExpr(com.alibaba.druid.sql.ast.SQLExpr) Test(org.junit.Test)

Example 92 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class ItemFuncCase method valInt.

@Override
public BigInteger valInt() {
    Item item = findItem();
    if (item == null) {
        nullValue = true;
        return BigInteger.ZERO;
    }
    BigInteger res = item.valInt();
    nullValue = item.isNullValue();
    return res;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) BigInteger(java.math.BigInteger)

Example 93 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class ItemFuncCase method valReal.

@Override
public BigDecimal valReal() {
    Item item = findItem();
    if (item == null) {
        nullValue = true;
        return BigDecimal.ZERO;
    }
    BigDecimal res = item.valReal();
    nullValue = item.isNullValue();
    return res;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) BigDecimal(java.math.BigDecimal)

Example 94 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class ItemFuncCase method valStr.

@Override
public String valStr() {
    FieldTypes i = fieldType();
    if (i == FieldTypes.MYSQL_TYPE_DATETIME || i == FieldTypes.MYSQL_TYPE_TIMESTAMP) {
        return valStringFromDatetime();
    } else if (i == FieldTypes.MYSQL_TYPE_DATE) {
        return valStringFromDate();
    } else if (i == FieldTypes.MYSQL_TYPE_TIME) {
        return valStringFromTime();
    } else {
        Item item = findItem();
        if (item != null) {
            String res;
            if ((res = item.valStr()) != null) {
                nullValue = false;
                return res;
            }
        }
    }
    nullValue = true;
    return null;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) FieldTypes(com.actiontech.dble.plan.common.item.FieldTypes)

Example 95 with Item

use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.

the class ItemFuncIf method valInt.

@Override
public BigInteger valInt() {
    Item arg = args.get(0).valBool() ? args.get(1) : args.get(2);
    BigInteger value = arg.valInt();
    nullValue = arg.isNullValue();
    return value;
}
Also used : Item(com.actiontech.dble.plan.common.item.Item) BigInteger(java.math.BigInteger)

Aggregations

Item (com.actiontech.dble.plan.common.item.Item)122 ArrayList (java.util.ArrayList)26 Order (com.actiontech.dble.plan.Order)16 PlanNode (com.actiontech.dble.plan.node.PlanNode)14 MySQLOutPutException (com.actiontech.dble.plan.common.exception.MySQLOutPutException)10 ItemField (com.actiontech.dble.plan.common.item.ItemField)10 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)7 MySqlSelectQueryBlock (com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlSelectQueryBlock)7 Test (org.junit.Test)7 FieldPacket (com.actiontech.dble.net.mysql.FieldPacket)6 ItemFuncEqual (com.actiontech.dble.plan.common.item.function.operator.cmpfunc.ItemFuncEqual)6 ItemSum (com.actiontech.dble.plan.common.item.function.sumfunc.ItemSum)6 JoinNode (com.actiontech.dble.plan.node.JoinNode)6 SQLAggregateExpr (com.alibaba.druid.sql.ast.expr.SQLAggregateExpr)6 ItemFunc (com.actiontech.dble.plan.common.item.function.ItemFunc)5 ItemInt (com.actiontech.dble.plan.common.item.ItemInt)4 ItemString (com.actiontech.dble.plan.common.item.ItemString)4 BigDecimal (java.math.BigDecimal)4 RowDataPacket (com.actiontech.dble.net.mysql.RowDataPacket)3 NamedField (com.actiontech.dble.plan.NamedField)3