public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
if (current == groupBy.getHaving()) { column.setHaving(true); } else if (groupBy.getItems().contains(current)) {
if (x == groupBy.getHaving()) { return true; } else {
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
public boolean visit(SQLSelectGroupByClause x) { WallVisitorUtils.checkHaving(this, x.getHaving()); return true; }
if (current == groupBy.getHaving()) { column.setHaving(true); } else if (groupBy.getItems().contains(current)) {
if (x == groupBy.getHaving()) { return true; } else {
private void parseGroupCommon(RouteResultset rrs, MySqlSelectQueryBlock mysqlSelectQuery, TableConfig tc) { if (mysqlSelectQuery.getGroupBy() != null) { SQLSelectGroupByClause groupBy = mysqlSelectQuery.getGroupBy(); boolean hasPartitionColumn = false; for (SQLExpr groupByItem : groupBy.getItems()) { if (isNeedOptimizer(groupByItem)) { rrs.setNeedOptimizer(true); return; } else if (groupByItem instanceof SQLIdentifierExpr) { SQLIdentifierExpr item = (SQLIdentifierExpr) groupByItem; if (item.getSimpleName().equalsIgnoreCase(tc.getPartitionColumn())) { hasPartitionColumn = true; } } else if (groupByItem instanceof SQLPropertyExpr) { SQLPropertyExpr item = (SQLPropertyExpr) groupByItem; if (item.getSimpleName().equalsIgnoreCase(tc.getPartitionColumn())) { hasPartitionColumn = true; } } } if (groupBy.getItems().size() > 0 && !hasPartitionColumn) { rrs.setNeedOptimizer(true); return; } if (groupBy.getItems().size() == 0 && groupBy.getHaving() != null) { // only having filter need optimizer rrs.setNeedOptimizer(true); } } }
private void handleGroupBy(SQLSelectGroupByClause groupBy) { for (SQLExpr p : groupBy.getItems()) { if (p instanceof MySqlOrderingExpr) { MySqlOrderingExpr groupitem = (MySqlOrderingExpr) p; SQLExpr q = groupitem.getExpr(); MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, this.charsetIndex, this.metaManager); q.accept(v); this.tableNode = tableNode.groupBy(v.getItem(), groupitem.getType()); } else { MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, this.charsetIndex, this.metaManager); p.accept(v); this.tableNode = tableNode.groupBy(v.getItem(), SQLOrderingSpecification.ASC); } } if (groupBy.isWithRollUp()) { throw new MySQLOutPutException(ErrorCode.ER_OPTIMIZER, "", "with rollup is not supported yet!"); } if (groupBy.getHaving() != null) { handleHavingCondition(groupBy.getHaving()); } }
@Test public void testGroupbyHaving() { MySqlSelectQueryBlock query = getQuery("select col1 from table1 group by col1 having count(*)>1 "); SQLSelectGroupByClause groupBy = query.getGroupBy(); SQLExpr q = groupBy.getHaving(); MySQLItemVisitor v = new MySQLItemVisitor(this.currentDb, utf8Charset, null); q.accept(v); Item item = v.getItem(); Assert.assertEquals(true, "COUNT(*) > 1".equals(item.getItemName())); }