本文整理汇总了Java中org.apache.calcite.sql.SqlNodeList.getList方法的典型用法代码示例。如果您正苦于以下问题:Java SqlNodeList.getList方法的具体用法?Java SqlNodeList.getList怎么用?Java SqlNodeList.getList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.calcite.sql.SqlNodeList
的用法示例。
在下文中一共展示了SqlNodeList.getList方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSwitched
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
/**
* Creates a call to the switched form of the case operator, viz:
*
* <blockquote><code>CASE value<br>
* WHEN whenList[0] THEN thenList[0]<br>
* WHEN whenList[1] THEN thenList[1]<br>
* ...<br>
* ELSE elseClause<br>
* END</code></blockquote>
*/
public static SqlCase createSwitched(SqlParserPos pos, SqlNode value,
SqlNodeList whenList, SqlNodeList thenList, SqlNode elseClause) {
if (null != value) {
List<SqlNode> list = whenList.getList();
for (int i = 0; i < list.size(); i++) {
SqlNode e = list.get(i);
final SqlCall call;
if (e instanceof SqlNodeList) {
call = SqlStdOperatorTable.IN.createCall(pos, value, e);
} else {
call = SqlStdOperatorTable.EQUALS.createCall(pos, value, e);
}
list.set(i, call);
}
}
if (null == elseClause) {
elseClause = SqlLiteral.createNull(pos);
}
return new SqlCase(pos, null, whenList, thenList, elseClause);
}
示例2: visit
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
public SqlNode visit(SqlNodeList nodeList) {
boolean update = false;
List<SqlNode> exprs = nodeList.getList();
int exprCount = exprs.size();
List<SqlNode> newList = new ArrayList<SqlNode>(exprCount);
for (SqlNode operand : exprs) {
SqlNode clonedOperand;
if (operand == null) {
clonedOperand = null;
} else {
clonedOperand = operand.accept(this);
if (clonedOperand != operand) {
update = true;
}
}
newList.add(clonedOperand);
}
if (update) {
return new SqlNodeList(newList, nodeList.getParserPosition());
} else {
return nodeList;
}
}
示例3: toNameAndGranularity
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private List<NameAndGranularity> toNameAndGranularity(SqlNodeList list){
if(list == null){
return ImmutableList.of();
}
List<NameAndGranularity> columnNames = Lists.newArrayList();
for(SqlNode node : list.getList()) {
IdentifierWithGranularity ident = (IdentifierWithGranularity) node;
NameAndGranularity value = new NameAndGranularity(ident.getSimple(), ident.getByDay() ? Granularity.BY_DAY : Granularity.NORMAL);
columnNames.add(value);
}
return columnNames;
}
示例4: toStrings
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private List<String> toStrings(SqlNodeList list){
if(list == null){
return ImmutableList.of();
}
List<String> columnNames = Lists.newArrayList();
for(SqlNode node : list.getList()) {
columnNames.add(node.toString());
}
return columnNames;
}
示例5: extractOrders
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private List<Order> extractOrders(SqlNodeList orderBy, final FromNode from) {
List<Order> orders = new ArrayList<>();
if (orderBy != null) {
for (SqlNode sqlNode : orderBy.getList()) {
orders.add(sqlNode.accept(new BaseSqlVisitor<Order>() {
@Override
public Order visit(SqlIdentifier id) {
return new Order(idToRef(from, id), ASC);
}
@Override
public Order visit(SqlCall call) {
switch (call.getOperator().getKind()) {
// there's no ASCENDING. It always fall in the id case above
case DESCENDING:
List<SqlNode> operandList = call.getOperandList();
if (operandList.size() != 1) {
throw new UnsupportedOperationException("Unexpected DESC operands in order clause:\n" + SqlNodes.toTreeString(call));
}
SqlNode operand = operandList.get(0);
if (operand.getKind() == IDENTIFIER) {
return new Order(idToRef(from, (SqlIdentifier)operand), DESC);
} else {
throw new UnsupportedOperationException("Unexpected DESC operand in order clause:\n" + SqlNodes.toTreeString(call));
}
default:
throw new UnsupportedOperationException("Unexpected SqlOperatorImpl in order clause:\n" + SqlNodes.toTreeString(call));
}
}
}));
}
}
if (orders.size() == 0) {
return null;
}
return orders;
}
示例6: containsNullLiteral
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private static boolean containsNullLiteral(SqlNodeList valueList) {
for (SqlNode node : valueList.getList()) {
if (node instanceof SqlLiteral) {
SqlLiteral lit = (SqlLiteral) node;
if (lit.getValue() == null) {
return true;
}
}
}
return false;
}
示例7: visit
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
@Override
public Expression visit(SqlNodeList nodeList) {
List<Expression> expressions = new ArrayList<>();
for (SqlNode node : nodeList.getList()) {
expressions.add(node.accept(this));
}
return new ExpressionList(expressions);
}
示例8: containsNullLiteral
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private static boolean containsNullLiteral(SqlNodeList valueList) {
for (SqlNode node : valueList.getList()) {
if (node instanceof SqlLiteral) {
SqlLiteral lit = (SqlLiteral) node;
if (lit.getValue() == null) {
return true;
}
}
}
return false;
}
示例9: pairs
import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
/** Converts a list of extended columns
* (of the form [name0, type0, name1, type1, ...])
* into a list of (name, type) pairs. */
private static List<Pair<SqlIdentifier, SqlDataTypeSpec>> pairs(
SqlNodeList extendedColumns) {
final List list = extendedColumns.getList();
//noinspection unchecked
return Pair.zip(Util.quotientList(list, 2, 0),
Util.quotientList(list, 2, 1));
}