本文整理了Java中org.apache.calcite.plan.RelOptUtil.eq
方法的一些代码示例,展示了RelOptUtil.eq
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。RelOptUtil.eq
方法的具体详情如下:
包路径:org.apache.calcite.plan.RelOptUtil
类名称:RelOptUtil
方法名:eq
[英]Returns whether two types are equal using '='.
[中]使用“=”返回两种类型是否相等。
代码示例来源:origin: Qihoo360/Quicksql
public RexNode visitInputRef(RexInputRef input) {
// This expression refers to the Nth project column. Lookup that
// column and find out what common sub-expression IT refers to.
final int index = input.getIndex();
final RexLocalRef local = projectRefList.get(index);
assert RelOptUtil.eq(
"type1",
local.getType(),
"type2",
input.getType(),
Litmus.THROW);
return local;
}
代码示例来源:origin: org.apache.calcite/calcite-core
public RexNode visitInputRef(RexInputRef input) {
// This expression refers to the Nth project column. Lookup that
// column and find out what common sub-expression IT refers to.
final int index = input.getIndex();
final RexLocalRef local = projectRefList.get(index);
assert RelOptUtil.eq(
"type1",
local.getType(),
"type2",
input.getType(),
Litmus.THROW);
return local;
}
代码示例来源:origin: org.apache.calcite/calcite-core
public RexNode visitOver(RexOver over) {
// Look up the aggCall which this expr was translated to.
final Window.RexWinAggCall aggCall =
aggMap.get(origToNewOver.get(over));
assert aggCall != null;
assert RelOptUtil.eq(
"over",
over.getType(),
"aggCall",
aggCall.getType(),
Litmus.THROW);
// Find the index of the aggCall among all partitions of all
// groups.
final int aggCallIndex =
flattenedAggCallList.indexOf(aggCall);
assert aggCallIndex >= 0;
// Replace expression with a reference to the window slot.
final int index = inputFieldCount + aggCallIndex;
assert RelOptUtil.eq(
"over",
over.getType(),
"intermed",
intermediateRowType.getFieldList().get(index).getType(),
Litmus.THROW);
return new RexInputRef(
index,
over.getType());
}
代码示例来源:origin: Qihoo360/Quicksql
assert index < exprList.size()
: "index=" + index + ", exprList=" + exprList;
assert RelOptUtil.eq(
"expr type",
exprList.get(index).getType(),
代码示例来源:origin: org.apache.calcite/calcite-core
assert index < exprList.size()
: "index=" + index + ", exprList=" + exprList;
assert RelOptUtil.eq(
"expr type",
exprList.get(index).getType(),
代码示例来源:origin: Qihoo360/Quicksql
public RexNode visitOver(RexOver over) {
// Look up the aggCall which this expr was translated to.
final Window.RexWinAggCall aggCall =
aggMap.get(origToNewOver.get(over));
assert aggCall != null;
assert RelOptUtil.eq(
"over",
over.getType(),
"aggCall",
aggCall.getType(),
Litmus.THROW);
// Find the index of the aggCall among all partitions of all
// groups.
final int aggCallIndex =
flattenedAggCallList.indexOf(aggCall);
assert aggCallIndex >= 0;
// Replace expression with a reference to the window slot.
final int index = inputFieldCount + aggCallIndex;
assert RelOptUtil.eq(
"over",
over.getType(),
"intermed",
intermediateRowType.getFieldList().get(index).getType(),
Litmus.THROW);
return new RexInputRef(
index,
over.getType());
}
代码示例来源:origin: org.apache.calcite/calcite-core
/** Overrides {@link RexChecker} method, because {@link RexLocalRef} is
* is illegal in most rex expressions, but legal in a program. */
@Override public Boolean visitLocalRef(RexLocalRef localRef) {
final int index = localRef.getIndex();
if ((index < 0) || (index >= internalExprTypeList.size())) {
++failCount;
return litmus.fail(null);
}
if (!RelOptUtil.eq(
"type1",
localRef.getType(),
"type2",
internalExprTypeList.get(index), litmus)) {
++failCount;
return litmus.fail(null);
}
return litmus.succeed();
}
}
代码示例来源:origin: Qihoo360/Quicksql
/**
* Returns whether the type of an array of expressions is compatible with a
* struct type.
*
* @param exprs Array of expressions
* @param type Type
* @param litmus What to do if an error is detected (there is a mismatch)
*
* @return Whether every expression has the same type as the corresponding
* member of the struct type
*
* @see RelOptUtil#eq(String, RelDataType, String, RelDataType, org.apache.calcite.util.Litmus)
*/
public static boolean compatibleTypes(
List<RexNode> exprs,
RelDataType type,
Litmus litmus) {
final List<RelDataTypeField> fields = type.getFieldList();
if (exprs.size() != fields.size()) {
return litmus.fail("rowtype mismatches expressions");
}
for (int i = 0; i < fields.size(); i++) {
final RelDataType exprType = exprs.get(i).getType();
final RelDataType fieldType = fields.get(i).getType();
if (!RelOptUtil.eq("type1", exprType, "type2", fieldType, litmus)) {
return litmus.fail(null);
}
}
return litmus.succeed();
}
代码示例来源:origin: Qihoo360/Quicksql
@Override public Boolean visitInputRef(RexInputRef ref) {
final int index = ref.getIndex();
if ((index < 0) || (index >= inputTypeList.size())) {
++failCount;
return litmus.fail("RexInputRef index {} out of range 0..{}",
index, inputTypeList.size() - 1);
}
if (!ref.getType().isStruct()
&& !RelOptUtil.eq("ref", ref.getType(), "input",
inputTypeList.get(index), litmus)) {
++failCount;
return litmus.fail(null);
}
return litmus.succeed();
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Override public Boolean visitInputRef(RexInputRef ref) {
final int index = ref.getIndex();
if ((index < 0) || (index >= inputTypeList.size())) {
++failCount;
return litmus.fail("RexInputRef index {} out of range 0..{}",
index, inputTypeList.size() - 1);
}
if (!ref.getType().isStruct()
&& !RelOptUtil.eq("ref", ref.getType(), "input",
inputTypeList.get(index), litmus)) {
++failCount;
return litmus.fail(null);
}
return litmus.succeed();
}
代码示例来源:origin: Qihoo360/Quicksql
/** Overrides {@link RexChecker} method, because {@link RexLocalRef} is
* is illegal in most rex expressions, but legal in a program. */
@Override public Boolean visitLocalRef(RexLocalRef localRef) {
final int index = localRef.getIndex();
if ((index < 0) || (index >= internalExprTypeList.size())) {
++failCount;
return litmus.fail(null);
}
if (!RelOptUtil.eq(
"type1",
localRef.getType(),
"type2",
internalExprTypeList.get(index), litmus)) {
++failCount;
return litmus.fail(null);
}
return litmus.succeed();
}
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Returns whether the type of an array of expressions is compatible with a
* struct type.
*
* @param exprs Array of expressions
* @param type Type
* @param litmus What to do if an error is detected (there is a mismatch)
*
* @return Whether every expression has the same type as the corresponding
* member of the struct type
*
* @see RelOptUtil#eq(String, RelDataType, String, RelDataType, org.apache.calcite.util.Litmus)
*/
public static boolean compatibleTypes(
List<RexNode> exprs,
RelDataType type,
Litmus litmus) {
final List<RelDataTypeField> fields = type.getFieldList();
if (exprs.size() != fields.size()) {
return litmus.fail("rowtype mismatches expressions");
}
for (int i = 0; i < fields.size(); i++) {
final RelDataType exprType = exprs.get(i).getType();
final RelDataType fieldType = fields.get(i).getType();
if (!RelOptUtil.eq("type1", exprType, "type2", fieldType, litmus)) {
return litmus.fail(null);
}
}
return litmus.succeed();
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Returns whether the inferred type of an {@link AggregateCall} matches the
* type it was given when it was created.
*
* @param aggCall Aggregate call
* @param litmus What to do if an error is detected (types do not match)
* @return Whether the inferred and declared types match
*/
private boolean typeMatchesInferred(
final AggregateCall aggCall,
final Litmus litmus) {
SqlAggFunction aggFunction = aggCall.getAggregation();
AggCallBinding callBinding = aggCall.createBinding(this);
RelDataType type = aggFunction.inferReturnType(callBinding);
RelDataType expectedType = aggCall.type;
return RelOptUtil.eq("aggCall type",
expectedType,
"inferred type",
type,
litmus);
}
代码示例来源:origin: Qihoo360/Quicksql
/**
* Returns whether the inferred type of an {@link AggregateCall} matches the
* type it was given when it was created.
*
* @param aggCall Aggregate call
* @param litmus What to do if an error is detected (types do not match)
* @return Whether the inferred and declared types match
*/
private boolean typeMatchesInferred(
final AggregateCall aggCall,
final Litmus litmus) {
SqlAggFunction aggFunction = aggCall.getAggregation();
AggCallBinding callBinding = aggCall.createBinding(this);
RelDataType type = aggFunction.inferReturnType(callBinding);
RelDataType expectedType = aggCall.type;
return RelOptUtil.eq("aggCall type",
expectedType,
"inferred type",
type,
litmus);
}
代码示例来源:origin: Qihoo360/Quicksql
/**
* Returns whether the leading edge of a given array of expressions is
* wholly {@link RexInputRef} objects with types corresponding to the
* underlying datatype.
*/
public static boolean containIdentity(
List<? extends RexNode> exprs,
RelDataType rowType,
Litmus litmus) {
final List<RelDataTypeField> fields = rowType.getFieldList();
if (exprs.size() < fields.size()) {
return litmus.fail("exprs/rowType length mismatch");
}
for (int i = 0; i < fields.size(); i++) {
if (!(exprs.get(i) instanceof RexInputRef)) {
return litmus.fail("expr[{}] is not a RexInputRef", i);
}
RexInputRef inputRef = (RexInputRef) exprs.get(i);
if (inputRef.getIndex() != i) {
return litmus.fail("expr[{}] has ordinal {}", i, inputRef.getIndex());
}
if (!RelOptUtil.eq("type1",
exprs.get(i).getType(),
"type2",
fields.get(i).getType(), litmus)) {
return litmus.fail(null);
}
}
return litmus.succeed();
}
代码示例来源:origin: org.apache.calcite/calcite-core
/**
* Returns whether the leading edge of a given array of expressions is
* wholly {@link RexInputRef} objects with types corresponding to the
* underlying datatype.
*/
public static boolean containIdentity(
List<? extends RexNode> exprs,
RelDataType rowType,
Litmus litmus) {
final List<RelDataTypeField> fields = rowType.getFieldList();
if (exprs.size() < fields.size()) {
return litmus.fail("exprs/rowType length mismatch");
}
for (int i = 0; i < fields.size(); i++) {
if (!(exprs.get(i) instanceof RexInputRef)) {
return litmus.fail("expr[{}] is not a RexInputRef", i);
}
RexInputRef inputRef = (RexInputRef) exprs.get(i);
if (inputRef.getIndex() != i) {
return litmus.fail("expr[{}] has ordinal {}", i, inputRef.getIndex());
}
if (!RelOptUtil.eq("type1",
exprs.get(i).getType(),
"type2",
fields.get(i).getType(), litmus)) {
return litmus.fail(null);
}
}
return litmus.succeed();
}
代码示例来源:origin: org.apache.calcite/calcite-core
public RexNode visitInputRef(RexInputRef input) {
final int index = input.getIndex();
if (valid) {
// The expression should already be valid. Check that its
// index is within bounds.
if ((index < 0) || (index >= inputRowType.getFieldCount())) {
assert false
: "RexInputRef index " + index + " out of range 0.."
+ (inputRowType.getFieldCount() - 1);
}
// Check that the type is consistent with the referenced
// field. If it is an object type, the rules are different, so
// skip the check.
assert input.getType().isStruct()
|| RelOptUtil.eq("type1", input.getType(),
"type2", inputRowType.getFieldList().get(index).getType(),
Litmus.THROW);
}
// Return a reference to the N'th expression, which should be
// equivalent.
final RexLocalRef ref = localRefList.get(index);
return ref;
}
代码示例来源:origin: Qihoo360/Quicksql
public RexNode visitInputRef(RexInputRef input) {
final int index = input.getIndex();
if (valid) {
// The expression should already be valid. Check that its
// index is within bounds.
if ((index < 0) || (index >= inputRowType.getFieldCount())) {
assert false
: "RexInputRef index " + index + " out of range 0.."
+ (inputRowType.getFieldCount() - 1);
}
// Check that the type is consistent with the referenced
// field. If it is an object type, the rules are different, so
// skip the check.
assert input.getType().isStruct()
|| RelOptUtil.eq("type1", input.getType(),
"type2", inputRowType.getFieldList().get(index).getType(),
Litmus.THROW);
}
// Return a reference to the N'th expression, which should be
// equivalent.
final RexLocalRef ref = localRefList.get(index);
return ref;
}
代码示例来源:origin: Qihoo360/Quicksql
@Override public Boolean visitFieldAccess(RexFieldAccess fieldAccess) {
super.visitFieldAccess(fieldAccess);
final RelDataType refType = fieldAccess.getReferenceExpr().getType();
assert refType.isStruct();
final RelDataTypeField field = fieldAccess.getField();
final int index = field.getIndex();
if ((index < 0) || (index > refType.getFieldList().size())) {
++failCount;
return litmus.fail(null);
}
final RelDataTypeField typeField = refType.getFieldList().get(index);
if (!RelOptUtil.eq(
"type1",
typeField.getType(),
"type2",
fieldAccess.getType(), litmus)) {
++failCount;
return litmus.fail(null);
}
return litmus.succeed();
}
代码示例来源:origin: org.apache.calcite/calcite-core
@Override public Boolean visitFieldAccess(RexFieldAccess fieldAccess) {
super.visitFieldAccess(fieldAccess);
final RelDataType refType = fieldAccess.getReferenceExpr().getType();
assert refType.isStruct();
final RelDataTypeField field = fieldAccess.getField();
final int index = field.getIndex();
if ((index < 0) || (index > refType.getFieldList().size())) {
++failCount;
return litmus.fail(null);
}
final RelDataTypeField typeField = refType.getFieldList().get(index);
if (!RelOptUtil.eq(
"type1",
typeField.getType(),
"type2",
fieldAccess.getType(), litmus)) {
++failCount;
return litmus.fail(null);
}
return litmus.succeed();
}
内容来源于网络,如有侵权,请联系作者删除!