org.apache.calcite.util.Util.last()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中org.apache.calcite.util.Util.last()方法的一些代码示例,展示了Util.last()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.last()方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:last

Util.last介绍

[英]Returns the last element of a list.
[中]返回列表的最后一个元素。

代码示例

代码示例来源:origin: apache/hive

private static String deriveAlias(RelNode rel) {
 if (rel instanceof TableScan) {
  final List<String> names = rel.getTable().getQualifiedName();
  if (!names.isEmpty()) {
   return Util.last(names);
  }
 }
 return null;
}

代码示例来源:origin: apache/flink

private Pair<String, String> findTableColumnPair(SqlIdentifier identifier,
  SqlValidatorScope scope) {
  SqlCall call = SqlUtil.makeCall(getOperatorTable(), identifier);
  if (call != null) {
    return null;
  }
  SqlQualified qualified = scope.fullyQualify(identifier);
  List<String> names = qualified.identifier.names;
  if (names.size() < 2) {
    return null;
  }
  return new Pair<>(names.get(names.size() - 2), Util.last(names));
}

代码示例来源:origin: apache/drill

private static String deriveAlias(RelNode rel) {
 if (rel instanceof TableScan) {
  final List<String> names = rel.getTable().getQualifiedName();
  if (!names.isEmpty()) {
   return Util.last(names);
  }
 }
 return null;
}

代码示例来源:origin: apache/flink

private void checkRollUpInUsing(SqlIdentifier identifier, SqlNode leftOrRight) {
  leftOrRight = stripAs(leftOrRight);
  // if it's not a SqlIdentifier then that's fine, it'll be validated somewhere else.
  if (leftOrRight instanceof SqlIdentifier) {
    SqlIdentifier from = (SqlIdentifier) leftOrRight;
    Table table = findTable(catalogReader.getRootSchema(), Util.last(from.names),
      catalogReader.nameMatcher().isCaseSensitive());
    String name = Util.last(identifier.names);
    if (table != null && table.isRolledUp(name)) {
      throw newValidationError(identifier, RESOURCE.rolledUpNotAllowed(name, "USING"));
    }
  }
}

代码示例来源:origin: apache/flink

if (DynamicRecordType.isDynamicStarColName(Util.last(fqId.names))
  && !DynamicRecordType.isDynamicStarColName(Util.last(id.names))) {
  SqlNode[] inputs = new SqlNode[2];
  inputs[0] = fqId;
  inputs[1] = SqlLiteral.createCharString(
    Util.last(id.names),
    id.getParserPosition());
  SqlBasicCall item_call = new SqlBasicCall(

代码示例来源:origin: apache/flink

new ValidationError(sourceValue,
    RESOURCE.viewConstraintNotSatisfied(colName,
      Util.last(validatorTable.getQualifiedName())));
RelOptUtil.validateValueAgainstConstraint(sourceValue,
  projectMap.get(colIndex), validationError);

代码示例来源:origin: apache/flink

new ValidationError(column.right,
    RESOURCE.viewConstraintNotSatisfied(columnName,
      Util.last(validatorTable.getQualifiedName())));
RelOptUtil.validateValueAgainstConstraint(column.right,
  columnConstraint, validationError);

代码示例来源:origin: apache/drill

public void onMatch(RelOptRuleCall call) {
  final Filter filter = call.rel(0);
  final Project project = call.rel(1);
  final List<RexNode> newProjects = new ArrayList<>(project.getProjects());
  newProjects.add(filter.getCondition());
  final RelOptCluster cluster = filter.getCluster();
  RelDataType newRowType =
    cluster.getTypeFactory().builder()
      .addAll(project.getRowType().getFieldList())
      .add("condition", Util.last(newProjects).getType())
      .build();
  final RelNode newProject =
    project.copy(project.getTraitSet(),
      project.getInput(),
      newProjects,
      newRowType);
  final RexInputRef newCondition =
    cluster.getRexBuilder().makeInputRef(newProject,
      newProjects.size() - 1);
  call.transformTo(filter.copy(filter.getTraitSet(), newProject, newCondition));
 }
}

代码示例来源:origin: Qihoo360/Quicksql

/**
 * Returns whether this identifier is a star, such as "*" or "foo.bar.*".
 */
public boolean isStar() {
 return Util.last(names).equals("");
}

代码示例来源:origin: Qihoo360/Quicksql

public SqlUserDefinedTableMacro(SqlIdentifier opName,
  SqlReturnTypeInference returnTypeInference,
  SqlOperandTypeInference operandTypeInference,
  SqlOperandTypeChecker operandTypeChecker, List<RelDataType> paramTypes,
  TableMacro tableMacro) {
 super(Util.last(opName.names), opName, SqlKind.OTHER_FUNCTION,
   returnTypeInference, operandTypeInference, operandTypeChecker,
   Objects.requireNonNull(paramTypes),
   SqlFunctionCategory.USER_DEFINED_TABLE_FUNCTION);
 this.tableMacro = tableMacro;
}

代码示例来源:origin: org.apache.calcite/calcite-core

@Override public Table extend(final List<RelDataTypeField> fields) {
 return new ModifiableTable(Util.last(names)) {
  @Override public RelDataType getRowType(RelDataTypeFactory typeFactory) {
   ImmutableList<RelDataTypeField> allFields = ImmutableList.copyOf(
     Iterables.concat(
       ModifiableTable.this.getRowType(typeFactory).getFieldList(),
       fields));
   return typeFactory.createStructType(allFields);
  }
 };
}

代码示例来源:origin: org.apache.calcite/calcite-core

/** Creates a call that concatenates patterns;
 * for use in {@link #match}. */
public RexNode patternConcat(Iterable<? extends RexNode> nodes) {
 final ImmutableList<RexNode> list = ImmutableList.copyOf(nodes);
 if (list.size() > 2) {
  // Convert into binary calls
  return patternConcat(patternConcat(Util.skipLast(list)), Util.last(list));
 }
 final RelDataType t = getTypeFactory().createSqlType(SqlTypeName.NULL);
 return getRexBuilder().makeCall(t, SqlStdOperatorTable.PATTERN_CONCAT,
   list);
}

代码示例来源:origin: Qihoo360/Quicksql

public static MySchemaPlus create(Path path) {
 final Pair<String, Schema> pair = Util.last(path);
 final SchemaPlus parent;
 if (path.size() == 1) {
  parent = null;
 } else {
  parent = create(path.parent());
 }
 return new MySchemaPlus(parent, pair.left, pair.right);
}

代码示例来源:origin: org.apache.calcite/calcite-core

private void registerTable(final List<String> names, final Table table) {
 assert names.get(0).equals(DEFAULT_CATALOG);
 final List<String> schemaPath = Util.skipLast(names);
 final String tableName = Util.last(names);
 final CalciteSchema schema = SqlValidatorUtil.getSchema(rootSchema,
   schemaPath, SqlNameMatchers.withCaseSensitive(true));
 schema.add(tableName, table);
}

代码示例来源:origin: Qihoo360/Quicksql

protected RelDataType validateImpl(RelDataType targetRowType) {
 for (SqlNode withItem : with.withList) {
  validator.validateWithItem((SqlWithItem) withItem);
 }
 final SqlValidatorScope scope2 =
   validator.getWithScope(Util.last(with.withList.getList()));
 validator.validateQuery(with.body, scope2, targetRowType);
 final RelDataType rowType = validator.getValidatedNodeType(with.body);
 validator.setValidatedNodeType(with, rowType);
 return rowType;
}

代码示例来源:origin: Qihoo360/Quicksql

private void registerTable(final List<String> names, final Table table) {
  assert names.get(0).equals(DEFAULT_CATALOG);
  final List<String> schemaPath = Util.skipLast(names);
  final String tableName = Util.last(names);
  final CalciteSchema schema = SqlValidatorUtil.getSchema(rootSchema,
      schemaPath, SqlNameMatchers.withCaseSensitive(true));
  schema.add(tableName, table);
}

代码示例来源:origin: Qihoo360/Quicksql

public static RelOptTableImpl create(RelOptSchema schema, RelDataType rowType,
  Table table, Path path) {
 final SchemaPlus schemaPlus = MySchemaPlus.create(path);
 return new RelOptTableImpl(schema, rowType, Pair.left(path), table,
   getClassExpressionFunction(schemaPlus, Util.last(path).left, table),
   table.getStatistic().getRowCount());
}

代码示例来源:origin: Qihoo360/Quicksql

@Override public RelDataType deriveRowType() {
  return getCluster().getTypeFactory().createStructType(
    Pair.right(Util.last(rels).getRowType().getFieldList()),
    getQuerySpec().fieldNames);
}

代码示例来源:origin: org.apache.calcite/calcite-core

protected RelDataType validateImpl(RelDataType targetRowType) {
 final RelDataTypeFactory.Builder builder =
   validator.getTypeFactory().builder();
 for (SqlMoniker moniker
   : validator.catalogReader.getAllSchemaObjectNames(names)) {
  final List<String> names1 = moniker.getFullyQualifiedNames();
  final SqlValidatorTable table = validator.catalogReader.getTable(names1);
  builder.add(Util.last(names1), table.getRowType());
 }
 return builder.build();
}

代码示例来源:origin: Qihoo360/Quicksql

protected RelDataType validateImpl(RelDataType targetRowType) {
 final RelDataTypeFactory.Builder builder =
   validator.getTypeFactory().builder();
 for (SqlMoniker moniker
   : validator.catalogReader.getAllSchemaObjectNames(names)) {
  final List<String> names1 = moniker.getFullyQualifiedNames();
  final SqlValidatorTable table = validator.catalogReader.getTable(names1);
  builder.add(Util.last(names1), table.getRowType());
 }
 return builder.build();
}

相关文章