• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SQLAggregateExpr类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.alibaba.druid.sql.ast.expr.SQLAggregateExpr的典型用法代码示例。如果您正苦于以下问题:Java SQLAggregateExpr类的具体用法?Java SQLAggregateExpr怎么用?Java SQLAggregateExpr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SQLAggregateExpr类属于com.alibaba.druid.sql.ast.expr包,在下文中一共展示了SQLAggregateExpr类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: parserFields

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
private void parserFields(List<SQLSelectItem> mysqlSelectList){
	//显示的字段
	String key="";
	String value ="";
	for(SQLSelectItem item : mysqlSelectList) {
		if (item.getExpr() instanceof SQLAllColumnExpr) {
			//*解析
			setField(item.toString(), item.toString());
		}
		else {
			if (item.getExpr() instanceof SQLAggregateExpr) {
				SQLAggregateExpr expr =(SQLAggregateExpr)item.getExpr();
				 key = getExprFieldName(expr);
				 //value=expr.
			}
			else {					
				key=getFieldName(item);
				value=item.getAlias();
			}			
			setField(key, value);
		}
	}			
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:24,代码来源:JoinParser.java


示例2: toExpression

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    if (hasWithDistinct()) {
        aggregate.setOption(SQLAggregateOption.DISTINCT);
    }
    if (orders != null) {
        SQLOrderBy orderBy = new SQLOrderBy();
        for (Order order : orders) {
            SQLSelectOrderByItem orderItem = new SQLSelectOrderByItem(order.getItem().toExpression());
            orderItem.setType(order.getSortOrder());
            orderBy.addItem(orderItem);
        }
        aggregate.putAttribute(ItemFuncKeyWord.ORDER_BY, orderBy);
    }
    for (Item arg : args) {
        aggregate.addArgument(arg.toExpression());
    }
    if (seperator != null) {
        SQLCharExpr sep = new SQLCharExpr(seperator);
        aggregate.putAttribute(ItemFuncKeyWord.SEPARATOR, sep);
    }
    return aggregate;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:25,代码来源:ItemFuncGroupConcat.java


示例3: calAggregateFunctionValue

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
private void calAggregateFunctionValue(Map<String, SQLSelectItem> columnNameFunctionMapping, RowData row,
		RowData newRowData, List<Integer> ignoreColumnList) throws SQLException {
	try {
		for (ColumnData col : row.getColumnDatas()) {
			if (ignoreColumnList != null && ignoreColumnList.contains(col.getColumnIndex())) {
				continue;
			}
			SQLSelectItem columnType = columnNameFunctionMapping.get(col.getColumnName());
			SQLAggregateExpr aggregateExpr = (SQLAggregateExpr) columnType.getExpr();
			Aggregator dataProcessor = aggregateFunctionProcessors.get(aggregateExpr.getMethodName());
			if (dataProcessor != null) {
				ColumnData oldCol = newRowData.get(col.getColumnIndex());
				Object value = dataProcessor.process(oldCol.getValue(), col.getValue());

				if (value != null) {
					oldCol.setWasNull(false);
				}
				oldCol.setValue(value);
			} else {
				throw new SQLException("Zebra unsupported groupby function exists");
			}
		}
	} catch (AggregateException e) {
		throw new SQLException("Proc aggregate merge failed.");
	}
}
 
开发者ID:dianping,项目名称:zebra,代码行数:27,代码来源:GroupByDataMerger.java


示例4: toPage

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
@Override
protected BindSql toPage(PageLimit offsetLimit, SQLServerSelectQueryBlock selectBody, SQLSelect select, String raw) {
	SQLOrderBy order = select.getOrderBy();
	if (order == null) {
		order = defaultOrder;
	} else {
		select.setOrderBy(null);
	}
	
	SQLAggregateExpr arg=new SQLAggregateExpr("row_number");
	SQLOver over=new SQLOver();
	over.setOrderBy(order);
	arg.setOver(over);
	selectBody.getSelectList().add(0, new SQLSelectItem(arg, "__rn"));

	StringBuilder sb = new StringBuilder("SELECT _tmp1.* FROM (");
	SQLServerOutputVisitor visitor=new SQLServerOutputVisitor(sb);
	visitor.setPrettyFormat(false);
	select.accept(visitor);
	sb.append(") _tmp1 WHERE __rn between ");
	sb.append(offsetLimit.getOffset() + 1).append(" and ").append(offsetLimit.getEnd());
	return new BindSql(sb.toString());
}
 
开发者ID:GeeQuery,项目名称:ef-orm,代码行数:24,代码来源:SQL2005LimitHandler.java


示例5: getExprFieldName

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
private String getExprFieldName(SQLAggregateExpr expr){
	StringBuilder field = new StringBuilder();
	for (SQLExpr item :expr.getArguments()){
		field.append(item.toString());
	}		
	return expr.getMethodName()+"("+field.toString()+")";
}
 
开发者ID:huang-up,项目名称:mycat-src-1.6.1-RELEASE,代码行数:8,代码来源:JoinParser.java


示例6: toExpression

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
    Item arg0 = getArg(0);
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    aggregate.addArgument(arg0.toExpression());
    if (hasWithDistinct()) {
        aggregate.setOption(SQLAggregateOption.DISTINCT);
    }
    return aggregate;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:ItemSumSum.java


示例7: toExpression

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
    Item arg0 = args.get(0);
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    aggregate.addArgument(arg0.toExpression());
    return aggregate;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:8,代码来源:ItemSumMin.java


示例8: toExpression

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
@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;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:11,代码来源:ItemSumAvg.java


示例9: toExpression

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
@Override
public SQLExpr toExpression() {
    SQLAggregateExpr aggregate = new SQLAggregateExpr(funcName());
    if (hasWithDistinct()) {
        for (Item arg : args)
            aggregate.addArgument(arg.toExpression());
        aggregate.setOption(SQLAggregateOption.DISTINCT);
    } else {
        Item arg0 = getArg(0);
        aggregate.addArgument(arg0.toExpression());
    }
    return aggregate;
}
 
开发者ID:actiontech,项目名称:dble,代码行数:14,代码来源:ItemSumCount.java


示例10: visit

import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr; //导入依赖的package包/类
@Override
public boolean visit(MySqlSelectQueryBlock x) {
	Map<String, SQLSelectItem> selectItemMap = result.getMergeContext().getSelectItemMap();
	Map<String, String> columnNameAliasMapping = result.getMergeContext().getColumnNameAliasMapping();

	for (SQLSelectItem column : x.getSelectList()) {
		String name = null;
		if (column.getExpr() instanceof SQLAggregateExpr) {
			SQLAggregateExpr expr = (SQLAggregateExpr) column.getExpr();
			SQLExpr argument = expr.getArguments().get(0);
			if (argument instanceof SQLAllColumnExpr) {
				name = expr.getMethodName() + "(*)";
			} else if(argument instanceof SQLIntegerExpr){
				name = expr.getMethodName() + "(1)";
			}else {
				name = expr.getMethodName() + "(" + ((SQLName) argument).getSimpleName() + ")";
				columnNameAliasMapping.put(((SQLName) argument).getSimpleName(), column.getAlias());
			}

			result.getMergeContext().setAggregate(true);
		} else if (column.getExpr() instanceof SQLIdentifierExpr || column.getExpr() instanceof SQLPropertyExpr) {
			name = ((SQLName) column.getExpr()).getSimpleName();

			if (column.getAlias() != null) {
				SQLName identifier = (SQLName) column.getExpr();
				columnNameAliasMapping.put(identifier.getSimpleName(), column.getAlias());
			}
		} else {
			// ignore SQLAllColumnExpr,SQLMethodInvokeExpr and etc.
		}

		selectItemMap.put(column.getAlias() == null ? name : column.getAlias(), column);
	}

	if (x.getDistionOption() == 2) {
		result.getMergeContext().setDistinct(true);
	}

	return true;
}
 
开发者ID:dianping,项目名称:zebra,代码行数:41,代码来源:MySQLSelectASTVisitor.java



注:本文中的com.alibaba.druid.sql.ast.expr.SQLAggregateExpr类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Presenter类代码示例发布时间:2022-05-23
下一篇:
Java STBVorbisInfo类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap