All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.calcite.rex.RexRangeRef Maven / Gradle / Ivy

There is a newer version: 1.17.0-flink-r3
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to you under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.calcite.rex;

import org.apache.calcite.rel.type.RelDataType;

/**
 * Reference to a range of columns.
 *
 * 

This construct is used only during the process of translating a * {@link org.apache.calcite.sql.SqlNode SQL} tree to a * {@link org.apache.calcite.rel.RelNode rel}/{@link RexNode rex} * tree. Regular {@link RexNode rex} trees do not contain this * construct.

* *

While translating a join of EMP(EMPNO, ENAME, DEPTNO) to DEPT(DEPTNO2, * DNAME) we create RexRangeRef(DeptType,3) to represent the pair * of columns (DEPTNO2, DNAME) which came from DEPT. The type has 2 columns, and * therefore the range represents columns {3, 4} of the input.

* *

Suppose we later create a reference to the DNAME field of this * RexRangeRef; it will return a {@link RexInputRef}(5,Integer), * and the {@link org.apache.calcite.rex.RexRangeRef} will disappear.

*/ public class RexRangeRef extends RexNode { //~ Instance fields -------------------------------------------------------- private final RelDataType type; private final int offset; //~ Constructors ----------------------------------------------------------- /** * Creates a range reference. * * @param rangeType Type of the record returned * @param offset Offset of the first column within the input record */ RexRangeRef( RelDataType rangeType, int offset) { this.type = rangeType; this.offset = offset; } //~ Methods ---------------------------------------------------------------- public RelDataType getType() { return type; } public int getOffset() { return offset; } public R accept(RexVisitor visitor) { return visitor.visitRangeRef(this); } public R accept(RexBiVisitor visitor, P arg) { return visitor.visitRangeRef(this, arg); } } // End RexRangeRef.java




© 2015 - 2024 Weber Informatics LLC | Privacy Policy