当前位置: 首页>>代码示例>>Java>>正文


Java SelectExpressionItem.getExpression方法代码示例

本文整理汇总了Java中net.sf.jsqlparser.statement.select.SelectExpressionItem.getExpression方法的典型用法代码示例。如果您正苦于以下问题:Java SelectExpressionItem.getExpression方法的具体用法?Java SelectExpressionItem.getExpression怎么用?Java SelectExpressionItem.getExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jsqlparser.statement.select.SelectExpressionItem的用法示例。


在下文中一共展示了SelectExpressionItem.getExpression方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createProjections

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入方法依赖的package包/类
private List<ProjectionItem> createProjections(PlainSelect plainSelect, List<ProjectionItem> fromProjections) throws AmbiguousCoalesceException {
	List<ProjectionItem> projections = Lists.newArrayList();

	List<SelectItem> selectItems = plainSelect.getSelectItems();

	for (SelectItem selectItem : selectItems) {
		if (selectItem instanceof AllColumns) {
			addAllFromProjections(fromProjections, projections);
		} else if (selectItem instanceof AllTableColumns) {
			AllTableColumns allTableColumns = (AllTableColumns) selectItem;
			Table table = allTableColumns.getTable();

			addAllFromProjectionsOfTable(fromProjections, projections, table);
		} else if (selectItem instanceof SelectExpressionItem) {
			SelectExpressionItem selectExpressionItem = (SelectExpressionItem) selectItem;
			Expression expression = selectExpressionItem.getExpression();

			addExpressionProjection(fromProjections, projections, expression, selectExpressionItem.getAlias());
		}
	}
	
	return projections;
}
 
开发者ID:sebastianoe,项目名称:s4j,代码行数:24,代码来源:QueryTypeExtractor.java

示例2: SQLAggregator

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入方法依赖的package包/类
public SQLAggregator(List<SelectItem> selectItems, List<Expression> groupByColumnReferences, RecordSetFactory recordSetFactory) throws StatementExecutionException {
    this.recordSetFactory = recordSetFactory;
    this.selectItems = selectItems;
    this.groupByColumnReferences = groupByColumnReferences != null ? groupByColumnReferences : Collections.emptyList();

    for (SelectItem item : selectItems) {
        boolean done = false;
        if (item instanceof SelectExpressionItem) {
            SelectExpressionItem sei = (SelectExpressionItem) item;
            Expression expression = sei.getExpression();
            if (expression instanceof Function) {
                Function f = (Function) expression;
                if (BuiltinFunctions.isAggregateFunction(f.getName())) {
                    done = true;
                }
            } else if (expression instanceof net.sf.jsqlparser.schema.Column) {
                net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) expression;
                for (Expression ex : this.groupByColumnReferences) {
                    if (ex instanceof net.sf.jsqlparser.schema.Column) {
                        net.sf.jsqlparser.schema.Column cex = (net.sf.jsqlparser.schema.Column) ex;
                        if (cex.getColumnName().equals(c.getColumnName())) {
                            done = true;
                            break;
                        }
                    }
                }
            }
        }
        if (!done) {
            throw new StatementExecutionException("field " + item + " MUST appear in GROUP BY clause");
        }
    }

}
 
开发者ID:diennea,项目名称:herddb,代码行数:35,代码来源:SQLAggregator.java

示例3: visit

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入方法依赖的package包/类
@Override
public void visit(SelectExpressionItem sei) {
    String alias = sei.getAlias() != null ? sei.getAlias().getName() : null;
    if (alias != null) {
        selectDef.getColumns().add(alias);
    } else {
        if (sei.getExpression() instanceof Column) {
            Column col = (Column) sei.getExpression();
            selectDef.getColumns().add(CheckExpressionParser.fixColumnName(col.getColumnName()));
        } else {
            throw new QueryException("Complex return expressions must have alias defined: %s", sei.getExpression());
        }
    }
    sei.getExpression().accept(expParser);
}
 
开发者ID:valdasraps,项目名称:resthub,代码行数:16,代码来源:CheckSelectParser.java

示例4: createOutputColumns

import net.sf.jsqlparser.statement.select.SelectExpressionItem; //导入方法依赖的package包/类
private static Column[] createOutputColumns(List<SelectItem> selectItems, DataScanner wrapped) throws StatementExecutionException {
    Column[] columns = new Column[selectItems.size()];
    int i = 0;
    for (SelectItem item : selectItems) {
        boolean done = false;
        if (item instanceof SelectExpressionItem) {
            SelectExpressionItem sei = (SelectExpressionItem) item;
            Expression expression = sei.getExpression();

            if (expression instanceof Function) {
                Function f = (Function) expression;
                String fieldName = f.toString();
                if (sei.getAlias() != null && sei.getAlias().getName() != null) {
                    fieldName = sei.getAlias().getName();
                }
                if (fieldName == null) {
                    fieldName = "field" + i;
                }
                Column aggregated = BuiltinFunctions.toAggregatedOutputColumn(fieldName, f);
                if (aggregated != null) {
                    columns[i] = aggregated;
                    done = true;
                }
            } else if (expression instanceof net.sf.jsqlparser.schema.Column) {
                net.sf.jsqlparser.schema.Column c = (net.sf.jsqlparser.schema.Column) expression;
                String name = c.getColumnName();
                boolean found = false;
                for (Column co : wrapped.getSchema()) {
                    if (co.name.equals(name)) {
                        columns[i] = co;
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    throw new StatementExecutionException("cannot find column " + name + " is upstream scanner");
                }
                done = true;
            } else {
                throw new StatementExecutionException("unhandled aggregate query selectable item:" + expression);
            }
        }
        i++;
        if (!done) {
            throw new StatementExecutionException("unhandled aggregate function " + item);
        }
    }
    return columns;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:50,代码来源:SQLAggregator.java


注:本文中的net.sf.jsqlparser.statement.select.SelectExpressionItem.getExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。