use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class ItemFunc method fixFields.
@Override
public final ItemFunc fixFields(NameResolutionContext context) {
getReferTables().clear();
if (getArgCount() > 0) {
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());
withSumFunc = withSumFunc || fixedArg.isWithSumFunc();
withIsNull = withIsNull || fixedArg.isWithIsNull();
withSubQuery = withSubQuery || fixedArg.isWithSubQuery();
withUnValAble = withUnValAble || arg.isWithUnValAble();
}
}
return this;
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class DruidSelectParser method isSumFuncOrSubQuery.
private boolean isSumFuncOrSubQuery(String schema, SQLExpr itemExpr) {
MySQLItemVisitor ev = new MySQLItemVisitor(schema, CharsetUtil.getCharsetDefaultIndex("utf8"), DbleServer.getInstance().getTmManager());
itemExpr.accept(ev);
Item selItem = ev.getItem();
return contaisSumFuncOrSubquery(selItem);
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class TestMySQLItemVisitor method testGroupbyOrder.
@Test
public void testGroupbyOrder() {
MySqlSelectQueryBlock query = getQuery("select col1,col2 from table1 group by col1 desc,col2 asc ");
SQLSelectGroupByClause groupBy = query.getGroupBy();
int i = 0;
for (SQLExpr p : groupBy.getItems()) {
i++;
String groupCol = "col" + i;
MySqlOrderingExpr groupitem = (MySqlOrderingExpr) p;
SQLExpr q = groupitem.getExpr();
MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
q.accept(v);
Item item = v.getItem();
Assert.assertEquals(true, groupCol.equals(item.getItemName()));
}
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class TestMySQLItemVisitor method testSelectItem.
@Test
public void testSelectItem() {
MySqlSelectQueryBlock query = getQuery("select sum(col1) from table1 where a >1 ");
List<SQLSelectItem> items = query.getSelectList();
MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
items.get(0).accept(v);
Item item = v.getItem();
Assert.assertEquals(true, "SUM(col1)".equals(item.getItemName()));
}
use of com.actiontech.dble.plan.common.item.Item in project dble by actiontech.
the class TestMySQLItemVisitor method testGroupby.
@Test
public void testGroupby() {
MySqlSelectQueryBlock query = getQuery("select col1,col2 from table1 group by col1,col2");
SQLSelectGroupByClause groupBy = query.getGroupBy();
int i = 0;
for (SQLExpr p : groupBy.getItems()) {
i++;
String groupCol = "col" + i;
MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null);
p.accept(v);
Item item = v.getItem();
Assert.assertEquals(true, groupCol.equals(item.getItemName()));
}
}
Aggregations