You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ch...@apache.org on 2020/07/28 06:38:16 UTC
[calcite] branch master updated (2ff1686 -> f03b455)
This is an automated email from the ASF dual-hosted git repository.
chunwei pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git.
omit 2ff1686 Remove duplicate codes and fix typos (Auxten, Chunwei Lei)
new f03b455 Remove duplicate codes and fix typos (Auxten, Chunwei Lei)
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (2ff1686)
\
N -- N -- N refs/heads/master (f03b455)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
[calcite] 01/01: Remove duplicate codes and fix typos (Auxten,
Chunwei Lei)
Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
chunwei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
commit f03b4559f1d79ef1886cdf79bc50e039640c7f50
Author: Chunwei Lei <ch...@gmail.com>
AuthorDate: Fri Jul 17 15:27:47 2020 +0800
Remove duplicate codes and fix typos (Auxten, Chunwei Lei)
Close apache/calcite#2066
---
.../org/apache/calcite/sql/SqlBinaryOperator.java | 70 ++++++----------------
.../calcite/test/AbstractMaterializedViewTest.java | 4 +-
2 files changed, 21 insertions(+), 53 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java b/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java
index 1efd2b5..d28d3e9 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlBinaryOperator.java
@@ -99,31 +99,35 @@ public class SqlBinaryOperator extends SqlOperator {
SqlValidator validator,
final SqlCall call,
RelDataType type) {
- RelDataType operandType1 =
+ return convertType(validator, call, type);
+ }
+
+ private RelDataType convertType(SqlValidator validator, SqlCall call, RelDataType type) {
+ RelDataType operandType0 =
validator.getValidatedNodeType(call.operand(0));
- RelDataType operandType2 =
+ RelDataType operandType1 =
validator.getValidatedNodeType(call.operand(1));
- if (SqlTypeUtil.inCharFamily(operandType1)
- && SqlTypeUtil.inCharFamily(operandType2)) {
+ if (SqlTypeUtil.inCharFamily(operandType0)
+ && SqlTypeUtil.inCharFamily(operandType1)) {
+ Charset cs0 = operandType0.getCharset();
Charset cs1 = operandType1.getCharset();
- Charset cs2 = operandType2.getCharset();
- assert (null != cs1) && (null != cs2)
+ assert (null != cs0) && (null != cs1)
: "An implicit or explicit charset should have been set";
- if (!cs1.equals(cs2)) {
+ if (!cs0.equals(cs1)) {
throw validator.newValidationError(call,
- RESOURCE.incompatibleCharset(getName(), cs1.name(), cs2.name()));
+ RESOURCE.incompatibleCharset(getName(), cs0.name(), cs1.name()));
}
- SqlCollation col1 = operandType1.getCollation();
- SqlCollation col2 = operandType2.getCollation();
- assert (null != col1) && (null != col2)
+ SqlCollation collation0 = operandType0.getCollation();
+ SqlCollation collation1 = operandType1.getCollation();
+ assert (null != collation0) && (null != collation1)
: "An implicit or explicit collation should have been set";
- // validation will occur inside getCoercibilityDyadicOperator...
+ // Validation will occur inside getCoercibilityDyadicOperator...
SqlCollation resultCol =
SqlCollation.getCoercibilityDyadicOperator(
- col1,
- col2);
+ collation0,
+ collation1);
if (SqlTypeUtil.inCharFamily(type)) {
type =
@@ -142,43 +146,7 @@ public class SqlBinaryOperator extends SqlOperator {
SqlValidatorScope scope,
SqlCall call) {
RelDataType type = super.deriveType(validator, scope, call);
-
- RelDataType operandType1 =
- validator.getValidatedNodeType(call.operand(0));
- RelDataType operandType2 =
- validator.getValidatedNodeType(call.operand(1));
- if (SqlTypeUtil.inCharFamily(operandType1)
- && SqlTypeUtil.inCharFamily(operandType2)) {
- Charset cs1 = operandType1.getCharset();
- Charset cs2 = operandType2.getCharset();
- assert (null != cs1) && (null != cs2)
- : "An implicit or explicit charset should have been set";
- if (!cs1.equals(cs2)) {
- throw validator.newValidationError(call,
- RESOURCE.incompatibleCharset(getName(), cs1.name(), cs2.name()));
- }
-
- SqlCollation col1 = operandType1.getCollation();
- SqlCollation col2 = operandType2.getCollation();
- assert (null != col1) && (null != col2)
- : "An implicit or explicit collation should have been set";
-
- // validation will occur inside getCoercibilityDyadicOperator...
- SqlCollation resultCol =
- SqlCollation.getCoercibilityDyadicOperator(
- col1,
- col2);
-
- if (SqlTypeUtil.inCharFamily(type)) {
- type =
- validator.getTypeFactory()
- .createTypeWithCharsetAndCollation(
- type,
- type.getCharset(),
- resultCol);
- }
- }
- return type;
+ return convertType(validator, call, type);
}
@Override public SqlMonotonicity getMonotonicity(SqlOperatorBinding call) {
diff --git a/core/src/test/java/org/apache/calcite/test/AbstractMaterializedViewTest.java b/core/src/test/java/org/apache/calcite/test/AbstractMaterializedViewTest.java
index fd6e35d..f9bf607 100644
--- a/core/src/test/java/org/apache/calcite/test/AbstractMaterializedViewTest.java
+++ b/core/src/test/java/org/apache/calcite/test/AbstractMaterializedViewTest.java
@@ -108,7 +108,7 @@ public abstract class AbstractMaterializedViewTest {
for (RelNode sub: substitutes) {
substituteMessages.append(RelOptUtil.toString(sub)).append("\n");
}
- throw new AssertionError("Materialized view failed to be matched by optmized results:\n"
+ throw new AssertionError("Materialized view failed to be matched by optimized results:\n"
+ substituteMessages.toString());
}
}
@@ -124,7 +124,7 @@ public abstract class AbstractMaterializedViewTest {
return;
}
final StringBuilder errMsgBuilder = new StringBuilder();
- errMsgBuilder.append("Optmization succeeds out of expectation: ");
+ errMsgBuilder.append("Optimization succeeds out of expectation: ");
for (RelNode res: results) {
errMsgBuilder.append(RelOptUtil.toString(res)).append("\n");
}