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


Java Util.skipLast方法代码示例

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


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

示例1: isValidSchema

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/**
 * check if the schema provided is a valid schema:
 * <li>schema is not indicated (only one element in the names list)<li/>
 *
 * @param names             list of schema and table names, table name is always the last element
 * @return throws a userexception if the schema is not valid.
 */
private void isValidSchema(final List<String> names) throws UserException {
  SchemaPlus defaultSchema = session.getDefaultSchema(this.rootSchema);
  String defaultSchemaCombinedPath = SchemaUtilites.getSchemaPath(defaultSchema);
  List<String> schemaPath = Util.skipLast(names);
  String schemaPathCombined = SchemaUtilites.getSchemaPath(schemaPath);
  String commonPrefix = SchemaUtilites.getPrefixSchemaPath(defaultSchemaCombinedPath,
          schemaPathCombined,
          parserConfig.caseSensitive());
  boolean isPrefixDefaultPath = commonPrefix.length() == defaultSchemaCombinedPath.length();
  List<String> fullSchemaPath = Strings.isNullOrEmpty(defaultSchemaCombinedPath) ? schemaPath :
          isPrefixDefaultPath ? schemaPath : ListUtils.union(SchemaUtilites.getSchemaPathAsList(defaultSchema), schemaPath);
  if (names.size() > 1 && (SchemaUtilites.findSchema(this.rootSchema, fullSchemaPath) == null &&
          SchemaUtilites.findSchema(this.rootSchema, schemaPath) == null)) {
    SchemaUtilites.throwSchemaNotFoundException(defaultSchema, schemaPath);
  }
}
 
开发者ID:axbaretto,项目名称:drill,代码行数:24,代码来源:SqlConverter.java

示例2: createLeftCall

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
private SqlNode createLeftCall(SqlOperator op, List<SqlNode> nodeList) {
    if (nodeList.size() == 2) {
        return op.createCall(new SqlNodeList(nodeList, POS));
    }
    final List<SqlNode> butLast = Util.skipLast(nodeList);
    final SqlNode last = nodeList.get(nodeList.size() - 1);
    final SqlNode call = createLeftCall(op, butLast);
    return op.createCall(new SqlNodeList(ImmutableList.of(call, last), POS));
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:10,代码来源:JdbcImplementor.java

示例3: createLeftCall

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
private SqlNode createLeftCall(SqlOperator op, List<SqlNode> nodeList) {
  if (nodeList.size() == 2) {
    return op.createCall(new SqlNodeList(nodeList, POS));
  }
  final List<SqlNode> butLast = Util.skipLast(nodeList);
  final SqlNode last = nodeList.get(nodeList.size() - 1);
  final SqlNode call = createLeftCall(op, butLast);
  return op.createCall(new SqlNodeList(ImmutableList.of(call, last), POS));
}
 
开发者ID:qubole,项目名称:quark,代码行数:10,代码来源:RelToSqlConverter.java

示例4: getSchemaObjectMonikers

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
public static void getSchemaObjectMonikers(
    SqlValidatorCatalogReader catalogReader,
    List<String> names,
    List<SqlMoniker> hints) {
  // Assume that the last name is 'dummy' or similar.
  List<String> subNames = Util.skipLast(names);

  // Try successively with catalog.schema, catalog and no prefix
  for (List<String> x : catalogReader.getSchemaPaths()) {
    final List<String> names2 =
        ImmutableList.<String>builder().addAll(x).addAll(subNames).build();
    hints.addAll(catalogReader.getAllSchemaObjectNames(names2));
  }
}
 
开发者ID:apache,项目名称:calcite,代码行数:15,代码来源:SqlValidatorUtil.java

示例5: rewrite

import org.apache.calcite.util.Util; //导入方法依赖的package包/类
/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.COLUMNS ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
  SqlDescribeTable node = unwrap(sqlNode, SqlDescribeTable.class);

  try {
    List<SqlNode> selectList =
        ImmutableList.of((SqlNode) new SqlIdentifier(COLS_COL_COLUMN_NAME, SqlParserPos.ZERO),
                                   new SqlIdentifier(COLS_COL_DATA_TYPE, SqlParserPos.ZERO),
                                   new SqlIdentifier(COLS_COL_IS_NULLABLE, SqlParserPos.ZERO));

    SqlNode fromClause = new SqlIdentifier(
        ImmutableList.of(IS_SCHEMA_NAME, TAB_COLUMNS), null, SqlParserPos.ZERO, null);

    final SqlIdentifier table = node.getTable();
    final SchemaPlus defaultSchema = context.getNewDefaultSchema();
    final List<String> schemaPathGivenInCmd = Util.skipLast(table.names);
    final SchemaPlus schema = SchemaUtilites.findSchema(defaultSchema, schemaPathGivenInCmd);

    if (schema == null) {
      SchemaUtilites.throwSchemaNotFoundException(defaultSchema,
          SchemaUtilites.SCHEMA_PATH_JOINER.join(schemaPathGivenInCmd));
    }

    if (SchemaUtilites.isRootSchema(schema)) {
      throw UserException.validationError()
          .message("No schema selected.")
          .build(logger);
    }

    final String tableName = Util.last(table.names);

    // find resolved schema path
    final String schemaPath = SchemaUtilites.unwrapAsDrillSchemaInstance(schema).getFullSchemaName();

    if (schema.getTable(tableName) == null) {
      throw UserException.validationError()
          .message("Unknown table [%s] in schema [%s]", tableName, schemaPath)
          .build(logger);
    }

    SqlNode schemaCondition = null;
    if (!SchemaUtilites.isRootSchema(schema)) {
      schemaCondition = DrillParserUtil.createCondition(
          new SqlIdentifier(SHRD_COL_TABLE_SCHEMA, SqlParserPos.ZERO),
          SqlStdOperatorTable.EQUALS,
          SqlLiteral.createCharString(schemaPath, CHARSET, SqlParserPos.ZERO)
      );
    }

    SqlNode where = DrillParserUtil.createCondition(
        new SqlIdentifier(SHRD_COL_TABLE_NAME, SqlParserPos.ZERO),
        SqlStdOperatorTable.EQUALS,
        SqlLiteral.createCharString(tableName, CHARSET, SqlParserPos.ZERO));

    where = DrillParserUtil.createCondition(schemaCondition, SqlStdOperatorTable.AND, where);

    SqlNode columnFilter = null;
    if (node.getColumn() != null) {
      columnFilter =
          DrillParserUtil.createCondition(
              new SqlIdentifier(COLS_COL_COLUMN_NAME, SqlParserPos.ZERO),
              SqlStdOperatorTable.EQUALS,
              SqlLiteral.createCharString(node.getColumn().toString(), CHARSET, SqlParserPos.ZERO));
    } else if (node.getColumnQualifier() != null) {
      columnFilter =
          DrillParserUtil.createCondition(
              new SqlIdentifier(COLS_COL_COLUMN_NAME, SqlParserPos.ZERO),
              SqlStdOperatorTable.LIKE, node.getColumnQualifier());
    }

    where = DrillParserUtil.createCondition(where, SqlStdOperatorTable.AND, columnFilter);

    return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
        fromClause, where, null, null, null, null, null, null);
  } catch (Exception ex) {
    throw UserException.planError(ex)
        .message("Error while rewriting DESCRIBE query: %d", ex.getMessage())
        .build(logger);
  }
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:82,代码来源:DescribeTableHandler.java


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