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


Java SqlNodeList.size方法代码示例

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


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

示例1: AggConverter

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
/**
 * Creates an AggConverter.
 *
 * <p>The <code>select</code> parameter provides enough context to name
 * aggregate calls which are top-level select list items.
 *
 * @param bb     Blackboard
 * @param select Query being translated; provides context to give
 */
public AggConverter(Blackboard bb, SqlSelect select) {
	this.bb = bb;
	this.aggregatingSelectScope =
		(AggregatingSelectScope) bb.getValidator().getSelectScope(select);

	// Collect all expressions used in the select list so that aggregate
	// calls can be named correctly.
	final SqlNodeList selectList = select.getSelectList();
	for (int i = 0; i < selectList.size(); i++) {
		SqlNode selectItem = selectList.get(i);
		String name = null;
		if (SqlUtil.isCallTo(
			selectItem,
			SqlStdOperatorTable.AS)) {
			final SqlCall call = (SqlCall) selectItem;
			selectItem = call.operand(0);
			name = call.operand(1).toString();
		}
		if (name == null) {
			name = validator.deriveAlias(selectItem, i);
		}
		nameMap.put(selectItem.toString(), name);
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:34,代码来源:SqlToRelConverter.java

示例2: AggConverter

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
/**
 * Creates an AggConverter.
 *
 * <p>The <code>select</code> parameter provides enough context to name
 * aggregate calls which are top-level select list items.
 *
 * @param bb     Blackboard
 * @param select Query being translated; provides context to give
 */
public AggConverter(Blackboard bb, SqlSelect select) {
  this.bb = bb;
  this.aggregatingSelectScope =
      (AggregatingSelectScope) bb.getValidator().getSelectScope(select);

  // Collect all expressions used in the select list so that aggregate
  // calls can be named correctly.
  final SqlNodeList selectList = select.getSelectList();
  for (int i = 0; i < selectList.size(); i++) {
    SqlNode selectItem = selectList.get(i);
    String name = null;
    if (SqlUtil.isCallTo(
        selectItem,
        SqlStdOperatorTable.AS)) {
      final SqlCall call = (SqlCall) selectItem;
      selectItem = call.operand(0);
      name = call.operand(1).toString();
    }
    if (name == null) {
      name = validator.deriveAlias(selectItem, i);
    }
    nameMap.put(selectItem.toString(), name);
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:34,代码来源:SqlToRelConverter.java

示例3: getMonotonicity

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
public SqlMonotonicity getMonotonicity(SqlNode expr) {
  SqlMonotonicity monotonicity = expr.getMonotonicity(this);
  if (monotonicity != SqlMonotonicity.NOT_MONOTONIC) {
    return monotonicity;
  }

  // TODO: compare fully qualified names
  final SqlNodeList orderList = getOrderList();
  if (orderList.size() > 0) {
    SqlNode order0 = orderList.get(0);
    monotonicity = SqlMonotonicity.INCREASING;
    if ((order0 instanceof SqlCall)
        && (((SqlCall) order0).getOperator()
        == SqlStdOperatorTable.DESC)) {
      monotonicity = monotonicity.reverse();
      order0 = ((SqlCall) order0).operand(0);
    }
    if (expr.equalsDeep(order0, Litmus.IGNORE)) {
      return monotonicity;
    }
  }

  return SqlMonotonicity.NOT_MONOTONIC;
}
 
开发者ID:apache,项目名称:calcite,代码行数:25,代码来源:SelectScope.java

示例4: expandStar

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
public SqlNodeList expandStar(
    SqlNodeList selectList,
    SqlSelect select,
    boolean includeSystemVars) {
  final List<SqlNode> list = new ArrayList<>();
  final List<Map.Entry<String, RelDataType>> types = new ArrayList<>();
  for (int i = 0; i < selectList.size(); i++) {
    final SqlNode selectItem = selectList.get(i);
    final RelDataType originalType = getValidatedNodeTypeIfKnown(selectItem);
    expandSelectItem(
        selectItem,
        select,
        Util.first(originalType, unknownType),
        list,
        catalogReader.nameMatcher().isCaseSensitive()
            ? new LinkedHashSet<String>()
            : new TreeSet<>(String.CASE_INSENSITIVE_ORDER),
        types,
        includeSystemVars);
  }
  getRawSelectScope(select).setExpandedSelectList(list);
  return new SqlNodeList(list, SqlParserPos.ZERO);
}
 
开发者ID:apache,项目名称:calcite,代码行数:24,代码来源:SqlValidatorImpl.java

示例5: nodeList

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
UnparseUtil nodeList(SqlNodeList l) {
  writer.keyword("(");
  if (l.size() > 0) {
    l.get(0).unparse(writer, leftPrec, rightPrec);
    for (int i = 1; i < l.size(); ++i) {
      writer.keyword(",");
      l.get(i).unparse(writer, leftPrec, rightPrec);
    }
  }
  writer.keyword(")");
  return this;
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:13,代码来源:UnparseUtil.java

示例6: unparseSqlNodeList

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
public static void unparseSqlNodeList(SqlWriter writer, int leftPrec, int rightPrec, SqlNodeList fieldList) {
  writer.keyword("(");
  fieldList.get(0).unparse(writer, leftPrec, rightPrec);
  for (int i = 1; i<fieldList.size(); i++) {
    writer.keyword(",");
    fieldList.get(i).unparse(writer, leftPrec, rightPrec);
  }
  writer.keyword(")");
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:10,代码来源:SqlHandlerUtil.java

示例7: createStorageOptionsMap

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
/**
 * Helper method to create map of key, value pairs, the value is a Java type object.
 * @param args
 * @return
 */
protected static Map<String, Object> createStorageOptionsMap(SqlHandlerConfig config, final SqlNodeList args) {
  if (args == null || args.size() == 0) {
    return null;
  }

  final ImmutableMap.Builder<String, Object> storageOptions = ImmutableMap.builder();
  for (SqlNode operand : args) {
    if (operand.getKind() != SqlKind.ARGUMENT_ASSIGNMENT) {
      throw UserException.unsupportedError()
          .message("Unsupported argument type. Only assignment arguments (param => value) are supported.")
          .build(logger);
    }
    final List<SqlNode> operandList = ((SqlCall) operand).getOperandList();

    final String name = ((SqlIdentifier) operandList.get(1)).getSimple();
    SqlNode literal = operandList.get(0);
    if (!(literal instanceof SqlLiteral)) {
      throw UserException.unsupportedError()
          .message("Only literals are accepted for storage option values")
          .build(logger);
    }

    Object value = ((SqlLiteral)literal).getValue();
    if (value instanceof NlsString) {
      value = ((NlsString)value).getValue();
    }
    storageOptions.put(name, value);
  }

  return storageOptions.build();
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:37,代码来源:CreateTableHandler.java

示例8: getColumnNames

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
@Override
protected List<String> getColumnNames() {
    SqlNodeList columnNodes = rootNode.getTargetColumnList();
    List<String> result = new ArrayList<>(columnNodes.size());
    for (SqlNode columnNode : columnNodes) {
        result.add(getName((SqlIdentifier) columnNode));
    }
    return result;
}
 
开发者ID:axibase,项目名称:atsd-jdbc,代码行数:10,代码来源:AtsdSqlInsertConverter.java

示例9: builder

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
/**
 * Once you have a Result of implementing a child relational expression,
 * call this method to create a Builder to implement the current relational
 * expression by adding additional clauses to the SQL query.
 * <p/>
 * <p>You need to declare which clauses you intend to add. If the clauses
 * are "later", you can add to the same query. For example, "GROUP BY" comes
 * after "WHERE". But if they are the same or earlier, this method will
 * start a new SELECT that wraps the previous result.</p>
 * <p/>
 * <p>When you have called
 * {@link Builder#setSelect(org.apache.calcite.sql.SqlNodeList)},
 * {@link Builder#setWhere(org.apache.calcite.sql.SqlNode)} etc. call
 * {@link Builder#result(org.apache.calcite.sql.SqlNode, java.util.Collection, org.apache.calcite.rel.RelNode)}
 * to fix the new query.</p>
 *
 * @param rel       Relational expression being implemented
 * @param clauseArr Clauses that will be generated to implement current
 *                  relational expression
 * @return A builder
 */
public Builder builder(JdbcRel rel, Clause... clauseArr) {
    final Clause maxClause = maxClause();
    boolean needNew = false;
    for (Clause clause : clauseArr) {
        if (maxClause.ordinal() >= clause.ordinal()) {
            needNew = true;
        }
    }
    SqlSelect select;
    Expressions.FluentList<Clause> clauseList = Expressions.list();
    if (needNew) {
        select = subSelect();
    } else {
        select = asSelect();
        clauseList.addAll(this.clauses);
    }
    clauseList.appendAll(clauseArr);
    Context newContext;
    final SqlNodeList selectList = select.getSelectList();
    if (selectList != null) {
        newContext = new Context(selectList.size()) {
            @Override
            public SqlNode field(int ordinal) {
                final SqlNode selectItem = selectList.get(ordinal);
                switch (selectItem.getKind()) {
                case AS:
                    return ((SqlCall) selectItem).operand(0);
                default:
                }
                return selectItem;
            }
        };
    } else {
        newContext = aliasContext(aliases, aliases.size() > 1);
    }
    return new Builder(rel, clauseList, select, newContext);
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:59,代码来源:JdbcImplementor.java

示例10: visit

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
@Override
public SqlNode visit(SqlNodeList nodeList) {
    for (int i = 0; i < nodeList.size(); i++) {
        SqlNode node = nodeList.get(i);
        if (node instanceof SqlWithItem) {
            SqlWithItem item = (SqlWithItem) node;
            item.query.accept(this);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:kylin,代码行数:12,代码来源:PushDownUtil.java

示例11: options

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private static List<Pair<SqlIdentifier, SqlNode>> options(
    final SqlNodeList optionList) {
  return new AbstractList<Pair<SqlIdentifier, SqlNode>>() {
    public Pair<SqlIdentifier, SqlNode> get(int index) {
      return Pair.of((SqlIdentifier) optionList.get(index * 2),
          optionList.get(index * 2 + 1));
    }

    public int size() {
      return optionList.size() / 2;
    }
  };
}
 
开发者ID:apache,项目名称:calcite,代码行数:14,代码来源:SqlCreateForeignSchema.java

示例12: registerSubQueries

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private void registerSubQueries(
    SqlValidatorScope parentScope,
    SqlNode node) {
  if (node == null) {
    return;
  }
  if (node.getKind().belongsTo(SqlKind.QUERY)
      || node.getKind() == SqlKind.MULTISET_QUERY_CONSTRUCTOR
      || node.getKind() == SqlKind.MULTISET_VALUE_CONSTRUCTOR) {
    registerQuery(parentScope, null, node, node, null, false);
  } else if (node instanceof SqlCall) {
    validateNodeFeature(node);
    SqlCall call = (SqlCall) node;
    for (int i = 0; i < call.operandCount(); i++) {
      registerOperandSubQueries(parentScope, call, i);
    }
  } else if (node instanceof SqlNodeList) {
    SqlNodeList list = (SqlNodeList) node;
    for (int i = 0, count = list.size(); i < count; i++) {
      SqlNode listNode = list.get(i);
      if (listNode.getKind().belongsTo(SqlKind.QUERY)) {
        listNode =
            SqlStdOperatorTable.SCALAR_QUERY.createCall(
                listNode.getParserPosition(),
                listNode);
        list.set(i, listNode);
      }
      registerSubQueries(parentScope, listNode);
    }
  } else {
    // atomic node -- can be ignored
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:34,代码来源:SqlValidatorImpl.java

示例13: visit

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
public R visit(SqlNodeList nodeList) {
  R result = null;
  for (int i = 0; i < nodeList.size(); i++) {
    SqlNode node = nodeList.get(i);
    result = node.accept(this);
  }
  return result;
}
 
开发者ID:apache,项目名称:calcite,代码行数:9,代码来源:SqlBasicVisitor.java

示例14: convertToSingleValueSubq

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
/**
 * Converts the RelNode tree for a select statement to a select that
 * produces a single value.
 *
 * @param query the query
 * @param plan   the original RelNode tree corresponding to the statement
 * @return the converted RelNode tree
 */
public RelNode convertToSingleValueSubq(
	SqlNode query,
	RelNode plan) {
	// Check whether query is guaranteed to produce a single value.
	if (query instanceof SqlSelect) {
		SqlSelect select = (SqlSelect) query;
		SqlNodeList selectList = select.getSelectList();
		SqlNodeList groupList = select.getGroup();

		if ((selectList.size() == 1)
			&& ((groupList == null) || (groupList.size() == 0))) {
			SqlNode selectExpr = selectList.get(0);
			if (selectExpr instanceof SqlCall) {
				SqlCall selectExprCall = (SqlCall) selectExpr;
				if (Util.isSingleValue(selectExprCall)) {
					return plan;
				}
			}

			// If there is a limit with 0 or 1,
			// it is ensured to produce a single value
			if (select.getFetch() != null
				&& select.getFetch() instanceof SqlNumericLiteral) {
				SqlNumericLiteral limitNum = (SqlNumericLiteral) select.getFetch();
				if (((BigDecimal) limitNum.getValue()).intValue() < 2) {
					return plan;
				}
			}
		}
	} else if (query instanceof SqlCall) {
		// If the query is (values ...),
		// it is necessary to look into the operands to determine
		// whether SingleValueAgg is necessary
		SqlCall exprCall = (SqlCall) query;
		if (exprCall.getOperator()
			instanceof SqlValuesOperator
			&& Util.isSingleValue(exprCall)) {
			return plan;
		}
	}

	// If not, project SingleValueAgg
	return RelOptUtil.createSingleValueAggRel(
		cluster,
		plan);
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:55,代码来源:SqlToRelConverter.java

示例15: convertOver

import org.apache.calcite.sql.SqlNodeList; //导入方法依赖的package包/类
private RexNode convertOver(Blackboard bb, SqlNode node) {
	SqlCall call = (SqlCall) node;
	SqlCall aggCall = call.operand(0);
	SqlNode windowOrRef = call.operand(1);
	final SqlWindow window =
		validator.resolveWindow(windowOrRef, bb.scope, true);

	// ROW_NUMBER() expects specific kind of framing.
	if (aggCall.getKind() == SqlKind.ROW_NUMBER) {
		window.setLowerBound(SqlWindow.createUnboundedPreceding(SqlParserPos.ZERO));
		window.setUpperBound(SqlWindow.createCurrentRow(SqlParserPos.ZERO));
		window.setRows(SqlLiteral.createBoolean(true, SqlParserPos.ZERO));
	}
	final SqlNodeList partitionList = window.getPartitionList();
	final ImmutableList.Builder<RexNode> partitionKeys =
		ImmutableList.builder();
	for (SqlNode partition : partitionList) {
		partitionKeys.add(bb.convertExpression(partition));
	}
	RexNode lowerBound = bb.convertExpression(window.getLowerBound());
	RexNode upperBound = bb.convertExpression(window.getUpperBound());
	SqlNodeList orderList = window.getOrderList();
	if ((orderList.size() == 0) && !window.isRows()) {
		// A logical range requires an ORDER BY clause. Use the implicit
		// ordering of this relation. There must be one, otherwise it would
		// have failed validation.
		orderList = bb.scope.getOrderList();
		if (orderList == null) {
			throw new AssertionError(
				"Relation should have sort key for implicit ORDER BY");
		}
	}
	final ImmutableList.Builder<RexFieldCollation> orderKeys =
		ImmutableList.builder();
	final Set<SqlKind> flags = EnumSet.noneOf(SqlKind.class);
	for (SqlNode order : orderList) {
		flags.clear();
		RexNode e = bb.convertSortExpression(order, flags);
		orderKeys.add(new RexFieldCollation(e, flags));
	}
	try {
		Preconditions.checkArgument(bb.window == null,
			"already in window agg mode");
		bb.window = window;
		RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
		rexAgg =
			rexBuilder.ensureType(
				validator.getValidatedNodeType(call), rexAgg, false);

		// Walk over the tree and apply 'over' to all agg functions. This is
		// necessary because the returned expression is not necessarily a call
		// to an agg function. For example, AVG(x) becomes SUM(x) / COUNT(x).
		final RexShuttle visitor =
			new HistogramShuttle(
				partitionKeys.build(), orderKeys.build(),
				RexWindowBound.create(window.getLowerBound(), lowerBound),
				RexWindowBound.create(window.getUpperBound(), upperBound),
				window);
		return rexAgg.accept(visitor);
	} finally {
		bb.window = null;
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:64,代码来源:SqlToRelConverter.java


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