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


Java SqlNodeList类代码示例

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


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

示例1: testMultipleStatement

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
@Test
public void testMultipleStatement() throws Exception {
  String sql = "SET flink.enable.checkpoint=1;";
  SqlNodeList list = Planner.parse(sql);
  assertEquals(1, list.size());

  sql = "SET flink.enable.checkpoint=1;\n"
      + "SELECT * FROM foo";
  list = Planner.parse(sql);
  assertEquals(2, list.size());

  sql = "SET flink.enable.checkpoint=1;\n"
      + "SELECT * FROM foo;";
  list = Planner.parse(sql);
  assertEquals(2, list.size());
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:17,代码来源:PlannerTest.java

示例2: testSetOptions

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
@Test
public void testSetOptions() throws IOException, ParseException {
  String sql = Joiner.on(";\n").join(
      "SET spam = 1",
      "SET foo = 'bar'",
      "RESET foo",
      "ALTER SESSION SET bar = OFF"
  );
  SqlNodeList nodes = Planner.parse(sql);
  Validator validator = new Validator();
  validator.extract(nodes);
  Configuration options = validator.options();
  assertEquals(1, options.getInt("spam"));
  assertNull(options.getString("foo", null));
  assertEquals("OFF", options.getString("bar"));
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:17,代码来源:ValidatorTest.java

示例3: testCreateFunction

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
@Test
public void testCreateFunction() throws IOException, ParseException {
  String sql = Joiner.on(";\n").join(
      "CREATE FUNCTION udf AS 'foo.udf'",
      "CREATE FUNCTION udf1 AS 'foo.udf' USING JAR 'mock://foo'",
      "CREATE FUNCTION udf2 AS 'foo.udf' USING JAR 'mock://foo', JAR 'mock://bar'"
  );
  SqlNodeList nodes = Planner.parse(sql);
  Validator validator = new Validator();
  validator.extract(nodes);
  assertEquals(ImmutableList.of(
      URI.create("mock://foo"),
      URI.create("mock://foo"),
      URI.create("mock://bar")
  ), ImmutableList.copyOf(validator.additionalResources()));
}
 
开发者ID:uber,项目名称:AthenaX,代码行数:17,代码来源:ValidatorTest.java

示例4: rewrite

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
/** Rewrite the parse tree as SELECT ... FROM INFORMATION_SCHEMA.SCHEMATA ... */
@Override
public SqlNode rewrite(SqlNode sqlNode) throws RelConversionException, ForemanSetupException {
  SqlShowSchemas node = unwrap(sqlNode, SqlShowSchemas.class);
  List<SqlNode> selectList =
      ImmutableList.of((SqlNode) new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO));

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

  SqlNode where = null;
  final SqlNode likePattern = node.getLikePattern();
  if (likePattern != null) {
    where = DrillParserUtil.createCondition(new SqlIdentifier(SCHS_COL_SCHEMA_NAME, SqlParserPos.ZERO),
                                            SqlStdOperatorTable.LIKE, likePattern);
  } else if (node.getWhereClause() != null) {
    where = node.getWhereClause();
  }

  return new SqlSelect(SqlParserPos.ZERO, null, new SqlNodeList(selectList, SqlParserPos.ZERO),
      fromClause, where, null, null, null, null, null, null);
}
 
开发者ID:skhalifa,项目名称:QDrill,代码行数:23,代码来源:ShowSchemasHandler.java

示例5: SqlCreateTable

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
public SqlCreateTable(
    SqlParserPos pos,
    SqlIdentifier tblName,
    SqlNodeList fieldList,
    PartitionDistributionStrategy partitionDistributionStrategy,
    SqlNodeList partitionColumns,
    SqlNodeList formatOptions,
    SqlLiteral singleWriter,
    SqlNode query,
    SqlNodeList sortFieldList,
    SqlNodeList distributionColumns) {
  super(pos);
  this.tblName = tblName;
  this.fieldList = fieldList;
  this.partitionDistributionStrategy = partitionDistributionStrategy;
  this.partitionColumns = partitionColumns;
  this.formatOptions = formatOptions;
  this.singleWriter = singleWriter;
  this.query = query;
  this.sortColumns = sortFieldList;
  this.distributionColumns = distributionColumns;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:23,代码来源:SqlCreateTable.java

示例6: convertQueryOrInList

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
private RelNode convertQueryOrInList(
	Blackboard bb,
	SqlNode seek,
	RelDataType targetRowType) {
	// NOTE: Once we start accepting single-row queries as row constructors,
	// there will be an ambiguity here for a case like X IN ((SELECT Y FROM
	// Z)).  The SQL standard resolves the ambiguity by saying that a lone
	// select should be interpreted as a table expression, not a row
	// expression.  The semantic difference is that a table expression can
	// return multiple rows.
	if (seek instanceof SqlNodeList) {
		return convertRowValues(
			bb,
			seek,
			((SqlNodeList) seek).getList(),
			false,
			targetRowType);
	} else {
		return convertQueryRecursive(seek, false, null).project();
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:22,代码来源:SqlToRelConverter.java

示例7: gatherOrderExprs

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
/**
 * Creates a list of collations required to implement the ORDER BY clause,
 * if there is one. Populates <code>extraOrderExprs</code> with any sort
 * expressions which are not in the select clause.
 *
 * @param bb              Scope within which to resolve identifiers
 * @param select          Select clause. Never null, because we invent a
 *                        dummy SELECT if ORDER BY is applied to a set
 *                        operation (UNION etc.)
 * @param orderList       Order by clause, may be null
 * @param extraOrderExprs Sort expressions which are not in the select
 *                        clause (output)
 * @param collationList   List of collations (output)
 */
protected void gatherOrderExprs(
	Blackboard bb,
	SqlSelect select,
	SqlNodeList orderList,
	List<SqlNode> extraOrderExprs,
	List<RelFieldCollation> collationList) {
	// TODO:  add validation rules to SqlValidator also
	assert bb.root != null : "precondition: child != null";
	assert select != null;
	if (orderList == null) {
		return;
	}
	for (SqlNode orderItem : orderList) {
		collationList.add(
			convertOrderItem(
				select,
				orderItem,
				extraOrderExprs,
				RelFieldCollation.Direction.ASCENDING,
				RelFieldCollation.NullDirection.UNSPECIFIED));
	}
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:37,代码来源:SqlToRelConverter.java

示例8: 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

示例9: implement

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
public JdbcImplementor.Result implement(JdbcImplementor implementor) {
    JdbcImplementor.Result x = implementor.visitChild(0, getInput());
    final JdbcImplementor.Builder builder =
            program.getCondition() != null
                    ? x.builder(this, JdbcImplementor.Clause.FROM,
                    JdbcImplementor.Clause.WHERE)
                    : x.builder(this, JdbcImplementor.Clause.FROM);
    if (!isStar(program)) {
        final List<SqlNode> selectList = new ArrayList<>();
        for (RexLocalRef ref : program.getProjectList()) {
            SqlNode sqlExpr = builder.getContext().toSql(program, ref);
            addSelect(selectList, sqlExpr, getRowType());
        }
        builder.setSelect(new SqlNodeList(selectList, POS));
    }
    if (program.getCondition() != null) {
        builder.setWhere(
                builder.getContext().toSql(program, program.getCondition()));
    }
    return builder.result();
}
 
开发者ID:bitnine-oss,项目名称:octopus,代码行数:22,代码来源:JdbcRules.java

示例10: setOperand

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
@Override public void setOperand(int i, SqlNode operand) {

    switch (i) {
      case 0:
        targetColumnList = (SqlNodeList) operand;
        break;
      case 1:
        sourceExpressionList = (SqlNodeList) operand;
        break;
      case 2:
        identifier = (SqlIdentifier) operand;
        break;
      default:
        throw new AssertionError(i);
    }
  }
 
开发者ID:qubole,项目名称:quark,代码行数:17,代码来源:SqlAlterQuark.java

示例11: visitCalc

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
public Result visitCalc(Calc e) {
  Result x = visitChild(0, e.getInput());
  final RexProgram program = e.getProgram();
  Builder builder =
      program.getCondition() != null
          ? x.builder(e, Clause.WHERE)
          : x.builder(e);
  if (!isStar(program)) {
    final List<SqlNode> selectList = new ArrayList<>();
    for (RexLocalRef ref : program.getProjectList()) {
      SqlNode sqlExpr = builder.context.toSql(program, ref);
      addSelect(selectList, sqlExpr, e.getRowType());
    }
    builder.setSelect(new SqlNodeList(selectList, POS));
  }

  if (program.getCondition() != null) {
    builder.setWhere(
        builder.context.toSql(program, program.getCondition()));
  }
  return builder.result();
}
 
开发者ID:qubole,项目名称:quark,代码行数:23,代码来源:RelToSqlConverter.java

示例12: convertQueryOrInList

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
private RelNode convertQueryOrInList(
    Blackboard bb,
    SqlNode seek,
    RelDataType targetRowType) {
  // NOTE: Once we start accepting single-row queries as row constructors,
  // there will be an ambiguity here for a case like X IN ((SELECT Y FROM
  // Z)).  The SQL standard resolves the ambiguity by saying that a lone
  // select should be interpreted as a table expression, not a row
  // expression.  The semantic difference is that a table expression can
  // return multiple rows.
  if (seek instanceof SqlNodeList) {
    return convertRowValues(
        bb,
        seek,
        ((SqlNodeList) seek).getList(),
        false,
        targetRowType);
  } else {
    return convertQueryRecursive(seek, false, null).project();
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:SqlToRelConverter.java

示例13: gatherOrderExprs

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
/**
 * Creates a list of collations required to implement the ORDER BY clause,
 * if there is one. Populates <code>extraOrderExprs</code> with any sort
 * expressions which are not in the select clause.
 *
 * @param bb              Scope within which to resolve identifiers
 * @param select          Select clause. Never null, because we invent a
 *                        dummy SELECT if ORDER BY is applied to a set
 *                        operation (UNION etc.)
 * @param orderList       Order by clause, may be null
 * @param extraOrderExprs Sort expressions which are not in the select
 *                        clause (output)
 * @param collationList   List of collations (output)
 */
protected void gatherOrderExprs(
    Blackboard bb,
    SqlSelect select,
    SqlNodeList orderList,
    List<SqlNode> extraOrderExprs,
    List<RelFieldCollation> collationList) {
  // TODO:  add validation rules to SqlValidator also
  assert bb.root != null : "precondition: child != null";
  assert select != null;
  if (orderList == null) {
    return;
  }
  for (SqlNode orderItem : orderList) {
    collationList.add(
        convertOrderItem(
            select,
            orderItem,
            extraOrderExprs,
            RelFieldCollation.Direction.ASCENDING,
            RelFieldCollation.NullDirection.UNSPECIFIED));
  }
}
 
开发者ID:apache,项目名称:kylin,代码行数:37,代码来源:SqlToRelConverter.java

示例14: 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

示例15: renameColumns

import org.apache.calcite.sql.SqlNodeList; //导入依赖的package包/类
/** Wraps a query to rename its columns. Used by CREATE VIEW and CREATE
 * MATERIALIZED VIEW. */
static SqlNode renameColumns(SqlNodeList columnList, SqlNode query) {
  if (columnList == null) {
    return query;
  }
  final SqlParserPos p = query.getParserPosition();
  final SqlNodeList selectList =
      new SqlNodeList(ImmutableList.<SqlNode>of(SqlIdentifier.star(p)), p);
  final SqlCall from =
      SqlStdOperatorTable.AS.createCall(p,
          ImmutableList.<SqlNode>builder()
              .add(query)
              .add(new SqlIdentifier("_", p))
              .addAll(columnList)
              .build());
  return new SqlSelect(p, null, selectList, from, null, null, null, null,
      null, null, null);
}
 
开发者ID:apache,项目名称:calcite,代码行数:20,代码来源:SqlDdlNodes.java


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