You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jh...@apache.org on 2017/01/25 21:25:16 UTC
[2/9] calcite git commit: [CALCITE-1597] Obsolete Util.newInternal,
.pre, .post, .permAssert and Throwables.propagate
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/sql2rel/SqlNodeToRexConverterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/SqlNodeToRexConverterImpl.java b/core/src/main/java/org/apache/calcite/sql2rel/SqlNodeToRexConverterImpl.java
index a22963f..3f7b5cb 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlNodeToRexConverterImpl.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlNodeToRexConverterImpl.java
@@ -34,6 +34,8 @@ import org.apache.calcite.util.BitString;
import org.apache.calcite.util.NlsString;
import org.apache.calcite.util.Util;
+import com.google.common.base.Preconditions;
+
import java.math.BigDecimal;
import java.util.Calendar;
@@ -117,8 +119,7 @@ public class SqlNodeToRexConverterImpl implements SqlNodeToRexConverter {
return rexBuilder.makeLiteral(((Boolean) value).booleanValue());
case BINARY:
bitString = (BitString) value;
- Util.permAssert(
- (bitString.getBitCount() % 8) == 0,
+ Preconditions.checkArgument((bitString.getBitCount() % 8) == 0,
"incomplete octet");
// An even number of hexits (e.g. X'ABCD') makes whole number
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
----------------------------------------------------------------------
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 3f3fe34..9ae5436 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -1185,7 +1185,8 @@ public class SqlToRelConverter {
return;
default:
- throw Util.newInternal("unexpected kind of sub-query :" + subQuery.node);
+ throw new AssertionError("unexpected kind of sub-query: "
+ + subQuery.node);
}
}
@@ -1861,7 +1862,8 @@ public class SqlToRelConverter {
orderKeys.add(new RexFieldCollation(e, flags));
}
try {
- Util.permAssert(bb.window == null, "already in window agg mode");
+ Preconditions.checkArgument(bb.window == null,
+ "already in window agg mode");
bb.window = window;
RexNode rexAgg = exprConverter.convertCall(bb, aggCall);
rexAgg =
@@ -1945,8 +1947,7 @@ public class SqlToRelConverter {
tableSampleSpec.getRepeatableSeed());
bb.setRoot(new Sample(cluster, bb.root, params), false);
} else {
- throw Util.newInternal(
- "unknown TABLESAMPLE type: " + sampleSpec);
+ throw new AssertionError("unknown TABLESAMPLE type: " + sampleSpec);
}
return;
@@ -2080,7 +2081,7 @@ public class SqlToRelConverter {
return;
default:
- throw Util.newInternal("not a join operator " + from);
+ throw new AssertionError("not a join operator " + from);
}
}
@@ -2508,7 +2509,7 @@ public class SqlToRelConverter {
final List<Pair<RexNode, String>> projects = Lists.newArrayList();
try {
- Util.permAssert(bb.agg == null, "already in agg mode");
+ Preconditions.checkArgument(bb.agg == null, "already in agg mode");
bb.agg = aggConverter;
// convert the select and having expressions, so that the
@@ -2887,7 +2888,7 @@ public class SqlToRelConverter {
case VALUES:
return RelRoot.of(convertValues((SqlCall) query, targetRowType), kind);
default:
- throw Util.newInternal("not a query: " + query);
+ throw new AssertionError("not a query: " + query);
}
}
@@ -3646,7 +3647,7 @@ public class SqlToRelConverter {
}
if (unionRels.size() == 0) {
- throw Util.newInternal("empty values clause");
+ throw new AssertionError("empty values clause");
} else if (unionRels.size() == 1) {
bb.setRoot(
unionRels.get(0),
@@ -3912,7 +3913,7 @@ public class SqlToRelConverter {
if (nameToNodeMap != null && qualified.prefixLength == 1) {
RexNode node = nameToNodeMap.get(qualified.identifier.names.get(0));
if (node == null) {
- throw Util.newInternal("Unknown identifier '" + qualified.identifier
+ throw new AssertionError("Unknown identifier '" + qualified.identifier
+ "' encountered while expanding expression");
}
return Pair.of(node, null);
@@ -4192,8 +4193,7 @@ public class SqlToRelConverter {
// Apply standard conversions.
rex = expr.accept(this);
- Util.permAssert(rex != null, "conversion result not null");
- return rex;
+ return Preconditions.checkNotNull(rex);
}
/**
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/tools/RelRunners.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/tools/RelRunners.java b/core/src/main/java/org/apache/calcite/tools/RelRunners.java
index 9db8e7c..48652a5 100644
--- a/core/src/main/java/org/apache/calcite/tools/RelRunners.java
+++ b/core/src/main/java/org/apache/calcite/tools/RelRunners.java
@@ -18,8 +18,6 @@ package org.apache.calcite.tools;
import org.apache.calcite.rel.RelNode;
-import com.google.common.base.Throwables;
-
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
@@ -35,7 +33,7 @@ public class RelRunners {
final RelRunner runner = connection.unwrap(RelRunner.class);
return runner.prepare(rel);
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/util/Closer.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/Closer.java b/core/src/main/java/org/apache/calcite/util/Closer.java
index b816d35..68c4622 100644
--- a/core/src/main/java/org/apache/calcite/util/Closer.java
+++ b/core/src/main/java/org/apache/calcite/util/Closer.java
@@ -16,8 +16,6 @@
*/
package org.apache.calcite.util;
-import com.google.common.base.Throwables;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -40,8 +38,10 @@ public final class Closer implements AutoCloseable {
for (AutoCloseable closeable : list) {
try {
closeable.close();
+ } catch (RuntimeException e) {
+ throw e;
} catch (Exception e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/util/ReflectUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/ReflectUtil.java b/core/src/main/java/org/apache/calcite/util/ReflectUtil.java
index 51b1e6b..04b8a7e 100644
--- a/core/src/main/java/org/apache/calcite/util/ReflectUtil.java
+++ b/core/src/main/java/org/apache/calcite/util/ReflectUtil.java
@@ -258,19 +258,13 @@ public abstract class ReflectUtil {
visitor,
visitee);
} catch (IllegalAccessException ex) {
- throw Util.newInternal(ex);
+ throw new RuntimeException(ex);
} catch (InvocationTargetException ex) {
// visit methods aren't allowed to have throws clauses,
// so the only exceptions which should come
// to us are RuntimeExceptions and Errors
- Throwable t = ex.getTargetException();
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- } else if (t instanceof Error) {
- throw (Error) t;
- } else {
- throw new AssertionError(t.getClass().getName());
- }
+ Util.throwIfUnchecked(ex.getTargetException());
+ throw new RuntimeException(ex.getTargetException());
}
return true;
}
@@ -531,8 +525,8 @@ public abstract class ReflectUtil {
final Object o = method.invoke(visitor, args);
return returnClazz.cast(o);
} catch (IllegalAccessException | InvocationTargetException e) {
- throw Util.newInternal(e,
- "While invoking method '" + method + "'");
+ throw new RuntimeException("While invoking method '" + method + "'",
+ e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/SaffronProperties.java b/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
index b36a742..8f45d68 100644
--- a/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
+++ b/core/src/main/java/org/apache/calcite/util/SaffronProperties.java
@@ -116,7 +116,7 @@ public interface SaffronProperties {
try {
properties.load(new FileInputStream(file));
} catch (IOException e) {
- throw Util.newInternal(e, "while reading from " + file);
+ throw new RuntimeException("while reading from " + file, e);
}
}
} catch (AccessControlException e) {
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/util/Util.java
----------------------------------------------------------------------
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 fee522d..9e011be 100644
--- a/core/src/main/java/org/apache/calcite/util/Util.java
+++ b/core/src/main/java/org/apache/calcite/util/Util.java
@@ -29,6 +29,8 @@ import org.apache.calcite.sql.fun.SqlRowOperator;
import org.apache.calcite.sql.util.SqlBasicVisitor;
import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
+import com.google.common.base.Throwables;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@@ -88,6 +90,8 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Miscellaneous utility functions.
*/
@@ -456,7 +460,7 @@ public class Util {
try {
val = field.get(o);
} catch (IllegalAccessException e) {
- throw newInternal(e);
+ throw new RuntimeException(e);
}
print(pw, val, indent + 1);
}
@@ -772,29 +776,43 @@ public class Util {
return DEFAULT_CHARSET;
}
+ /** @deprecated Throw new {@link AssertionError} */
+ @Deprecated // to be removed before 2.0
public static Error newInternal() {
- return newInternal("(unknown cause)");
+ return new AssertionError("(unknown cause)");
}
+ /** @deprecated Throw new {@link AssertionError} */
+ @Deprecated // to be removed before 2.0
public static Error newInternal(String s) {
- return new AssertionError("Internal error: " + s);
+ return new AssertionError(s);
}
+ /** @deprecated Throw new {@link RuntimeException} if checked; throw raw
+ * exception if unchecked or {@link Error} */
+ @Deprecated // to be removed before 2.0
public static Error newInternal(Throwable e) {
- return newInternal(e, "(unknown cause)");
+ return new AssertionError(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}. */
public static Error newInternal(Throwable e, String s) {
- String message = "Internal error: " + s;
- if (false) {
- // TODO re-enable this code when we're no longer throwing spurious
- // internal errors (which should be parse errors, for example)
- System.err.println(message);
- e.printStackTrace(System.err);
+ return new AssertionError("Internal error: " + s, e);
+ }
+
+ /** As {@link Throwables#throwIfUnchecked(Throwable)}, but we don't require
+ * Guava version 20 yet. */
+ public static void throwIfUnchecked(Throwable throwable) {
+ Bug.upgrade("Remove when minimum Guava version is 20");
+ checkNotNull(throwable);
+ if (throwable instanceof RuntimeException) {
+ throw (RuntimeException) throwable;
+ }
+ if (throwable instanceof Error) {
+ throw (Error) throwable;
}
- AssertionError ae = new AssertionError(message);
- ae.initCause(e);
- return ae;
}
/**
@@ -836,60 +854,29 @@ public class Util {
return sw.toString();
}
- /**
- * Checks a pre-condition.
- *
- * <p>For example,
- *
- * <pre>
- * /**
- * * @ pre x != 0
- * * /
- * void foo(int x) {
- * Util.pre(x != 0, "x != 0");
- * }</pre>
- *
- * @param b Result of evaluating the pre-condition.
- * @param description Description of the pre-condition.
- */
+ /** @deprecated Use {@link Preconditions#checkArgument}
+ * or {@link Preconditions#checkNotNull(Object)} */
+ @Deprecated // to be removed before 2.0
public static void pre(boolean b, String description) {
if (!b) {
- throw newInternal("pre-condition failed: " + description);
+ throw new AssertionError("pre-condition failed: " + description);
}
}
- /**
- * Checks a post-condition.
- *
- * <p>For example,
- *
- * <pre>
- * /**
- * * @ post return != 0
- * * /
- * void foo(int x) {
- * int res = bar(x);
- * Util.post(res != 0, "return != 0");
- * }</pre>
- *
- * @param b Result of evaluating the pre-condition.
- * @param description Description of the pre-condition.
- */
+ /** @deprecated Use {@link Preconditions#checkArgument}
+ * or {@link Preconditions#checkNotNull(Object)} */
+ @Deprecated // to be removed before 2.0
public static void post(boolean b, String description) {
if (!b) {
- throw newInternal("post-condition failed: " + description);
+ throw new AssertionError("post-condition failed: " + description);
}
}
- /**
- * Checks an invariant.
- *
- * <p>This is similar to <code>assert</code> keyword, except that the
- * condition is always evaluated even if asserts are disabled.
- */
+ /** @deprecated Use {@link Preconditions#checkArgument} */
+ @Deprecated // to be removed before 2.0
public static void permAssert(boolean b, String description) {
if (!b) {
- throw newInternal("invariant violated: " + description);
+ throw new AssertionError("invariant violated: " + description);
}
}
@@ -1533,8 +1520,7 @@ public class Util {
case 3:
return new Locale(strings[0], strings[1], strings[2]);
default:
- throw newInternal(
- "bad locale string '" + localeString + "'");
+ throw new AssertionError("bad locale string '" + localeString + "'");
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java b/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
index e508d7d..af170d9 100644
--- a/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
+++ b/core/src/main/java/org/apache/calcite/util/javac/JaninoCompiler.java
@@ -16,8 +16,6 @@
*/
package org.apache.calcite.util.javac;
-import org.apache.calcite.util.Util;
-
import org.codehaus.janino.JavaSourceClassLoader;
import org.codehaus.janino.util.ClassFile;
import org.codehaus.janino.util.resource.MapResourceFinder;
@@ -81,7 +79,7 @@ public class JaninoCompiler implements JavaCompiler {
try {
classLoader.loadClass(args.fullClassName);
} catch (ClassNotFoundException ex) {
- throw Util.newInternal(ex, "while compiling " + args.fullClassName);
+ throw new RuntimeException("while compiling " + args.fullClassName, ex);
}
}
@@ -156,12 +154,11 @@ public class JaninoCompiler implements JavaCompiler {
return nBytes;
}
- // override JavaSourceClassLoader
- public Map generateBytecodes(String name)
+ @Override public Map<String, byte[]> generateBytecodes(String name)
throws ClassNotFoundException {
- Map<String, byte[]> map = super.generateBytecodes(name);
+ final Map<String, byte[]> map = super.generateBytecodes(name);
if (map == null) {
- return map;
+ return null;
}
if (destDir != null) {
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/plan/volcano/VolcanoPlannerTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/plan/volcano/VolcanoPlannerTest.java b/core/src/test/java/org/apache/calcite/plan/volcano/VolcanoPlannerTest.java
index 041eb2c..b4a2557 100644
--- a/core/src/test/java/org/apache/calcite/plan/volcano/VolcanoPlannerTest.java
+++ b/core/src/test/java/org/apache/calcite/plan/volcano/VolcanoPlannerTest.java
@@ -31,7 +31,6 @@ import org.apache.calcite.rel.convert.ConverterRule;
import org.apache.calcite.rel.logical.LogicalProject;
import org.apache.calcite.rel.rules.ProjectRemoveRule;
import org.apache.calcite.rex.RexInputRef;
-import org.apache.calcite.util.Util;
import com.google.common.collect.ImmutableList;
@@ -520,12 +519,10 @@ public class VolcanoPlannerTest {
operand(PhysLeafRel.class, any())));
}
- // implement RelOptRule
- public Convention getOutConvention() {
+ @Override public Convention getOutConvention() {
return PHYS_CALLING_CONVENTION;
}
- // implement RelOptRule
public void onMatch(RelOptRuleCall call) {
NoneSingleRel singleRel = call.rel(0);
RelNode childRel = call.rel(1);
@@ -546,12 +543,10 @@ public class VolcanoPlannerTest {
super(operand(LogicalProject.class, any()));
}
- // implement RelOptRule
- public Convention getOutConvention() {
+ @Override public Convention getOutConvention() {
return PHYS_CALLING_CONVENTION;
}
- // implement RelOptRule
public void onMatch(RelOptRuleCall call) {
final LogicalProject project = call.rel(0);
RelNode childRel = project.getInput();
@@ -571,12 +566,10 @@ public class VolcanoPlannerTest {
operand(PhysLeafRel.class, any())));
}
- // implement RelOptRule
- public Convention getOutConvention() {
+ @Override public Convention getOutConvention() {
return PHYS_CALLING_CONVENTION;
}
- // implement RelOptRule
public void onMatch(RelOptRuleCall call) {
PhysSingleRel singleRel = call.rel(0);
PhysLeafRel leafRel = call.rel(1);
@@ -596,12 +589,10 @@ public class VolcanoPlannerTest {
operand(PhysLeafRel.class, any())));
}
- // implement RelOptRule
public Convention getOutConvention() {
return PHYS_CALLING_CONVENTION;
}
- // implement RelOptRule
public void onMatch(RelOptRuleCall call) {
NoneSingleRel singleRel = call.rel(0);
PhysLeafRel leafRel = call.rel(1);
@@ -628,18 +619,15 @@ public class VolcanoPlannerTest {
eventList.add(event);
}
- // implement RelOptListener
public void relChosen(RelChosenEvent event) {
recordEvent(event);
}
- // implement RelOptListener
public void relDiscarded(RelDiscardedEvent event) {
- // Volcano is quite a packrat--it never discards anything!
- throw Util.newInternal(event.toString());
+ // Volcano is quite a pack rat--it never discards anything!
+ throw new AssertionError(event);
}
- // implement RelOptListener
public void relEquivalenceFound(RelEquivalenceEvent event) {
if (!event.isPhysical()) {
return;
@@ -647,12 +635,10 @@ public class VolcanoPlannerTest {
recordEvent(event);
}
- // implement RelOptListener
public void ruleAttempted(RuleAttemptedEvent event) {
recordEvent(event);
}
- // implement RelOptListener
public void ruleProductionSucceeded(RuleProductionEvent event) {
recordEvent(event);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
index b97ed3f..88c3ffb 100644
--- a/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
+++ b/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java
@@ -40,7 +40,6 @@ import org.apache.calcite.tools.RuleSets;
import org.apache.calcite.util.Util;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import org.junit.Test;
@@ -567,10 +566,6 @@ public class RelToSqlConverterTest {
return new Sql(schemaSpec, sql, dialect, transforms);
}
- Sql planner(Planner planner) {
- return new Sql(schemaSpec, sql, dialect, transforms);
- }
-
Sql optimize(final RuleSet ruleSet, final RelOptPlanner relOptPlanner) {
return new Sql(schemaSpec, sql, dialect,
FlatLists.append(transforms, new Function<RelNode, RelNode>() {
@@ -596,8 +591,10 @@ public class RelToSqlConverterTest {
final SqlNode sqlNode = converter.visitChild(0, rel).asStatement();
assertThat(Util.toLinux(sqlNode.toSqlString(dialect).getSql()),
is(expectedQuery));
+ } catch (RuntimeException e) {
+ throw e;
} catch (Exception e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
return this;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
index 38c0e68..54fce65 100644
--- a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
@@ -33,7 +33,6 @@ import org.apache.calcite.util.ConversionUtil;
import org.apache.calcite.util.TestUtil;
import org.apache.calcite.util.Util;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSortedSet;
@@ -7193,7 +7192,7 @@ public class SqlParserTest {
final SqlNode sqlNode = getSqlParser(sap.sql).parseStmt();
assertThat(sqlNode, matcher);
} catch (SqlParseException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
index 4861506..71df5c5 100644
--- a/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/test/SqlOperatorBaseTest.java
@@ -51,7 +51,6 @@ import org.apache.calcite.test.SqlLimitsTest;
import org.apache.calcite.util.Bug;
import org.apache.calcite.util.Holder;
import org.apache.calcite.util.Pair;
-import org.apache.calcite.util.Util;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
@@ -1410,10 +1409,10 @@ public abstract class SqlOperatorBaseTest {
return cal;
default:
- throw Util.newInternal("unexpected time unit " + timeUnit);
+ throw new AssertionError("unexpected time unit: " + timeUnit);
}
} catch (InterruptedException e) {
- throw Util.newInternal(e);
+ throw new RuntimeException(e);
}
}
}
@@ -6410,8 +6409,10 @@ public abstract class SqlOperatorBaseTest {
final ResultSet resultSet =
statement.executeQuery(query);
resultChecker.checkResult(resultSet);
+ } catch (RuntimeException e) {
+ throw e;
} catch (Exception e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/DiffRepository.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/DiffRepository.java b/core/src/test/java/org/apache/calcite/test/DiffRepository.java
index 90ecc83..622c526 100644
--- a/core/src/test/java/org/apache/calcite/test/DiffRepository.java
+++ b/core/src/test/java/org/apache/calcite/test/DiffRepository.java
@@ -217,7 +217,7 @@ public class DiffRepository {
+ "', but found '" + root.getNodeName() + "'");
}
} catch (ParserConfigurationException | SAXException e) {
- throw Util.newInternal(e, "error while creating xml parser");
+ throw new RuntimeException("error while creating xml parser", e);
}
indent = logFile.getPath().contains("RelOptRulesTest")
|| logFile.getPath().contains("SqlToRelConverterTest")
@@ -523,23 +523,15 @@ public class DiffRepository {
* Flushes the reference document to the file system.
*/
private void flushDoc() {
- FileWriter w = null;
try {
boolean b = logFile.getParentFile().mkdirs();
Util.discard(b);
- w = new FileWriter(logFile);
- write(doc, w, indent);
- } catch (IOException e) {
- throw Util.newInternal(e,
- "error while writing test reference log '" + logFile + "'");
- } finally {
- if (w != null) {
- try {
- w.close();
- } catch (IOException e) {
- // ignore
- }
+ try (FileWriter w = new FileWriter(logFile)) {
+ write(doc, w, indent);
}
+ } catch (IOException e) {
+ throw new RuntimeException("error while writing test reference log '"
+ + logFile + "'", e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java b/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
index 3e7c301..61dee87 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcAdapterTest.java
@@ -22,7 +22,6 @@ import org.apache.calcite.test.CalciteAssert.AssertThat;
import org.apache.calcite.test.CalciteAssert.DatabaseInstance;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import org.hsqldb.jdbcDriver;
@@ -579,7 +578,7 @@ public class JdbcAdapterTest {
assertFalse(CalciteAssert.toString(resultSet).isEmpty());
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
@@ -677,7 +676,7 @@ public class JdbcAdapterTest {
.planUpdateHasSql(jdbcSql, 1);
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
@@ -713,7 +712,7 @@ public class JdbcAdapterTest {
.planUpdateHasSql(jdbcSql, 2);
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
@@ -753,7 +752,7 @@ public class JdbcAdapterTest {
.planUpdateHasSql(jdbcSql, 1);
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
@@ -783,7 +782,7 @@ public class JdbcAdapterTest {
.planUpdateHasSql(jdbcSql, 1);
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
@@ -810,7 +809,7 @@ public class JdbcAdapterTest {
.planUpdateHasSql(jdbcSql, 1);
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/JdbcFrontLinqBackTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcFrontLinqBackTest.java b/core/src/test/java/org/apache/calcite/test/JdbcFrontLinqBackTest.java
index f5ae8c9..73b1bb8 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcFrontLinqBackTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcFrontLinqBackTest.java
@@ -31,7 +31,6 @@ import org.apache.calcite.schema.impl.AbstractSchema;
import org.apache.calcite.schema.impl.AbstractTableQueryable;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import org.junit.Ignore;
import org.junit.Test;
@@ -262,7 +261,7 @@ public class JdbcFrontLinqBackTest {
}
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index 25d3dcf..701c8c9 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -98,7 +98,6 @@ import org.apache.calcite.util.TryThreadLocal;
import org.apache.calcite.util.Util;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
@@ -315,7 +314,7 @@ public class JdbcTest {
statement.close();
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
@@ -6597,7 +6596,7 @@ public class JdbcTest {
}
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/QuidemTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/QuidemTest.java b/core/src/test/java/org/apache/calcite/test/QuidemTest.java
index 88479c6..f15fe13 100644
--- a/core/src/test/java/org/apache/calcite/test/QuidemTest.java
+++ b/core/src/test/java/org/apache/calcite/test/QuidemTest.java
@@ -46,6 +46,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
+import java.io.FilenameFilter;
import java.lang.reflect.Method;
import java.net.URL;
import java.sql.Connection;
@@ -111,7 +112,8 @@ public class QuidemTest {
final File firstFile = new File(x);
final File dir = firstFile.getParentFile();
final List<String> paths = new ArrayList<>();
- for (File f : dir.listFiles(new PatternFilenameFilter(".*\\.iq$"))) {
+ final FilenameFilter filter = new PatternFilenameFilter(".*\\.iq$");
+ for (File f : Util.first(dir.listFiles(filter), new File[0])) {
assert f.getAbsolutePath().startsWith(base)
: "f: " + f.getAbsolutePath() + "; base: " + base;
paths.add(f.getAbsolutePath().substring(base.length()));
@@ -246,7 +248,8 @@ public class QuidemTest {
}
/** Quidem connection factory for Calcite's built-in test schemas. */
- private static class QuidemConnectionFactory implements Quidem.NewConnectionFactory {
+ private static class QuidemConnectionFactory
+ implements Quidem.ConnectionFactory {
public Connection connect(String name) throws Exception {
return connect(name, false);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java b/core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java
index 606f1d6..41d3e89 100644
--- a/core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java
+++ b/core/src/test/java/org/apache/calcite/test/ReflectiveSchemaTest.java
@@ -37,7 +37,6 @@ import org.apache.calcite.util.Smalls;
import org.apache.calcite.util.Util;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import org.junit.Assert;
@@ -347,7 +346,7 @@ public class ReflectiveSchemaTest {
++n;
}
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
assertThat(n, equalTo(1));
return null;
@@ -580,7 +579,7 @@ public class ReflectiveSchemaTest {
buf.append(input.getInt(2)).append("\n");
}
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
assertThat(buf.toString(), equalTo("0\n2147483647\n"));
return null;
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java b/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
index f11b26a..9bded46 100644
--- a/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelMetadataTest.java
@@ -75,7 +75,6 @@ import org.apache.calcite.util.ImmutableBitSet;
import org.apache.calcite.util.ImmutableIntList;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
@@ -1074,7 +1073,7 @@ public class RelMetadataTest extends SqlToRelTestBase {
join = EnumerableMergeJoin.create(project, deptSort,
rexBuilder.makeLiteral(true), leftKeys, rightKeys, JoinRelType.INNER);
} catch (InvalidRelException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
collations =
RelMdCollation.mergeJoin(mq, project, deptSort, leftKeys,
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
index db7d27c..88ca598 100644
--- a/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RelOptRulesTest.java
@@ -99,7 +99,6 @@ import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.validate.SqlValidator;
import org.apache.calcite.sql2rel.SqlToRelConverter;
import org.apache.calcite.tools.RelBuilder;
-import org.apache.calcite.util.Util;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
@@ -672,7 +671,7 @@ public class RelOptRulesTest extends RelOptTestBase {
.checkUnchanged();
}
- @Test public void testSemiJoinTrim() {
+ @Test public void testSemiJoinTrim() throws Exception {
final DiffRepository diffRepos = getDiffRepos();
String sql = diffRepos.expand(null, "${sql}");
@@ -690,13 +689,7 @@ public class RelOptRulesTest extends RelOptTestBase {
typeFactory,
SqlToRelConverter.Config.DEFAULT);
- final SqlNode sqlQuery;
- try {
- sqlQuery = t.parseQuery(sql);
- } catch (Exception e) {
- throw Util.newInternal(e);
- }
-
+ final SqlNode sqlQuery = t.parseQuery(sql);
final SqlNode validatedQuery = validator.validate(sqlQuery);
RelRoot root =
converter.convertQuery(validatedQuery, false, true);
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
index 3ca7c44..3be7821 100644
--- a/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
+++ b/core/src/test/java/org/apache/calcite/test/RexProgramTest.java
@@ -419,7 +419,7 @@ public class RexProgramTest {
t1));
break;
default:
- throw Util.newInternal("unexpected variant " + variant);
+ throw new AssertionError("unexpected variant " + variant);
}
// $t6 = $t4 + $t2 (i.e. (x + y) + (x + 1))
RexLocalRef t6 =
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/SqlTestGen.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlTestGen.java b/core/src/test/java/org/apache/calcite/test/SqlTestGen.java
index c5ed8c0..e330efc 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlTestGen.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlTestGen.java
@@ -24,7 +24,6 @@ import org.apache.calcite.sql.test.SqlTester;
import org.apache.calcite.sql.test.SqlTesterImpl;
import org.apache.calcite.sql.validate.SqlValidator;
import org.apache.calcite.util.BarfingInvocationHandler;
-import org.apache.calcite.util.Util;
import java.io.File;
import java.io.FileOutputStream;
@@ -51,38 +50,20 @@ public class SqlTestGen {
}
private void genValidatorTest() {
- FileOutputStream fos = null;
- PrintWriter pw = null;
- try {
- File file = new File("validatorTest.sql");
- fos = new FileOutputStream(file);
- pw = new PrintWriter(fos);
+ final File file = new File("validatorTest.sql");
+ try (FileOutputStream fos = new FileOutputStream(file);
+ PrintWriter pw = new PrintWriter(fos)) {
Method[] methods = getJunitMethods(SqlValidatorSpooler.class);
for (Method method : methods) {
final SqlValidatorSpooler test = new SqlValidatorSpooler(pw);
final Object result = method.invoke(test);
assert result == null;
}
- } catch (IOException e) {
- throw Util.newInternal(e);
- } catch (IllegalAccessException e) {
- throw Util.newInternal(e);
- } catch (IllegalArgumentException e) {
- throw Util.newInternal(e);
+ } catch (IOException | IllegalAccessException
+ | IllegalArgumentException e) {
+ throw new RuntimeException(e);
} catch (InvocationTargetException e) {
- e.printStackTrace();
- throw Util.newInternal(e);
- } finally {
- if (pw != null) {
- pw.flush();
- }
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException e) {
- throw Util.newInternal(e);
- }
- }
+ throw new RuntimeException(e.getCause());
}
}
@@ -90,7 +71,7 @@ public class SqlTestGen {
* Returns a list of all of the Junit methods in a given class.
*/
private static Method[] getJunitMethods(Class<SqlValidatorSpooler> clazz) {
- List<Method> list = new ArrayList<Method>();
+ List<Method> list = new ArrayList<>();
for (Method method : clazz.getMethods()) {
if (method.getName().startsWith("test")
&& Modifier.isPublic(method.getModifiers())
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java b/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
index 7520b4a..a74415c 100644
--- a/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
+++ b/core/src/test/java/org/apache/calcite/test/SqlToRelTestBase.java
@@ -55,9 +55,9 @@ import org.apache.calcite.sql2rel.SqlToRelConverter;
import org.apache.calcite.sql2rel.StandardConvertletTable;
import org.apache.calcite.tools.RelBuilder;
import org.apache.calcite.util.ImmutableBitSet;
-import org.apache.calcite.util.Util;
import com.google.common.base.Function;
+import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -522,13 +522,15 @@ public abstract class SqlToRelTestBase {
}
public RelRoot convertSqlToRel(String sql) {
- Util.pre(sql != null, "sql != null");
+ Preconditions.checkNotNull(sql);
final SqlNode sqlQuery;
final SqlToRelConverter.Config localConfig;
try {
sqlQuery = parseQuery(sql);
+ } catch (RuntimeException | Error e) {
+ throw e;
} catch (Exception e) {
- throw Util.newInternal(e); // todo: better handling
+ throw new RuntimeException(e);
}
final RelDataTypeFactory typeFactory = getTypeFactory();
final Prepare.CatalogReader catalogReader =
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/core/src/test/java/org/apache/calcite/test/StreamTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/StreamTest.java b/core/src/test/java/org/apache/calcite/test/StreamTest.java
index ebb420f..2740957 100644
--- a/core/src/test/java/org/apache/calcite/test/StreamTest.java
+++ b/core/src/test/java/org/apache/calcite/test/StreamTest.java
@@ -37,7 +37,6 @@ import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.util.ImmutableBitSet;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -348,7 +347,7 @@ public class StreamTest {
}
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
};
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
----------------------------------------------------------------------
diff --git a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
index 872b6e9..07740c2 100644
--- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
+++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
@@ -26,6 +26,7 @@ import org.apache.calcite.linq4j.Enumerator;
import org.apache.calcite.prepare.CalcitePrepareImpl;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.util.Holder;
+import org.apache.calcite.util.Util;
import static org.apache.calcite.runtime.HttpUtils.post;
@@ -36,7 +37,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.type.CollectionType;
import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -120,7 +120,7 @@ class DruidConnectionImpl implements DruidConnection {
System.out.println("Response: " + new String(bytes));
in = new ByteArrayInputStream(bytes);
} catch (IOException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
@@ -239,7 +239,7 @@ class DruidConnectionImpl implements DruidConnection {
}
}
} catch (IOException | InterruptedException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
@@ -483,7 +483,7 @@ class DruidConnectionImpl implements DruidConnection {
}
}
} catch (IOException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
@@ -505,7 +505,7 @@ class DruidConnectionImpl implements DruidConnection {
final List<String> list = mapper.readValue(in, listType);
return ImmutableSet.copyOf(list);
} catch (IOException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
@@ -517,7 +517,7 @@ class DruidConnectionImpl implements DruidConnection {
System.out.println("Response: " + new String(bytes));
in = new ByteArrayInputStream(bytes);
} catch (IOException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
return in;
@@ -559,10 +559,11 @@ class DruidConnectionImpl implements DruidConnection {
public void reset() {}
public void close() {
- final Throwable throwable = throwableHolder.get();
- if (throwable != null) {
+ final Throwable e = throwableHolder.get();
+ if (e != null) {
throwableHolder.set(null);
- throw Throwables.propagate(throwable);
+ Util.throwIfUnchecked(e);
+ throw new RuntimeException(e);
}
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/druid/src/main/java/org/apache/calcite/adapter/druid/DruidQuery.java
----------------------------------------------------------------------
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 f5c034e..5a40849 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
@@ -64,7 +64,6 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.google.common.base.Preconditions;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -746,7 +745,7 @@ public class DruidQuery extends AbstractRelNode implements BindableRel {
generator.writeEndObject();
generator.close();
} catch (IOException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
return sw.toString();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
----------------------------------------------------------------------
diff --git a/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java b/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
index 97b8188..ea156f4 100644
--- a/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
+++ b/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
@@ -22,7 +22,6 @@ import org.apache.calcite.config.CalciteConnectionProperty;
import org.apache.calcite.util.Util;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimap;
@@ -294,7 +293,7 @@ public class DruidAdapterIT {
assertThat(map.get("BIGINT").size(), is(1));
assertThat(map.get(VARCHAR_TYPE).size(), is(88));
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
return null;
}
@@ -350,7 +349,7 @@ public class DruidAdapterIT {
assertThat(input.next(), is(false));
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
@@ -644,7 +643,7 @@ public class DruidAdapterIT {
assertFalse(resultSet.next());
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
})
@@ -722,7 +721,7 @@ public class DruidAdapterIT {
assertFalse(resultSet.next());
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
})
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchema.java
----------------------------------------------------------------------
diff --git a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchema.java b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchema.java
index e59e0a4..d74f3f5 100644
--- a/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchema.java
+++ b/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchSchema.java
@@ -21,7 +21,6 @@ import org.apache.calcite.schema.impl.AbstractSchema;
import com.carrotsearch.hppc.cursors.ObjectObjectCursor;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@@ -94,8 +93,10 @@ public class ElasticsearchSchema extends AbstractSchema {
for (ObjectObjectCursor<String, MappingMetaData> c: mapping) {
builder.put(c.key, new ElasticsearchTable(client, index, c.key));
}
+ } catch (RuntimeException e) {
+ throw e;
} catch (Exception e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
return builder.build();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvEnumerator.java
----------------------------------------------------------------------
diff --git a/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvEnumerator.java b/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvEnumerator.java
index 716992c..25a3c38 100644
--- a/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvEnumerator.java
+++ b/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvEnumerator.java
@@ -26,8 +26,6 @@ import org.apache.commons.lang3.time.FastDateFormat;
import au.com.bytecode.opencsv.CSVReader;
-import com.google.common.base.Throwables;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
@@ -201,7 +199,7 @@ class CsvEnumerator<E> implements Enumerator<E> {
try {
Thread.sleep(CsvStreamReader.DEFAULT_MONITOR_DELAY);
} catch (InterruptedException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
continue;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvStreamReader.java
----------------------------------------------------------------------
diff --git a/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvStreamReader.java b/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvStreamReader.java
index e97278a..27db047 100644
--- a/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvStreamReader.java
+++ b/example/csv/src/main/java/org/apache/calcite/adapter/csv/CsvStreamReader.java
@@ -23,8 +23,6 @@ import org.apache.commons.io.input.TailerListenerAdapter;
import au.com.bytecode.opencsv.CSVParser;
import au.com.bytecode.opencsv.CSVReader;
-import com.google.common.base.Throwables;
-
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
@@ -88,7 +86,7 @@ class CsvStreamReader extends CSVReader implements Closeable {
// wait for tailer to capture data
Thread.sleep(DEFAULT_MONITOR_DELAY);
} catch (InterruptedException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java
----------------------------------------------------------------------
diff --git a/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java b/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java
index 6c381e5..38693ce 100644
--- a/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java
+++ b/example/csv/src/test/java/org/apache/calcite/test/CsvTest.java
@@ -24,7 +24,6 @@ import org.apache.calcite.schema.Schema;
import org.apache.calcite.sql2rel.SqlToRelConverter;
import org.apache.calcite.util.Util;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import org.junit.Assert;
@@ -198,7 +197,7 @@ public class CsvTest {
assertThat(resultSet.next(), is(false));
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
----------------------------------------------------------------------
diff --git a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
index 70c3cde..d60c476 100644
--- a/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
+++ b/mongodb/src/main/java/org/apache/calcite/adapter/mongodb/MongoRules.java
@@ -98,7 +98,8 @@ public class MongoRules {
@Override public int size() {
return rowType.getFieldCount();
}
- });
+ },
+ SqlValidatorUtil.EXPR_SUGGESTER, true);
}
static String maybeQuote(String s) {
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterIT.java
----------------------------------------------------------------------
diff --git a/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterIT.java b/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterIT.java
index 25b39ac..3550711 100644
--- a/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterIT.java
+++ b/mongodb/src/test/java/org/apache/calcite/test/MongoAdapterIT.java
@@ -22,7 +22,6 @@ import org.apache.calcite.util.Pair;
import org.apache.calcite.util.Util;
import com.google.common.base.Function;
-import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Ordering;
@@ -833,7 +832,7 @@ public class MongoAdapterIT {
assertThat(input.getInt(1), CoreMatchers.is(29353));
return null;
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}
});
http://git-wip-us.apache.org/repos/asf/calcite/blob/603648bc/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java
----------------------------------------------------------------------
diff --git a/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java b/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java
index 1c83e2f..66cb671 100644
--- a/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java
+++ b/piglet/src/test/java/org/apache/calcite/test/CalciteHandler.java
@@ -21,8 +21,6 @@ import org.apache.calcite.rel.RelNode;
import org.apache.calcite.tools.PigRelBuilder;
import org.apache.calcite.tools.RelRunners;
-import com.google.common.base.Throwables;
-
import java.io.PrintWriter;
import java.io.Writer;
import java.sql.Array;
@@ -48,7 +46,7 @@ class CalciteHandler extends Handler {
final ResultSet resultSet = preparedStatement.executeQuery();
dump(resultSet, true);
} catch (SQLException e) {
- throw Throwables.propagate(e);
+ throw new RuntimeException(e);
}
}