From 155276591288615c4d02d55fb7d77eceb2e24b2d Mon Sep 17 00:00:00 2001
From: Vladimir Sitnikov
Date: Wed, 30 Sep 2020 10:32:43 +0300
Subject: [PATCH] [CALCITE-4314] Suppress the current CatchAndPrintStackTrace,
MissingSummary, etc
---
.../calcite/adapter/enumerable/EnumerableTableScan.java | 2 +-
.../org/apache/calcite/adapter/jdbc/JdbcImplementor.java | 1 +
.../main/java/org/apache/calcite/interpreter/Bindables.java | 1 +
.../java/org/apache/calcite/interpreter/Interpreter.java | 1 +
.../materialize/CachingLatticeStatisticProvider.java | 2 +-
.../org/apache/calcite/rel/metadata/RelMdPredicates.java | 6 +++++-
.../java/org/apache/calcite/rel/metadata/RelMdRowCount.java | 1 +
.../src/main/java/org/apache/calcite/runtime/FlatLists.java | 1 +
core/src/main/java/org/apache/calcite/runtime/Hook.java | 2 +-
.../main/java/org/apache/calcite/runtime/SqlFunctions.java | 2 +-
.../apache/calcite/runtime/TrustAllSslSocketFactory.java | 1 +
core/src/main/java/org/apache/calcite/sql/SqlNode.java | 3 ++-
.../org/apache/calcite/sql/parser/SqlParseException.java | 2 +-
.../main/java/org/apache/calcite/sql/type/SqlTypeUtil.java | 2 +-
.../java/org/apache/calcite/sql2rel/RelDecorrelator.java | 2 ++
.../java/org/apache/calcite/util/ControlFlowException.java | 2 +-
core/src/main/java/org/apache/calcite/util/Util.java | 1 +
.../org/apache/calcite/adapter/druid/DruidJsonFilter.java | 2 +-
.../java/org/apache/calcite/adapter/druid/DruidQuery.java | 6 +++---
.../java/org/apache/calcite/adapter/druid/DruidType.java | 2 +-
.../adapter/elasticsearch/ElasticsearchTransport.java | 3 ++-
.../calcite/adapter/elasticsearch/PredicateAnalyzer.java | 1 +
.../apache/calcite/adapter/geode/rel/GeodeAggregate.java | 3 +--
.../org/apache/calcite/adapter/geode/rel/GeodeTable.java | 3 +--
.../org/apache/calcite/adapter/geode/util/GeodeUtils.java | 1 +
.../main/java/org/apache/calcite/adapter/os/SqlShell.java | 1 +
.../org/apache/calcite/adapter/splunk/SplunkDriver.java | 2 +-
.../calcite/adapter/splunk/search/SplunkConnectionImpl.java | 1 +
28 files changed, 37 insertions(+), 20 deletions(-)
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
index cf1a9606f57..bae77f9caaa 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/EnumerableTableScan.java
@@ -113,7 +113,7 @@ public static EnumerableTableScan create(RelOptCluster cluster,
/** Returns whether EnumerableTableScan can generate code to handle a
* particular variant of the Table SPI.
- * @deprecated
+ * @deprecated remove before Calcite 2.0
**/
@Deprecated
public static boolean canHandle(Table table) {
diff --git a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java
index eeebc0be34d..83e5f642eb2 100644
--- a/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java
+++ b/core/src/main/java/org/apache/calcite/adapter/jdbc/JdbcImplementor.java
@@ -35,6 +35,7 @@ public JdbcImplementor(SqlDialect dialect, JavaTypeFactory typeFactory) {
// CHECKSTYLE: IGNORE 1
/** @see #dispatch */
+ @SuppressWarnings("MissingSummary")
public Result visit(JdbcTableScan scan) {
return result(scan.jdbcTable.tableName(),
ImmutableList.of(Clause.FROM), scan, null);
diff --git a/core/src/main/java/org/apache/calcite/interpreter/Bindables.java b/core/src/main/java/org/apache/calcite/interpreter/Bindables.java
index 20e7921783d..25329f37df6 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/Bindables.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/Bindables.java
@@ -111,6 +111,7 @@ private Bindables() {}
// CHECKSTYLE: IGNORE 1
/** @deprecated Use {@link #BINDABLE_SET_OP_RULE}. */
+ @SuppressWarnings("MissingSummary")
public static final RelOptRule BINDABLE_SETOP_RULE =
BINDABLE_SET_OP_RULE;
diff --git a/core/src/main/java/org/apache/calcite/interpreter/Interpreter.java b/core/src/main/java/org/apache/calcite/interpreter/Interpreter.java
index 556c70d6a44..939b5708362 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/Interpreter.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/Interpreter.java
@@ -122,6 +122,7 @@ private RelNode optimize(RelNode rootRel) {
};
}
+ @SuppressWarnings("CatchAndPrintStackTrace")
private void start() {
// We rely on the nodes being ordered leaves first.
for (Map.Entry entry : nodes.entrySet()) {
diff --git a/core/src/main/java/org/apache/calcite/materialize/CachingLatticeStatisticProvider.java b/core/src/main/java/org/apache/calcite/materialize/CachingLatticeStatisticProvider.java
index 5b20859537b..2a3d59cc2c0 100644
--- a/core/src/main/java/org/apache/calcite/materialize/CachingLatticeStatisticProvider.java
+++ b/core/src/main/java/org/apache/calcite/materialize/CachingLatticeStatisticProvider.java
@@ -40,7 +40,7 @@ class CachingLatticeStatisticProvider implements LatticeStatisticProvider {
CachingLatticeStatisticProvider(final Lattice lattice,
final LatticeStatisticProvider provider) {
this.lattice = lattice;
- cache = CacheBuilder.newBuilder().build(
+ cache = CacheBuilder.newBuilder().build(
CacheLoader.from(key -> provider.cardinality(ImmutableList.of(key))));
}
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
index 3f93392db92..bfb7ac3072f 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdPredicates.java
@@ -486,7 +486,11 @@ public RelOptPredicateList getPredicates(Exchange exchange,
}
// CHECKSTYLE: IGNORE 1
- /** @see RelMetadataQuery#getPulledUpPredicates(RelNode) */
+ /**
+ * Returns the
+ * {@link BuiltInMetadata.Predicates#getPredicates()}
+ * statistic.
+ * @see RelMetadataQuery#getPulledUpPredicates(RelNode) */
public RelOptPredicateList getPredicates(RelSubset r,
RelMetadataQuery mq) {
if (!Bug.CALCITE_1048_FIXED) {
diff --git a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
index 4cf6209ead1..02c45cfc31f 100644
--- a/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
+++ b/core/src/main/java/org/apache/calcite/rel/metadata/RelMdRowCount.java
@@ -67,6 +67,7 @@ public Double getRowCount(RelNode rel, RelMetadataQuery mq) {
return rel.estimateRowCount(mq);
}
+ @SuppressWarnings("CatchAndPrintStackTrace")
public Double getRowCount(RelSubset subset, RelMetadataQuery mq) {
if (!Bug.CALCITE_1048_FIXED) {
return mq.getRowCount(Util.first(subset.getBest(), subset.getOriginal()));
diff --git a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
index 41bde64f8d1..2d61ae0edb0 100644
--- a/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
+++ b/core/src/main/java/org/apache/calcite/runtime/FlatLists.java
@@ -1289,6 +1289,7 @@ private ComparableEmptyList() {
*
* @param element type
*/
+ @SuppressWarnings("ComparableType")
public interface ComparableList extends List, Comparable {
}
diff --git a/core/src/main/java/org/apache/calcite/runtime/Hook.java b/core/src/main/java/org/apache/calcite/runtime/Hook.java
index f849d3ea44b..2f531db930b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/Hook.java
+++ b/core/src/main/java/org/apache/calcite/runtime/Hook.java
@@ -134,7 +134,7 @@ public Closeable add(final Consumer handler) {
// CHECKSTYLE: IGNORE 1
/** @deprecated Use {@link #add(Consumer)}. */
- @SuppressWarnings("Guava")
+ @SuppressWarnings({"Guava", "ReturnValueIgnored"})
@Deprecated // to be removed before 2.0
public Closeable add(final Function handler) {
return add((Consumer) handler::apply);
diff --git a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
index 194b2eaa975..df458d0dc8b 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -2429,7 +2429,7 @@ public static long currentTimestamp(DataContext root) {
public static int currentTime(DataContext root) {
int time = (int) (currentTimestamp(root) % DateTimeUtils.MILLIS_PER_DAY);
if (time < 0) {
- time += DateTimeUtils.MILLIS_PER_DAY;
+ time = (int) (time + DateTimeUtils.MILLIS_PER_DAY);
}
return time;
}
diff --git a/core/src/main/java/org/apache/calcite/runtime/TrustAllSslSocketFactory.java b/core/src/main/java/org/apache/calcite/runtime/TrustAllSslSocketFactory.java
index b5ef3899f40..ba09e5ac369 100644
--- a/core/src/main/java/org/apache/calcite/runtime/TrustAllSslSocketFactory.java
+++ b/core/src/main/java/org/apache/calcite/runtime/TrustAllSslSocketFactory.java
@@ -29,6 +29,7 @@
/**
* Socket factory that trusts all SSL connections.
*/
+@SuppressWarnings("CatchAndPrintStackTrace")
public class TrustAllSslSocketFactory extends SocketFactoryImpl {
private static final TrustAllSslSocketFactory DEFAULT =
new TrustAllSslSocketFactory();
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlNode.java b/core/src/main/java/org/apache/calcite/sql/SqlNode.java
index d4cb3bcef93..73341be62a3 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlNode.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlNode.java
@@ -70,12 +70,13 @@ public abstract class SqlNode implements Cloneable {
/** @deprecated Please use {@link #clone(SqlNode)}; this method brings
* along too much baggage from early versions of Java */
@Deprecated
- @SuppressWarnings("MethodDoesntCallSuperMethod")
+ @SuppressWarnings({"MethodDoesntCallSuperMethod", "AmbiguousMethodReference"})
@Override public Object clone() {
return clone(getParserPosition());
}
/** Creates a copy of a SqlNode. */
+ @SuppressWarnings("AmbiguousMethodReference")
public static E clone(E e) {
//noinspection unchecked
return (E) e.clone(e.pos);
diff --git a/core/src/main/java/org/apache/calcite/sql/parser/SqlParseException.java b/core/src/main/java/org/apache/calcite/sql/parser/SqlParseException.java
index bba8b93d5d5..ebd28e405a5 100644
--- a/core/src/main/java/org/apache/calcite/sql/parser/SqlParseException.java
+++ b/core/src/main/java/org/apache/calcite/sql/parser/SqlParseException.java
@@ -154,7 +154,7 @@ public int[][] getExpectedTokenSequences() {
}
// override Exception
- @Override public Throwable getCause() {
+ @Override public synchronized Throwable getCause() {
return parserException;
}
diff --git a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
index 66d1be6734f..825e9e22f85 100644
--- a/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
+++ b/core/src/main/java/org/apache/calcite/sql/type/SqlTypeUtil.java
@@ -1425,7 +1425,7 @@ && canConvertStringInCompare(family1)) {
}
/** Returns the least restrictive type T, such that a value of type T can be
- * compared with values of type {@code type0} and {@code type1} using
+ * compared with values of type {@code type1} and {@code type2} using
* {@code =}. */
public static RelDataType leastRestrictiveForComparison(
RelDataTypeFactory typeFactory, RelDataType type1, RelDataType type2) {
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
index e3f2c3bc1ad..765f71868bd 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/RelDecorrelator.java
@@ -2778,9 +2778,11 @@ private CorelMap(Multimap mapRefRelToCorRef,
+ "\n";
}
+ @SuppressWarnings("UndefinedEquals")
@Override public boolean equals(Object obj) {
return obj == this
|| obj instanceof CorelMap
+ // TODO: Multimap does not have well-defined equals behavior
&& mapRefRelToCorRef.equals(((CorelMap) obj).mapRefRelToCorRef)
&& mapCorToCorRel.equals(((CorelMap) obj).mapCorToCorRel)
&& mapFieldAccessToCorRef.equals(
diff --git a/core/src/main/java/org/apache/calcite/util/ControlFlowException.java b/core/src/main/java/org/apache/calcite/util/ControlFlowException.java
index b4262962d37..bdf19373d12 100644
--- a/core/src/main/java/org/apache/calcite/util/ControlFlowException.java
+++ b/core/src/main/java/org/apache/calcite/util/ControlFlowException.java
@@ -24,7 +24,7 @@
* makes instantiating one of these (or a sub-class) more efficient.
*/
public class ControlFlowException extends RuntimeException {
- @Override public Throwable fillInStackTrace() {
+ @Override public synchronized Throwable fillInStackTrace() {
return this;
}
}
diff --git a/core/src/main/java/org/apache/calcite/util/Util.java b/core/src/main/java/org/apache/calcite/util/Util.java
index 60424c3d4df..47a23769da4 100644
--- a/core/src/main/java/org/apache/calcite/util/Util.java
+++ b/core/src/main/java/org/apache/calcite/util/Util.java
@@ -899,6 +899,7 @@ public static Error newInternal(Throwable e) {
/** @deprecated Throw new {@link AssertionError} if applicable;
* or {@link RuntimeException} if e is checked;
* or raw exception if e is unchecked or {@link Error}. */
+ @SuppressWarnings("MissingSummary")
public static Error newInternal(Throwable e, String s) {
return new AssertionError("Internal error: " + s, e);
}
diff --git a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidJsonFilter.java b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidJsonFilter.java
index 715a26c9de3..78447b29d46 100644
--- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidJsonFilter.java
+++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidJsonFilter.java
@@ -333,7 +333,7 @@ private static DruidJsonFilter toBetweenDruidFilter(RexNode rexNode, RelDataType
return null;
}
final boolean isNumeric = lhs.getType().getFamily() == SqlTypeFamily.NUMERIC
- || lhs.getType().getFamily() == SqlTypeFamily.NUMERIC;
+ || rhs.getType().getFamily() == SqlTypeFamily.NUMERIC;
final Pair druidColumn = DruidQuery
.toDruidColumn(refNode, rowType, query);
final String columnName = druidColumn.left;
diff --git a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
index bf17b8055ed..239b72cf563 100644
--- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
+++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
@@ -589,7 +589,7 @@ public DruidTable getDruidTable() {
}
private double getIntervalCostMultiplier() {
- int days = 0;
+ long days = 0;
for (Interval interval : intervals) {
days += interval.toDuration().getStandardDays();
}
@@ -597,7 +597,7 @@ private double getIntervalCostMultiplier() {
// A plan querying 10 or more years of data will have 10x the cost of a
// plan returning 1 day data.
// A plan where least interval is queries will be preferred.
- return RelMdUtil.linear(days, 1, DAYS_IN_TEN_YEARS, 0.1d, 1d);
+ return RelMdUtil.linear((int) days, 1, DAYS_IN_TEN_YEARS, 0.1d, 1d);
}
private double getQueryTypeCostMultiplier() {
@@ -1196,7 +1196,7 @@ private String planAsTimeSeries(List groupByKeyDims, DruidJsonFil
// cannot use timeseries
boolean hasExpressionOnTopOfTimeExtract = false;
for (JsonExpressionPostAgg postAgg : postAggregations) {
- if (postAgg instanceof JsonExpressionPostAgg) {
+ if (postAgg != null) {
if (postAgg.expression.contains(groupByKeyDims.get(0).getOutputName())) {
hasExpressionOnTopOfTimeExtract = true;
}
diff --git a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidType.java b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidType.java
index af7f43b2fc1..adb4d8541a5 100644
--- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidType.java
+++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidType.java
@@ -59,7 +59,7 @@ static DruidType getTypeFromMetric(String type) {
}
/** Returns a DruidType matching the String from a meta data query. */
- protected static DruidType getTypeFromMetaData(String type) {
+ static DruidType getTypeFromMetaData(String type) {
assert type != null;
switch (type) {
case "LONG":
diff --git a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTransport.java b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTransport.java
index 2eac8b2eded..e5023a89c56 100644
--- a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTransport.java
+++ b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchTransport.java
@@ -188,7 +188,8 @@ void closeScroll(Iterable scrollIds) {
try {
final String json = mapper().writeValueAsString(payload);
request.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));
- rawHttp().apply(request);
+ @SuppressWarnings("unused")
+ Response response = rawHttp().apply(request);
} catch (IOException | UncheckedIOException e) {
LOGGER.warn("Failed to close scroll(s): {}", scrollIds, e);
}
diff --git a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java
index aacc7df1c37..5828a05efc9 100644
--- a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java
+++ b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/PredicateAnalyzer.java
@@ -263,6 +263,7 @@ private static String convertQueryString(List fields, Expression que
Preconditions.checkArgument(query instanceof LiteralExpression,
"Query string must be a string literal");
String queryString = ((LiteralExpression) query).stringValue();
+ @SuppressWarnings("ModifiedButNotUsed")
Map fieldMap = new LinkedHashMap<>();
for (Expression expr : fields) {
if (expr instanceof NamedFieldExpression) {
diff --git a/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeAggregate.java b/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeAggregate.java
index 365eebafda2..3945d19cb20 100644
--- a/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeAggregate.java
+++ b/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeAggregate.java
@@ -31,7 +31,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
import java.util.ArrayList;
import java.util.List;
@@ -101,7 +100,7 @@ public GeodeAggregate(RelOptCluster cluster,
geodeImplementContext.addGroupBy(groupByFields);
// Find the aggregate functions (e.g. MAX, SUM ...)
- Builder aggregateFunctionMap = ImmutableMap.builder();
+ ImmutableMap.Builder aggregateFunctionMap = ImmutableMap.builder();
for (AggregateCall aggCall : aggCalls) {
List aggCallFieldNames = new ArrayList<>();
diff --git a/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeTable.java b/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeTable.java
index 1ff44c34653..7de3aa28e93 100644
--- a/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeTable.java
+++ b/geode/src/main/java/org/apache/calcite/adapter/geode/rel/GeodeTable.java
@@ -44,7 +44,6 @@
import org.apache.geode.cache.query.SelectResults;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableList.Builder;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger;
@@ -129,7 +128,7 @@ public Enumerable