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


Java SqlSelect.getSelectList方法代码示例

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


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

示例1: AggConverter

import org.apache.calcite.sql.SqlSelect; //导入方法依赖的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.SqlSelect; //导入方法依赖的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: builder

import org.apache.calcite.sql.SqlSelect; //导入方法依赖的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

示例4: convertToSingleValueSubq

import org.apache.calcite.sql.SqlSelect; //导入方法依赖的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

示例5: builder

import org.apache.calcite.sql.SqlSelect; //导入方法依赖的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>
 * <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>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 clauses Clauses that will be generated to implement current
 *                relational expression
 * @return A builder
 */
public Builder builder(RelNode rel, Clause... clauses) {
  final Clause maxClause = maxClause();
  boolean needNew = false;
  for (Clause clause : clauses) {
    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(clauses);
  Context newContext;
  final SqlNodeList selectList = select.getSelectList();
  if (selectList != null) {
    newContext = new Context(selectList.size()) {

      @Override
      public SqlNode field(int ordinal) {
        return field(ordinal, false);
      }

      @Override
      public SqlNode field(int ordinal, boolean useAlias) {
        final SqlNode selectItem = selectList.get(ordinal);
        switch (selectItem.getKind()) {
          case AS:
            if (useAlias) {
              return ((SqlCall) selectItem).operand(1);
            } else {
              return ((SqlCall) selectItem).operand(0);
            }
        }
        return selectItem;
      }
    };
  } else {
    newContext = new AliasContext(aliases, aliases.size() > 1);
  }
  return new Builder(rel, clauseList, select, newContext);
}
 
开发者ID:qubole,项目名称:quark,代码行数:67,代码来源:RelToSqlConverter.java

示例6: convertToSingleValueSubq

import org.apache.calcite.sql.SqlSelect; //导入方法依赖的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:apache,项目名称:kylin,代码行数:55,代码来源:SqlToRelConverter.java

示例7: builder

import org.apache.calcite.sql.SqlSelect; //导入方法依赖的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>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>When you have called
 * {@link Builder#setSelect(SqlNodeList)},
 * {@link Builder#setWhere(SqlNode)} etc. call
 * {@link Builder#result(SqlNode, Collection, RelNode, Map)}
 * to fix the new query.
 *
 * @param rel Relational expression being implemented
 * @param clauses Clauses that will be generated to implement current
 *                relational expression
 * @return A builder
 */
public Builder builder(RelNode rel, Clause... clauses) {
  final Clause maxClause = maxClause();
  boolean needNew = false;
  // If old and new clause are equal and belong to below set,
  // then new SELECT wrap is not required
  Set<Clause> nonWrapSet = ImmutableSet.of(Clause.SELECT);
  for (Clause clause : clauses) {
    if (maxClause.ordinal() > clause.ordinal()
        || (maxClause == clause && !nonWrapSet.contains(clause))) {
      needNew = true;
    }
  }
  if (rel instanceof LogicalAggregate
      && !dialect.supportsNestedAggregations()
      && hasNestedAggregations((LogicalAggregate) rel)) {
    needNew = true;
  }

  SqlSelect select;
  Expressions.FluentList<Clause> clauseList = Expressions.list();
  if (needNew) {
    select = subSelect();
  } else {
    select = asSelect();
    clauseList.addAll(this.clauses);
  }
  clauseList.appendAll(clauses);
  Context newContext;
  final SqlNodeList selectList = select.getSelectList();
  if (selectList != null) {
    newContext = new Context(selectList.size()) {
      public SqlNode field(int ordinal) {
        final SqlNode selectItem = selectList.get(ordinal);
        switch (selectItem.getKind()) {
        case AS:
          return ((SqlCall) selectItem).operand(0);
        }
        return selectItem;
      }
    };
  } else {
    boolean qualified =
        !dialect.hasImplicitTableAlias() || aliases.size() > 1;
    // basically, we did a subSelect() since needNew is set and neededAlias is not null
    // now, we need to make sure that we need to update the alias context.
    // if our aliases map has a single element:  <neededAlias, rowType>,
    // then we don't need to rewrite the alias but otherwise, it should be updated.
    if (needNew
            && neededAlias != null
            && (aliases.size() != 1 || !aliases.containsKey(neededAlias))) {
      final Map<String, RelDataType> newAliases =
          ImmutableMap.of(neededAlias, rel.getInput(0).getRowType());
      newContext = aliasContext(newAliases, qualified);
    } else {
      newContext = aliasContext(aliases, qualified);
    }
  }
  return new Builder(rel, clauseList, select, newContext,
      needNew ? null : aliases);
}
 
开发者ID:apache,项目名称:calcite,代码行数:81,代码来源:SqlImplementor.java

示例8: checkRollUpInSelectList

import org.apache.calcite.sql.SqlSelect; //导入方法依赖的package包/类
private void checkRollUpInSelectList(SqlSelect select) {
  SqlValidatorScope scope = getSelectScope(select);
  for (SqlNode item : select.getSelectList()) {
    checkRollUp(null, select, item, scope);
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:7,代码来源:SqlValidatorImpl.java


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