Java Code Examples for org.apache.calcite.sql.SqlNode#clone()

The following examples show how to use org.apache.calcite.sql.SqlNode#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlValidatorImpl.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the <code>ordinal</code>th item in the select list.
 */
private SqlNode nthSelectItem(int ordinal, final SqlParserPos pos) {
	// TODO: Don't expand the list every time. Maybe keep an expanded
	// version of each expression -- select lists and identifiers -- in
	// the validator.

	SqlNodeList expandedSelectList =
		expandStar(
			select.getSelectList(),
			select,
			false);
	SqlNode expr = expandedSelectList.get(ordinal);
	expr = stripAs(expr);
	if (expr instanceof SqlIdentifier) {
		expr = getScope().fullyQualify((SqlIdentifier) expr).identifier;
	}

	// Create a copy of the expression with the position of the order
	// item.
	return expr.clone(pos);
}
 
Example 2
Source File: SqlValidatorImpl.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the <code>ordinal</code>th item in the select list.
 */
private SqlNode nthSelectItem(int ordinal, final SqlParserPos pos) {
	// TODO: Don't expand the list every time. Maybe keep an expanded
	// version of each expression -- select lists and identifiers -- in
	// the validator.

	SqlNodeList expandedSelectList =
		expandStar(
			select.getSelectList(),
			select,
			false);
	SqlNode expr = expandedSelectList.get(ordinal);
	expr = stripAs(expr);
	if (expr instanceof SqlIdentifier) {
		expr = getScope().fullyQualify((SqlIdentifier) expr).identifier;
	}

	// Create a copy of the expression with the position of the order
	// item.
	return expr.clone(pos);
}
 
Example 3
Source File: RelToSqlConverter.java    From calcite with Apache License 2.0 5 votes vote down vote up
@Override public SqlNode visit(SqlIdentifier id) {
  if (tableAlias.equals(id.names.get(0))) {
    int index = tableType.getField(
        id.names.get(1), false, false).getIndex();
    SqlNode selectItem = replaceSource.get(index);
    if (selectItem.getKind() == SqlKind.AS) {
      selectItem = ((SqlCall) selectItem).operand(0);
    }
    return selectItem.clone(id.getParserPosition());
  }
  return id;
}
 
Example 4
Source File: SqlValidatorUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlLiteral literal) {
  return SqlNode.clone(literal);
}
 
Example 5
Source File: SqlValidatorUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlDataTypeSpec type) {
  return SqlNode.clone(type);
}
 
Example 6
Source File: SqlValidatorUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlDynamicParam param) {
  return SqlNode.clone(param);
}
 
Example 7
Source File: SqlValidatorUtil.java    From Bats with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlIntervalQualifier intervalQualifier) {
  return SqlNode.clone(intervalQualifier);
}
 
Example 8
Source File: SqlValidatorUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlLiteral literal) {
  return SqlNode.clone(literal);
}
 
Example 9
Source File: SqlValidatorUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlDataTypeSpec type) {
  return SqlNode.clone(type);
}
 
Example 10
Source File: SqlValidatorUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlDynamicParam param) {
  return SqlNode.clone(param);
}
 
Example 11
Source File: SqlValidatorUtil.java    From calcite with Apache License 2.0 4 votes vote down vote up
public SqlNode visit(SqlIntervalQualifier intervalQualifier) {
  return SqlNode.clone(intervalQualifier);
}