You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by da...@apache.org on 2020/06/09 01:49:32 UTC
[calcite] branch master updated: Following CALCITE-4031,
some code style promotion
This is an automated email from the ASF dual-hosted git repository.
danny0405 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push:
new 8dec7ba Following CALCITE-4031, some code style promotion
8dec7ba is described below
commit 8dec7ba9a7c4969eb2e376c6f80f529e52f884e3
Author: yuzhao.cyz <yu...@gmail.com>
AuthorDate: Mon Jun 8 15:45:58 2020 +0800
Following CALCITE-4031, some code style promotion
* Remove useless code in SqlValidatorImpl and SqlToRelConverter
* Mark SqlValidator#setValidatedNodeType interval instead of deprecated
* Implement Symbolizable where possible
* Some cosmetic changes
---
.../java/org/apache/calcite/plan/RelOptNode.java | 2 +-
.../org/apache/calcite/sql/JoinConditionType.java | 14 +--
.../main/java/org/apache/calcite/sql/JoinType.java | 13 +--
.../java/org/apache/calcite/sql/SqlExplain.java | 12 +--
.../org/apache/calcite/sql/SqlExplainFormat.java | 14 +--
.../org/apache/calcite/sql/SqlExplainLevel.java | 14 +--
.../org/apache/calcite/sql/SqlInsertKeyword.java | 14 +--
.../apache/calcite/sql/SqlJdbcDataTypeName.java | 10 +-
.../org/apache/calcite/sql/SqlMatchRecognize.java | 10 +-
.../org/apache/calcite/sql/SqlSelectKeyword.java | 14 +--
.../java/org/apache/calcite/sql/SqlWindow.java | 10 +-
.../apache/calcite/sql/fun/SqlTrimFunction.java | 11 +--
.../apache/calcite/sql/validate/SqlValidator.java | 7 +-
.../calcite/sql/validate/SqlValidatorImpl.java | 109 +++------------------
.../validate/implicit/AbstractTypeCoercion.java | 1 -
.../apache/calcite/sql2rel/SqlToRelConverter.java | 16 ++-
16 files changed, 41 insertions(+), 230 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/plan/RelOptNode.java b/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
index 6ba931b..2a0f077 100644
--- a/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
+++ b/core/src/main/java/org/apache/calcite/plan/RelOptNode.java
@@ -35,7 +35,7 @@ public interface RelOptNode {
/**
* Returns a string which concisely describes the definition of this
* relational expression. Two relational expressions are equivalent if
- * their digests and {@link #getRowType()} are the same.
+ * their digests and {@link #getRowType()} (except the field names) are the same.
*
* <p>The digest does not contain the relational expression's identity --
* that would prevent similar relational expressions from ever comparing
diff --git a/core/src/main/java/org/apache/calcite/sql/JoinConditionType.java b/core/src/main/java/org/apache/calcite/sql/JoinConditionType.java
index ce32ba4..421af6f 100644
--- a/core/src/main/java/org/apache/calcite/sql/JoinConditionType.java
+++ b/core/src/main/java/org/apache/calcite/sql/JoinConditionType.java
@@ -16,12 +16,10 @@
*/
package org.apache.calcite.sql;
-import org.apache.calcite.sql.parser.SqlParserPos;
-
/**
* Enumerates the types of condition in a join expression.
*/
-public enum JoinConditionType {
+public enum JoinConditionType implements Symbolizable {
/**
* Join clause has no condition, for example "FROM EMP, DEPT"
*/
@@ -37,13 +35,5 @@ public enum JoinConditionType {
* Join clause has a USING condition, for example "FROM EMP JOIN DEPT
* USING (DEPTNO)"
*/
- USING;
-
- /**
- * Creates a parse-tree node representing an occurrence of this join
- * type at a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
+ USING
}
diff --git a/core/src/main/java/org/apache/calcite/sql/JoinType.java b/core/src/main/java/org/apache/calcite/sql/JoinType.java
index 698097e..fa689c6 100644
--- a/core/src/main/java/org/apache/calcite/sql/JoinType.java
+++ b/core/src/main/java/org/apache/calcite/sql/JoinType.java
@@ -16,14 +16,12 @@
*/
package org.apache.calcite.sql;
-import org.apache.calcite.sql.parser.SqlParserPos;
-
import java.util.Locale;
/**
* Enumerates the types of join.
*/
-public enum JoinType {
+public enum JoinType implements Symbolizable {
/**
* Inner join.
*/
@@ -81,13 +79,4 @@ public enum JoinType {
public boolean generatesNullsOnRight() {
return this == LEFT || this == FULL;
}
-
- /**
- * Creates a parse-tree node representing an occurrence of this
- * condition type keyword at a particular position in the parsed
- * text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
}
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlExplain.java b/core/src/main/java/org/apache/calcite/sql/SqlExplain.java
index 4c96177..caa434f 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlExplain.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlExplain.java
@@ -40,16 +40,8 @@ public class SqlExplain extends SqlCall {
/**
* The level of abstraction with which to display the plan.
*/
- public enum Depth {
- TYPE, LOGICAL, PHYSICAL;
-
- /**
- * Creates a parse-tree node representing an occurrence of this symbol
- * at a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
+ public enum Depth implements Symbolizable {
+ TYPE, LOGICAL, PHYSICAL
}
//~ Instance fields --------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlExplainFormat.java b/core/src/main/java/org/apache/calcite/sql/SqlExplainFormat.java
index 43fbceb..5c25bba 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlExplainFormat.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlExplainFormat.java
@@ -16,12 +16,10 @@
*/
package org.apache.calcite.sql;
-import org.apache.calcite.sql.parser.SqlParserPos;
-
/**
* Output format for {@code EXPLAIN PLAN} statement.
*/
-public enum SqlExplainFormat {
+public enum SqlExplainFormat implements Symbolizable {
/** Indicates that the plan should be output as a piece of indented text. */
TEXT,
@@ -29,13 +27,5 @@ public enum SqlExplainFormat {
XML,
/** Indicates that the plan should be output in JSON format. */
- JSON;
-
- /**
- * Creates a parse-tree node representing an occurrence of this symbol at
- * a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
+ JSON
}
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlExplainLevel.java b/core/src/main/java/org/apache/calcite/sql/SqlExplainLevel.java
index 5e0ed94..7e9c696 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlExplainLevel.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlExplainLevel.java
@@ -16,12 +16,10 @@
*/
package org.apache.calcite.sql;
-import org.apache.calcite.sql.parser.SqlParserPos;
-
/**
* SqlExplainLevel defines detail levels for EXPLAIN PLAN.
*/
-public enum SqlExplainLevel {
+public enum SqlExplainLevel implements Symbolizable {
/**
* Suppress all attributes.
*/
@@ -45,13 +43,5 @@ public enum SqlExplainLevel {
/**
* Display all attributes, including cost.
*/
- ALL_ATTRIBUTES;
-
- /**
- * Creates a parse-tree node representing an occurrence of this symbol at
- * a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
+ ALL_ATTRIBUTES
}
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlInsertKeyword.java b/core/src/main/java/org/apache/calcite/sql/SqlInsertKeyword.java
index 2ec36cf..df77e85 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlInsertKeyword.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlInsertKeyword.java
@@ -16,21 +16,11 @@
*/
package org.apache.calcite.sql;
-import org.apache.calcite.sql.parser.SqlParserPos;
-
/**
* Defines the keywords that can occur immediately after the "INSERT" keyword.
*
* <p>Standard SQL has no such keywords, but extension projects may define them.
*/
-public enum SqlInsertKeyword {
- UPSERT;
-
- /**
- * Creates a parse-tree node representing an occurrence of this keyword
- * at a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
+public enum SqlInsertKeyword implements Symbolizable {
+ UPSERT
}
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlJdbcDataTypeName.java b/core/src/main/java/org/apache/calcite/sql/SqlJdbcDataTypeName.java
index 7f58301..bc7b3d7 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlJdbcDataTypeName.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlJdbcDataTypeName.java
@@ -29,7 +29,7 @@ import org.apache.calcite.sql.type.SqlTypeName;
*
* @see SqlJdbcFunctionCall
*/
-public enum SqlJdbcDataTypeName {
+public enum SqlJdbcDataTypeName implements Symbolizable {
SQL_CHAR(SqlTypeName.CHAR),
SQL_VARCHAR(SqlTypeName.VARCHAR),
SQL_DATE(SqlTypeName.DATE),
@@ -80,14 +80,6 @@ public enum SqlJdbcDataTypeName {
this.range = range;
}
- /**
- * Creates a parse-tree node representing an occurrence of this keyword
- * at a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
-
/** Creates a parse tree node for a type identifier of this name. */
public SqlNode createDataType(SqlParserPos pos) {
if (typeName != null) {
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java b/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java
index c4c156b..c3b1322 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlMatchRecognize.java
@@ -236,7 +236,7 @@ public class SqlMatchRecognize extends SqlCall {
/**
* Options for {@code AFTER MATCH} clause.
*/
- public enum AfterOption {
+ public enum AfterOption implements Symbolizable {
SKIP_TO_NEXT_ROW("SKIP TO NEXT ROW"),
SKIP_PAST_LAST_ROW("SKIP PAST LAST ROW");
@@ -249,14 +249,6 @@ public class SqlMatchRecognize extends SqlCall {
@Override public String toString() {
return sql;
}
-
- /**
- * Creates a parse-tree node representing an occurrence of this symbol
- * at a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
}
/**
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlSelectKeyword.java b/core/src/main/java/org/apache/calcite/sql/SqlSelectKeyword.java
index 69c9fa0..0e96f36 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlSelectKeyword.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlSelectKeyword.java
@@ -16,21 +16,11 @@
*/
package org.apache.calcite.sql;
-import org.apache.calcite.sql.parser.SqlParserPos;
-
/**
* Defines the keywords which can occur immediately after the "SELECT" keyword.
*/
-public enum SqlSelectKeyword {
+public enum SqlSelectKeyword implements Symbolizable {
DISTINCT,
ALL,
- STREAM;
-
- /**
- * Creates a parse-tree node representing an occurrence of this keyword
- * at a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
+ STREAM
}
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlWindow.java b/core/src/main/java/org/apache/calcite/sql/SqlWindow.java
index 710b56f..4f816d0 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlWindow.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlWindow.java
@@ -778,7 +778,7 @@ public class SqlWindow extends SqlCall {
* An enumeration of types of bounds in a window: <code>CURRENT ROW</code>,
* <code>UNBOUNDED PRECEDING</code>, and <code>UNBOUNDED FOLLOWING</code>.
*/
- enum Bound {
+ enum Bound implements Symbolizable {
CURRENT_ROW("CURRENT ROW"),
UNBOUNDED_PRECEDING("UNBOUNDED PRECEDING"),
UNBOUNDED_FOLLOWING("UNBOUNDED FOLLOWING");
@@ -792,14 +792,6 @@ public class SqlWindow extends SqlCall {
public String toString() {
return sql;
}
-
- /**
- * Creates a parse-tree node representing an occurrence of this bound
- * type at a particular position in the parsed text.
- */
- public SqlNode symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
}
/** An operator describing a window specification. */
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlTrimFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlTrimFunction.java
index 6e8fb12..1702659 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlTrimFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlTrimFunction.java
@@ -24,6 +24,7 @@ import org.apache.calcite.sql.SqlKind;
import org.apache.calcite.sql.SqlLiteral;
import org.apache.calcite.sql.SqlNode;
import org.apache.calcite.sql.SqlWriter;
+import org.apache.calcite.sql.Symbolizable;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.type.ReturnTypes;
@@ -63,7 +64,7 @@ public class SqlTrimFunction extends SqlFunction {
/**
* Defines the enumerated values "LEADING", "TRAILING", "BOTH".
*/
- public enum Flag {
+ public enum Flag implements Symbolizable {
BOTH(1, 1), LEADING(1, 0), TRAILING(0, 1);
private final int left;
@@ -81,14 +82,6 @@ public class SqlTrimFunction extends SqlFunction {
public int getRight() {
return right;
}
-
- /**
- * Creates a parse-tree node representing an occurrence of this flag
- * at a particular position in the parsed text.
- */
- public SqlLiteral symbol(SqlParserPos pos) {
- return SqlLiteral.createSymbol(this, pos);
- }
}
//~ Constructors -----------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java
index 1f888e2..09a50ff 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidator.java
@@ -460,12 +460,13 @@ public interface SqlValidator {
/**
* Saves the type of a {@link SqlNode}, now that it has been validated.
*
+ * <p>This method is only for internal use. The validator should drive the
+ * type-derivation process, and store nodes' types when they have been derived.
+ *
* @param node A SQL parse tree node, never null
* @param type Its type; must not be null
- * @deprecated This method should not be in the {@link SqlValidator}
- * interface. The validator should drive the type-derivation process, and
- * store nodes' types when they have been derived.
*/
+ @API(status = API.Status.INTERNAL, since = "1.24")
void setValidatedNodeType(
SqlNode node,
RelDataType type);
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
index 8ab958a..c0843ca 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
@@ -16,7 +16,6 @@
*/
package org.apache.calcite.sql.validate;
-import org.apache.calcite.config.NullCollation;
import org.apache.calcite.linq4j.Ord;
import org.apache.calcite.linq4j.function.Function2;
import org.apache.calcite.linq4j.function.Functions;
@@ -106,7 +105,6 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import org.slf4j.Logger;
@@ -540,7 +538,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
}
final SqlNode from = sqlSelect.getFrom();
- if (from == null || !(from instanceof SqlJoin)) {
+ if (!(from instanceof SqlJoin)) {
return selectItem;
}
@@ -884,7 +882,6 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
// No suggestions.
// Not supporting hints for other types such as 'Using' yet.
- return;
}
}
@@ -1240,7 +1237,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
SqlNode node,
boolean underFrom) {
if (node == null) {
- return node;
+ return null;
}
SqlNode newOperand;
@@ -1713,7 +1710,6 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
* @param node A SQL parse tree node, never null
* @param type Its type; must not be null
*/
- @SuppressWarnings("deprecation")
public final void setValidatedNodeType(SqlNode node, RelDataType type) {
Objects.requireNonNull(type);
Objects.requireNonNull(node);
@@ -1987,7 +1983,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
String uniqueAlias =
SqlValidatorUtil.uniquify(
alias, aliases, SqlValidatorUtil.EXPR_SUGGESTER);
- if (!alias.equals(uniqueAlias)) {
+ if (!Objects.equals(alias, uniqueAlias)) {
exp = SqlValidatorUtil.addAlias(exp, uniqueAlias);
}
fieldList.add(Pair.of(uniqueAlias, deriveType(scope, exp)));
@@ -2000,39 +1996,6 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
return SqlValidatorUtil.getAlias(node, ordinal);
}
- // implement SqlValidator
- public void setIdentifierExpansion(boolean expandIdentifiers) {
- this.config = this.config.withIdentifierExpansion(expandIdentifiers);
- }
-
- // implement SqlValidator
- public void setColumnReferenceExpansion(
- boolean expandColumnReferences) {
- this.config = this.config.withColumnReferenceExpansion(expandColumnReferences);
- }
-
- // implement SqlValidator
- public boolean getColumnReferenceExpansion() {
- return this.config.columnReferenceExpansion();
- }
-
- public void setDefaultNullCollation(NullCollation nullCollation) {
- this.config = this.config.withDefaultNullCollation(Objects.requireNonNull(nullCollation));
- }
-
- public NullCollation getDefaultNullCollation() {
- return this.config.defaultNullCollation();
- }
-
- // implement SqlValidator
- public void setCallRewrite(boolean rewriteCalls) {
- this.config = this.config.withCallRewrite(rewriteCalls);
- }
-
- public boolean shouldExpandIdentifiers() {
- return this.config.identifierExpansion();
- }
-
protected boolean shouldAllowIntermediateOrderBy() {
return true;
}
@@ -2257,7 +2220,6 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
scopes.put(join, joinScope);
final SqlNode left = join.getLeft();
final SqlNode right = join.getRight();
- final boolean rightIsLateral = isLateral(right);
boolean forceLeftNullable = forceNullable;
boolean forceRightNullable = forceNullable;
switch (join.getJoinType()) {
@@ -2463,19 +2425,6 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
}
}
- private static boolean isLateral(SqlNode node) {
- switch (node.getKind()) {
- case LATERAL:
- case UNNEST:
- // Per SQL std, UNNEST is implicitly LATERAL.
- return true;
- case AS:
- return isLateral(((SqlCall) node).operand(0));
- default:
- return false;
- }
- }
-
protected boolean shouldAllowOverRelation() {
return false;
}
@@ -2978,7 +2927,6 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
return aggFinder.findAgg(select.getSelectList());
}
- @SuppressWarnings("deprecation")
public boolean isAggregate(SqlNode selectNode) {
return aggFinder.findAgg(selectNode) != null;
}
@@ -3168,21 +3116,11 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
final int minPrecision = qualifier.typeName().getMinPrecision();
final int minScale = qualifier.typeName().getMinScale();
final int maxScale = typeSystem.getMaxScale(qualifier.typeName());
- if (qualifier.isYearMonth()) {
- if (startPrecision < minPrecision || startPrecision > maxPrecision) {
- startPrecisionOutOfRange = true;
- } else {
- if (fracPrecision < minScale || fracPrecision > maxScale) {
- fractionalSecondPrecisionOutOfRange = true;
- }
- }
+ if (startPrecision < minPrecision || startPrecision > maxPrecision) {
+ startPrecisionOutOfRange = true;
} else {
- if (startPrecision < minPrecision || startPrecision > maxPrecision) {
- startPrecisionOutOfRange = true;
- } else {
- if (fracPrecision < minScale || fracPrecision > maxScale) {
- fractionalSecondPrecisionOutOfRange = true;
- }
+ if (fracPrecision < minScale || fracPrecision > maxScale) {
+ fractionalSecondPrecisionOutOfRange = true;
}
}
@@ -3473,7 +3411,9 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
final SelectScope fromScope = (SelectScope) getFromScope(select);
List<String> names = fromScope.getChildNames();
if (!catalogReader.nameMatcher().isCaseSensitive()) {
- names = Lists.transform(names, s -> s.toUpperCase(Locale.ROOT));
+ names = names.stream()
+ .map(s -> s.toUpperCase(Locale.ROOT))
+ .collect(Collectors.toList());
}
final int duplicateAliasOrdinal = Util.firstDuplicate(names);
if (duplicateAliasOrdinal >= 0) {
@@ -3944,38 +3884,11 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
return scopes.get(withItem);
}
- public SqlValidator setLenientOperatorLookup(boolean lenient) {
- this.config = this.config.withLenientOperatorLookup(lenient);
- return this;
- }
-
- public boolean isLenientOperatorLookup() {
- return this.config.lenientOperatorLookup();
- }
-
- public SqlValidator setEnableTypeCoercion(boolean enabled) {
- this.config = this.config.withTypeCoercionEnabled(enabled);
- return this;
- }
-
- public boolean isTypeCoercionEnabled() {
- return this.config.typeCoercionEnabled();
- }
-
- public void setTypeCoercion(TypeCoercion typeCoercion) {
- Objects.requireNonNull(typeCoercion);
- this.typeCoercion = typeCoercion;
- }
-
public TypeCoercion getTypeCoercion() {
assert config.typeCoercionEnabled();
return this.typeCoercion;
}
- public void setSqlTypeCoercionRules(SqlTypeCoercionRule typeCoercionRules) {
- SqlTypeCoercionRule.THREAD_PROVIDERS.set(typeCoercionRules);
- }
-
public Config config() {
return this.config;
}
@@ -5783,7 +5696,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
/**
* retrieve pattern variables defined
*/
- private class PatternVarVisitor implements SqlVisitor<Void> {
+ private static class PatternVarVisitor implements SqlVisitor<Void> {
private MatchRecognizeScope scope;
PatternVarVisitor(MatchRecognizeScope scope) {
this.scope = scope;
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java b/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java
index 4ad0c6c..86fd549 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/implicit/AbstractTypeCoercion.java
@@ -281,7 +281,6 @@ public abstract class AbstractTypeCoercion implements TypeCoercion {
/**
* Update inferred type for a SqlNode.
*/
- @SuppressWarnings("deprecation")
protected void updateInferredType(SqlNode node, RelDataType type) {
validator.setValidatedNodeType(node, type);
final SqlValidatorNamespace namespace = validator.getNamespace(node);
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
index 8197b0a..28ffa01 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -483,7 +483,7 @@ public class SqlToRelConverter {
* @return New root relational expression after decorrelation
*/
public RelNode decorrelate(SqlNode query, RelNode rootRel) {
- if (!enableDecorrelation()) {
+ if (!config.isDecorrelationEnabled()) {
return rootRel;
}
final RelNode result = decorrelateQuery(rootRel);
@@ -779,8 +779,9 @@ public class SqlToRelConverter {
RelDataTypeField field = fields.get(i);
undoProjects.add(
Pair.of(
- (RexNode) new RexInputRef(
- squished.get(origin), field.getType()),
+ new RexInputRef(
+ squished.get(origin),
+ field.getType()),
field.getName()));
}
@@ -2606,9 +2607,8 @@ public class SqlToRelConverter {
.union(p.requiredColumns);
}
- LogicalCorrelate corr = LogicalCorrelate.create(leftRel, innerRel,
+ return LogicalCorrelate.create(leftRel, innerRel,
p.id, requiredCols, joinType);
- return corr;
}
final RelNode node =
@@ -2986,7 +2986,7 @@ public class SqlToRelConverter {
// at all. The rest of the system doesn't like 0-tuples, so we
// select a dummy constant here.
final RexNode zero = rexBuilder.makeExactLiteral(BigDecimal.ZERO);
- preExprs = ImmutableList.of(Pair.of(zero, (String) null));
+ preExprs = ImmutableList.of(Pair.of(zero, null));
}
final RelNode inputRel = bb.root;
@@ -4044,7 +4044,7 @@ public class SqlToRelConverter {
}, null, false);
}
RelDataType multisetType = validator.getValidatedNodeType(call);
- ((SqlValidatorImpl) validator).setValidatedNodeType(list,
+ validator.setValidatedNodeType(list,
multisetType.getComponentType());
input = convertQueryOrInList(usedBb, list, null);
break;
@@ -5414,8 +5414,6 @@ public class SqlToRelConverter {
collation,
type,
nameMap.get(outerCall.toString()));
- final AggregatingSelectScope.Resolved r =
- aggregatingSelectScope.resolved.get();
RexNode rex =
rexBuilder.addAggCall(
aggCall,