本文整理汇总了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;未经允许,请勿转载。 |
请发表评论