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:23 UTC
[9/9] calcite git commit: [CALCITE-1602] Remove uses of deprecated
APIs
[CALCITE-1602] Remove uses of deprecated APIs
Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/5181563f
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/5181563f
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/5181563f
Branch: refs/heads/master
Commit: 5181563f9f26d1533a7d98ecca8443077e7b7efa
Parents: d335e48
Author: Julian Hyde <jh...@apache.org>
Authored: Tue Jan 24 11:49:40 2017 -0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Wed Jan 25 11:21:36 2017 -0800
----------------------------------------------------------------------
.../avatica/AvaticaPreparedStatement.java | 1 +
.../calcite/avatica/AvaticaResultSet.java | 4 ++
.../apache/calcite/avatica/AvaticaUtils.java | 2 +-
.../calcite/avatica/UnregisteredDriver.java | 8 +--
.../calcite/avatica/remote/RemoteMeta.java | 2 +
.../apache/calcite/avatica/remote/Service.java | 4 +-
.../calcite/avatica/util/AbstractCursor.java | 2 +-
.../AvaticaResultSetConversionsTest.java | 2 +
.../calcite/avatica/MetaResultSetTest.java | 2 +
.../avatica/remote/KerberosConnectionTest.java | 2 +-
.../noop/AvaticaNoopPreparedStatement.java | 1 +
.../avatica/noop/AvaticaNoopResultSet.java | 4 ++
avatica/pom.xml | 1 +
.../apache/calcite/avatica/jdbc/JdbcMeta.java | 2 +
.../server/DelegatingAvaticaHandler.java | 2 +-
.../calcite/avatica/server/HttpServer.java | 2 +-
.../org/apache/calcite/avatica/server/Main.java | 22 +++++----
.../calcite/adapter/enumerable/RexImpTable.java | 3 +-
.../calcite/adapter/java/ReflectiveSchema.java | 22 ++++-----
.../calcite/interpreter/AggregateNode.java | 8 ++-
.../apache/calcite/interpreter/Interpreter.java | 1 +
.../apache/calcite/jdbc/CalciteMetaImpl.java | 2 +
.../calcite/plan/AbstractRelOptPlanner.java | 2 +
.../calcite/prepare/CalciteCatalogReader.java | 3 ++
.../org/apache/calcite/prepare/PlannerImpl.java | 1 +
.../org/apache/calcite/rel/AbstractRelNode.java | 8 +++
.../java/org/apache/calcite/rel/core/Sort.java | 1 +
.../org/apache/calcite/rel/core/TableScan.java | 1 +
.../rel/type/RelDataTypeFactoryImpl.java | 24 +++++----
.../java/org/apache/calcite/rex/RexBuilder.java | 7 +--
.../org/apache/calcite/rex/RexCallBinding.java | 2 +
.../org/apache/calcite/rex/RexExecutable.java | 9 +++-
.../apache/calcite/runtime/SqlFunctions.java | 10 ++--
.../calcite/schema/impl/TableFunctionImpl.java | 10 ++--
.../calcite/schema/impl/TableMacroImpl.java | 12 ++---
.../org/apache/calcite/sql/SqlCallBinding.java | 2 +
.../apache/calcite/sql/SqlFilterOperator.java | 5 +-
.../apache/calcite/sql/SqlIntervalLiteral.java | 1 +
.../apache/calcite/sql/SqlJdbcFunctionCall.java | 3 +-
.../org/apache/calcite/sql/SqlOperator.java | 5 +-
.../org/apache/calcite/sql/SqlOverOperator.java | 5 +-
.../apache/calcite/sql/fun/SqlCaseOperator.java | 5 +-
.../apache/calcite/sql/fun/SqlCastFunction.java | 7 +--
.../calcite/sql/fun/SqlCountAggFunction.java | 2 +
.../sql/fun/SqlFirstLastValueAggFunction.java | 2 +
.../sql/fun/SqlHistogramAggFunction.java | 2 +
.../apache/calcite/sql/fun/SqlInOperator.java | 5 +-
.../calcite/sql/fun/SqlMinMaxAggFunction.java | 2 +
.../sql/fun/SqlSingleValueAggFunction.java | 2 +
.../calcite/sql/fun/SqlSumAggFunction.java | 2 +
.../sql/fun/SqlSumEmptyIsZeroAggFunction.java | 2 +
.../calcite/sql/validate/AbstractNamespace.java | 1 +
.../sql/validate/DelegatingNamespace.java | 1 +
.../calcite/sql/validate/DelegatingScope.java | 2 +
.../apache/calcite/sql/validate/EmptyScope.java | 2 +
.../apache/calcite/sql/validate/ListScope.java | 2 +-
.../sql/validate/SqlUserDefinedAggFunction.java | 2 +
.../calcite/sql/validate/SqlValidatorImpl.java | 52 ++++++++++----------
.../calcite/sql2rel/SqlToRelConverter.java | 3 +-
.../sql2rel/StandardConvertletTable.java | 3 +-
.../org/apache/calcite/util/NumberUtil.java | 3 +-
.../concurrent/ConcurrentTestCommandScript.java | 16 +++---
.../org/apache/calcite/tools/PlannerTest.java | 2 +
.../apache/calcite/util/ReflectVisitorTest.java | 30 ++++++-----
.../java/org/apache/calcite/util/UtilTest.java | 17 ++++---
.../adapter/druid/DruidConnectionImpl.java | 1 +
.../elasticsearch/ElasticsearchRules.java | 26 +++++-----
.../org/apache/calcite/linq4j/tree/Types.java | 4 +-
.../apache/calcite/linq4j/test/Linq4jTest.java | 9 ++--
pom.xml | 1 +
.../calcite/adapter/spark/SparkHandlerImpl.java | 20 ++++----
71 files changed, 267 insertions(+), 171 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaPreparedStatement.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaPreparedStatement.java b/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaPreparedStatement.java
index 5e25a03..31cdfd2 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaPreparedStatement.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaPreparedStatement.java
@@ -197,6 +197,7 @@ public abstract class AvaticaPreparedStatement
getSite(parameterIndex).setAsciiStream(x, length);
}
+ @SuppressWarnings("deprecation")
public void setUnicodeStream(int parameterIndex, InputStream x, int length)
throws SQLException {
getSite(parameterIndex).setUnicodeStream(x, length);
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java b/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
index cfeff03..a102eba 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaResultSet.java
@@ -273,6 +273,7 @@ public class AvaticaResultSet implements ResultSet, ArrayImpl.Factory {
return getAccessor(columnIndex).getDouble();
}
+ @SuppressWarnings("deprecation")
public BigDecimal getBigDecimal(
int columnIndex, int scale) throws SQLException {
return getAccessor(columnIndex).getBigDecimal(scale);
@@ -298,6 +299,7 @@ public class AvaticaResultSet implements ResultSet, ArrayImpl.Factory {
return getAccessor(columnIndex).getAsciiStream();
}
+ @SuppressWarnings("deprecation")
public InputStream getUnicodeStream(int columnIndex) throws SQLException {
return getAccessor(columnIndex).getUnicodeStream();
}
@@ -338,6 +340,7 @@ public class AvaticaResultSet implements ResultSet, ArrayImpl.Factory {
return getAccessor(columnLabel).getDouble();
}
+ @SuppressWarnings("deprecation")
public BigDecimal getBigDecimal(
String columnLabel, int scale) throws SQLException {
return getAccessor(columnLabel).getBigDecimal(scale);
@@ -363,6 +366,7 @@ public class AvaticaResultSet implements ResultSet, ArrayImpl.Factory {
return getAccessor(columnLabel).getAsciiStream();
}
+ @SuppressWarnings("deprecation")
public InputStream getUnicodeStream(String columnLabel) throws SQLException {
return getAccessor(columnLabel).getUnicodeStream();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaUtils.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaUtils.java b/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaUtils.java
index 8c16959..53aff83 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaUtils.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/AvaticaUtils.java
@@ -234,7 +234,7 @@ public class AvaticaUtils {
} catch (NoSuchFieldException e) {
// ignore
}
- return clazz.newInstance();
+ return clazz.getConstructor().newInstance();
} catch (Exception e) {
throw new RuntimeException("Property '" + className
+ "' not valid for plugin type " + pluginClass.getName(), e);
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/main/java/org/apache/calcite/avatica/UnregisteredDriver.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/UnregisteredDriver.java b/avatica/core/src/main/java/org/apache/calcite/avatica/UnregisteredDriver.java
index b1fe787..4118fd7 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/UnregisteredDriver.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/UnregisteredDriver.java
@@ -113,13 +113,7 @@ public abstract class UnregisteredDriver implements java.sql.Driver {
protected static AvaticaFactory instantiateFactory(String factoryClassName) {
try {
final Class<?> clazz = Class.forName(factoryClassName);
- return (AvaticaFactory) clazz.newInstance();
- } catch (ClassNotFoundException e) {
- throw handle("Error loading factory " + factoryClassName, e);
- } catch (IllegalAccessException e) {
- throw handle("Error loading factory " + factoryClassName, e);
- } catch (InstantiationException e) {
- throw handle("Error loading factory " + factoryClassName, e);
+ return (AvaticaFactory) clazz.getConstructor().newInstance();
} catch (Throwable e) {
// It is not usually good to catch Throwable. But class loading can fail
// with serious errors such as java.lang.NoClassDefFoundError
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/main/java/org/apache/calcite/avatica/remote/RemoteMeta.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/remote/RemoteMeta.java b/avatica/core/src/main/java/org/apache/calcite/avatica/remote/RemoteMeta.java
index 7ee2226..75b9d58 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/remote/RemoteMeta.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/remote/RemoteMeta.java
@@ -244,6 +244,7 @@ class RemoteMeta extends MetaImpl {
});
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult prepareAndExecute(StatementHandle h, String sql, long maxRowCount,
PrepareCallback callback) throws NoSuchStatementException {
// The old semantics were that maxRowCount was also treated as the maximum number of
@@ -327,6 +328,7 @@ class RemoteMeta extends MetaImpl {
}
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues,
long maxRowCount) throws NoSuchStatementException {
return execute(h, parameterValues, AvaticaUtils.toSaturatedInt(maxRowCount));
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/main/java/org/apache/calcite/avatica/remote/Service.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/remote/Service.java b/avatica/core/src/main/java/org/apache/calcite/avatica/remote/Service.java
index 1f398ef..786d07a 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/remote/Service.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/remote/Service.java
@@ -1776,7 +1776,7 @@ public interface Service {
connectionId = msg.getConnectionId();
}
- Map<String, String> info = msg.getInfo();
+ Map<String, String> info = msg.getInfoMap();
if (info.isEmpty()) {
info = null;
}
@@ -1790,7 +1790,7 @@ public interface Service {
builder.setConnectionId(connectionId);
}
if (null != info) {
- builder.getMutableInfo().putAll(info);
+ builder.putAllInfo(info);
}
return builder.build();
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java b/avatica/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
index 74fb803..3bf69d6 100644
--- a/avatica/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
+++ b/avatica/core/src/main/java/org/apache/calcite/avatica/util/AbstractCursor.java
@@ -704,7 +704,7 @@ public abstract class AbstractCursor implements Cursor {
}
BigDecimal decimal = AvaticaSite.toBigDecimal(n);
if (0 != scale) {
- return decimal.setScale(scale, BigDecimal.ROUND_UNNECESSARY);
+ return decimal.setScale(scale, RoundingMode.UNNECESSARY);
}
return decimal;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/test/java/org/apache/calcite/avatica/AvaticaResultSetConversionsTest.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/test/java/org/apache/calcite/avatica/AvaticaResultSetConversionsTest.java b/avatica/core/src/test/java/org/apache/calcite/avatica/AvaticaResultSetConversionsTest.java
index 79b1dca..95d160b 100644
--- a/avatica/core/src/test/java/org/apache/calcite/avatica/AvaticaResultSetConversionsTest.java
+++ b/avatica/core/src/test/java/org/apache/calcite/avatica/AvaticaResultSetConversionsTest.java
@@ -85,6 +85,7 @@ public class AvaticaResultSetConversionsTest {
throw new UnsupportedOperationException();
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult prepareAndExecute(StatementHandle h, String sql,
long maxRowCount, PrepareCallback callback) throws NoSuchStatementException {
throw new UnsupportedOperationException();
@@ -190,6 +191,7 @@ public class AvaticaResultSetConversionsTest {
throw new UnsupportedOperationException();
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues,
long maxRowCount) throws NoSuchStatementException {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/test/java/org/apache/calcite/avatica/MetaResultSetTest.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/test/java/org/apache/calcite/avatica/MetaResultSetTest.java b/avatica/core/src/test/java/org/apache/calcite/avatica/MetaResultSetTest.java
index 64eebda..6ec1dc7 100644
--- a/avatica/core/src/test/java/org/apache/calcite/avatica/MetaResultSetTest.java
+++ b/avatica/core/src/test/java/org/apache/calcite/avatica/MetaResultSetTest.java
@@ -68,6 +68,7 @@ public class MetaResultSetTest {
throw new UnsupportedOperationException();
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult prepareAndExecute(StatementHandle h, String sql,
long maxRowCount, PrepareCallback callback) throws NoSuchStatementException {
throw new UnsupportedOperationException();
@@ -94,6 +95,7 @@ public class MetaResultSetTest {
throw new UnsupportedOperationException();
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues,
long maxRowCount) throws NoSuchStatementException {
throw new UnsupportedOperationException();
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/core/src/test/java/org/apache/calcite/avatica/remote/KerberosConnectionTest.java
----------------------------------------------------------------------
diff --git a/avatica/core/src/test/java/org/apache/calcite/avatica/remote/KerberosConnectionTest.java b/avatica/core/src/test/java/org/apache/calcite/avatica/remote/KerberosConnectionTest.java
index 4122afd..a57b95b 100644
--- a/avatica/core/src/test/java/org/apache/calcite/avatica/remote/KerberosConnectionTest.java
+++ b/avatica/core/src/test/java/org/apache/calcite/avatica/remote/KerberosConnectionTest.java
@@ -32,7 +32,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.nullable;
import static org.mockito.Mockito.verify;
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopPreparedStatement.java
----------------------------------------------------------------------
diff --git a/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopPreparedStatement.java b/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopPreparedStatement.java
index b8ad8cc..0d936ed 100644
--- a/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopPreparedStatement.java
+++ b/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopPreparedStatement.java
@@ -243,6 +243,7 @@ public class AvaticaNoopPreparedStatement implements PreparedStatement {
@Override public void setAsciiStream(int parameterIndex, InputStream x, int length)
throws SQLException {}
+ @SuppressWarnings("deprecation")
@Override public void setUnicodeStream(int parameterIndex, InputStream x, int length)
throws SQLException {}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopResultSet.java
----------------------------------------------------------------------
diff --git a/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopResultSet.java b/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopResultSet.java
index 2d71184..022f610 100644
--- a/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopResultSet.java
+++ b/avatica/noop-driver/src/main/java/org/apache/calcite/avatica/noop/AvaticaNoopResultSet.java
@@ -105,6 +105,7 @@ public class AvaticaNoopResultSet implements ResultSet {
throw unsupported();
}
+ @SuppressWarnings("deprecation")
@Override public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
throw unsupported();
}
@@ -129,6 +130,7 @@ public class AvaticaNoopResultSet implements ResultSet {
throw unsupported();
}
+ @SuppressWarnings("deprecation")
@Override public InputStream getUnicodeStream(int columnIndex) throws SQLException {
throw unsupported();
}
@@ -169,6 +171,7 @@ public class AvaticaNoopResultSet implements ResultSet {
throw unsupported();
}
+ @SuppressWarnings("deprecation")
@Override public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
throw unsupported();
}
@@ -193,6 +196,7 @@ public class AvaticaNoopResultSet implements ResultSet {
throw unsupported();
}
+ @SuppressWarnings("deprecation")
@Override public InputStream getUnicodeStream(String columnLabel) throws SQLException {
throw unsupported();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/pom.xml
----------------------------------------------------------------------
diff --git a/avatica/pom.xml b/avatica/pom.xml
index 02a5d20..d8952aa 100644
--- a/avatica/pom.xml
+++ b/avatica/pom.xml
@@ -357,6 +357,7 @@ limitations under the License.
<configuration>
<source>1.7</source>
<target>1.7</target>
+ <compilerArgument>-Xlint:deprecation</compilerArgument>
</configuration>
</plugin>
<plugin>
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
----------------------------------------------------------------------
diff --git a/avatica/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java b/avatica/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
index 204421f..e90d78a 100644
--- a/avatica/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
+++ b/avatica/server/src/main/java/org/apache/calcite/avatica/jdbc/JdbcMeta.java
@@ -708,6 +708,7 @@ public class JdbcMeta implements ProtobufMeta {
}
}
+ @SuppressWarnings("deprecation")
public ExecuteResult prepareAndExecute(StatementHandle h, String sql,
long maxRowCount, PrepareCallback callback) throws NoSuchStatementException {
return prepareAndExecute(h, sql, maxRowCount, AvaticaUtils.toSaturatedInt(maxRowCount),
@@ -817,6 +818,7 @@ public class JdbcMeta implements ProtobufMeta {
return typeList.toArray(new String[typeList.size()]);
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult execute(StatementHandle h, List<TypedValue> parameterValues,
long maxRowCount) throws NoSuchStatementException {
return execute(h, parameterValues, AvaticaUtils.toSaturatedInt(maxRowCount));
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/server/src/main/java/org/apache/calcite/avatica/server/DelegatingAvaticaHandler.java
----------------------------------------------------------------------
diff --git a/avatica/server/src/main/java/org/apache/calcite/avatica/server/DelegatingAvaticaHandler.java b/avatica/server/src/main/java/org/apache/calcite/avatica/server/DelegatingAvaticaHandler.java
index a574985..fff176d 100644
--- a/avatica/server/src/main/java/org/apache/calcite/avatica/server/DelegatingAvaticaHandler.java
+++ b/avatica/server/src/main/java/org/apache/calcite/avatica/server/DelegatingAvaticaHandler.java
@@ -38,7 +38,7 @@ import javax.servlet.http.HttpServletResponse;
* <p>This implementation provides a no-op implementation for
* {@link #setServerRpcMetadata(org.apache.calcite.avatica.remote.Service.RpcMetadataResponse)}.
*
- * Does not implement {@link MetricsAwareAvaticaHandler} as this implementation is only presented
+ * <p>Does not implement {@link MetricsAwareAvaticaHandler} as this implementation is only presented
* for backwards compatibility.
*/
public class DelegatingAvaticaHandler implements AvaticaHandler {
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/server/src/main/java/org/apache/calcite/avatica/server/HttpServer.java
----------------------------------------------------------------------
diff --git a/avatica/server/src/main/java/org/apache/calcite/avatica/server/HttpServer.java b/avatica/server/src/main/java/org/apache/calcite/avatica/server/HttpServer.java
index a8524ec..911d359 100644
--- a/avatica/server/src/main/java/org/apache/calcite/avatica/server/HttpServer.java
+++ b/avatica/server/src/main/java/org/apache/calcite/avatica/server/HttpServer.java
@@ -142,7 +142,7 @@ public class HttpServer {
this.sslFactory = sslFactory;
}
- private static AvaticaHandler wrapJettyHandler(Handler handler) {
+ static AvaticaHandler wrapJettyHandler(Handler handler) {
if (handler instanceof AvaticaHandler) {
return (AvaticaHandler) handler;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/avatica/server/src/main/java/org/apache/calcite/avatica/server/Main.java
----------------------------------------------------------------------
diff --git a/avatica/server/src/main/java/org/apache/calcite/avatica/server/Main.java b/avatica/server/src/main/java/org/apache/calcite/avatica/server/Main.java
index 8b05931..f2d546b 100644
--- a/avatica/server/src/main/java/org/apache/calcite/avatica/server/Main.java
+++ b/avatica/server/src/main/java/org/apache/calcite/avatica/server/Main.java
@@ -22,6 +22,7 @@ import org.apache.calcite.avatica.remote.Service;
import org.eclipse.jetty.server.handler.AbstractHandler;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
/**
@@ -30,9 +31,9 @@ import java.util.Arrays;
public class Main {
private Main() {}
- public static void main(String[] args)
- throws InterruptedException, ClassNotFoundException,
- IllegalAccessException, InstantiationException {
+ public static void main(String[] args) throws InterruptedException, ClassNotFoundException,
+ IllegalAccessException, InstantiationException, NoSuchMethodException,
+ InvocationTargetException {
HttpServer server = start(args);
server.join();
}
@@ -64,7 +65,8 @@ public class Main {
* @param args Command-line arguments
*/
public static HttpServer start(String[] args) throws ClassNotFoundException,
- InstantiationException, IllegalAccessException {
+ InstantiationException, IllegalAccessException, NoSuchMethodException,
+ InvocationTargetException {
return start(args, 8765, JSON_HANDLER_FACTORY);
}
@@ -84,14 +86,16 @@ public class Main {
* @param handlerFactory Factory to create the handler used by the server
*/
public static HttpServer start(String[] args, int port, HandlerFactory handlerFactory)
- throws ClassNotFoundException, InstantiationException,
- IllegalAccessException {
+ throws ClassNotFoundException, InstantiationException, IllegalAccessException,
+ NoSuchMethodException, InvocationTargetException {
String factoryClassName = args[0];
- Class<?> factoryClass = Class.forName(factoryClassName);
- Meta.Factory factory = (Meta.Factory) factoryClass.newInstance();
+ @SuppressWarnings("unchecked") Class<Meta.Factory> factoryClass =
+ (Class<Meta.Factory>) Class.forName(factoryClassName);
+ Meta.Factory factory = factoryClass.getConstructor().newInstance();
Meta meta = factory.create(Arrays.asList(args).subList(1, args.length));
Service service = new LocalService(meta);
- HttpServer server = new HttpServer(port, handlerFactory.createHandler(service));
+ HttpServer server = new HttpServer(port,
+ HttpServer.wrapJettyHandler(handlerFactory.createHandler(service)));
server.start();
return server;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
index 3d87041..eff8cc1 100644
--- a/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
+++ b/core/src/main/java/org/apache/calcite/adapter/enumerable/RexImpTable.java
@@ -65,6 +65,7 @@ import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -1035,7 +1036,7 @@ public class RexImpTable {
Expressions.constant(divider.intValueExact()));
}
final BigDecimal x =
- multiplier.divide(divider, BigDecimal.ROUND_UNNECESSARY);
+ multiplier.divide(divider, RoundingMode.UNNECESSARY);
switch (x.compareTo(BigDecimal.ONE)) {
case 0:
return e;
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/adapter/java/ReflectiveSchema.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/adapter/java/ReflectiveSchema.java b/core/src/main/java/org/apache/calcite/adapter/java/ReflectiveSchema.java
index a7155a1..91fe3e7 100644
--- a/core/src/main/java/org/apache/calcite/adapter/java/ReflectiveSchema.java
+++ b/core/src/main/java/org/apache/calcite/adapter/java/ReflectiveSchema.java
@@ -49,6 +49,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -62,7 +63,7 @@ import java.util.Map;
*/
public class ReflectiveSchema
extends AbstractSchema {
- final Class clazz;
+ private final Class clazz;
private Object target;
/**
@@ -148,7 +149,7 @@ public class ReflectiveSchema
}
@SuppressWarnings("unchecked")
final Enumerable<T> enumerable = toEnumerable(o);
- return new FieldTable<T>(field, elementType, enumerable);
+ return new FieldTable<>(field, elementType, enumerable);
}
/** Deduces the element type of a collection;
@@ -185,7 +186,7 @@ public class ReflectiveSchema
private final Type elementType;
private final Enumerable enumerable;
- public ReflectiveTable(Type elementType, Enumerable enumerable) {
+ ReflectiveTable(Type elementType, Enumerable enumerable) {
super(elementType);
this.elementType = elementType;
this.enumerable = enumerable;
@@ -254,7 +255,7 @@ public class ReflectiveSchema
public static class Factory implements SchemaFactory {
public Schema create(SchemaPlus parentSchema, String name,
Map<String, Object> operand) {
- Class clazz;
+ Class<?> clazz;
Object target;
final Object className = operand.get("class");
if (className != null) {
@@ -277,7 +278,8 @@ public class ReflectiveSchema
}
} else {
try {
- target = clazz.newInstance();
+ final Constructor<?> constructor = clazz.getConstructor();
+ target = constructor.newInstance();
} catch (Exception e) {
throw new RuntimeException("Error instantiating class " + className,
e);
@@ -292,7 +294,7 @@ public class ReflectiveSchema
implements TableMacro {
private final ReflectiveSchema schema;
- public MethodTableMacro(ReflectiveSchema schema, Method method) {
+ MethodTableMacro(ReflectiveSchema schema, Method method) {
super(method);
this.schema = schema;
assert TranslatableTable.class.isAssignableFrom(method.getReturnType())
@@ -308,9 +310,7 @@ public class ReflectiveSchema
try {
final Object o = method.invoke(schema.getTarget(), arguments.toArray());
return (TranslatableTable) o;
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
+ } catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
@@ -320,7 +320,7 @@ public class ReflectiveSchema
private static class FieldTable<T> extends ReflectiveTable {
private final Field field;
- public FieldTable(Field field, Type elementType, Enumerable<T> enumerable) {
+ FieldTable(Field field, Type elementType, Enumerable<T> enumerable) {
super(elementType, enumerable);
this.field = field;
}
@@ -341,7 +341,7 @@ public class ReflectiveSchema
private static class FieldSelector implements Function1<Object, Object[]> {
private final Field[] fields;
- public FieldSelector(Class elementType) {
+ FieldSelector(Class elementType) {
this.fields = elementType.getFields();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java b/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java
index a342b25..5a5d265 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/AggregateNode.java
@@ -45,6 +45,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
@@ -448,8 +449,11 @@ public class AggregateNode extends AbstractSingleNode<Aggregate> {
instance = null;
} else {
try {
- instance = aggFunction.declaringClass.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
+ final Constructor<?> constructor =
+ aggFunction.declaringClass.getConstructor();
+ instance = constructor.newInstance();
+ } catch (InstantiationException | IllegalAccessException
+ | NoSuchMethodException | InvocationTargetException e) {
throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/interpreter/Interpreter.java
----------------------------------------------------------------------
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 5b2752c..0e154eb 100644
--- a/core/src/main/java/org/apache/calcite/interpreter/Interpreter.java
+++ b/core/src/main/java/org/apache/calcite/interpreter/Interpreter.java
@@ -369,6 +369,7 @@ public class Interpreter extends AbstractEnumerable<Object[]>
public void end() throws InterruptedException {
}
+ @SuppressWarnings("deprecation")
@Override public void setSourceEnumerable(Enumerable<Row> enumerable)
throws InterruptedException {
// just copy over the source into the local list
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/jdbc/CalciteMetaImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/jdbc/CalciteMetaImpl.java b/core/src/main/java/org/apache/calcite/jdbc/CalciteMetaImpl.java
index daf6e8b..1cd88e4 100644
--- a/core/src/main/java/org/apache/calcite/jdbc/CalciteMetaImpl.java
+++ b/core/src/main/java/org/apache/calcite/jdbc/CalciteMetaImpl.java
@@ -575,6 +575,7 @@ public class CalciteMetaImpl extends MetaImpl {
return h;
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult prepareAndExecute(StatementHandle h,
String sql, long maxRowCount, PrepareCallback callback)
throws NoSuchStatementException {
@@ -629,6 +630,7 @@ public class CalciteMetaImpl extends MetaImpl {
return new Meta.Frame(offset, done, rows1);
}
+ @SuppressWarnings("deprecation")
@Override public ExecuteResult execute(StatementHandle h,
List<TypedValue> parameterValues, long maxRowCount)
throws NoSuchStatementException {
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java b/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
index eaed2ef..698c790 100644
--- a/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
+++ b/core/src/main/java/org/apache/calcite/plan/AbstractRelOptPlanner.java
@@ -108,6 +108,7 @@ public abstract class AbstractRelOptPlanner implements RelOptPlanner {
return costFactory;
}
+ @SuppressWarnings("deprecation")
public void setCancelFlag(CancelFlag cancelFlag) {
// ignored
}
@@ -242,6 +243,7 @@ public abstract class AbstractRelOptPlanner implements RelOptPlanner {
return mq.getCumulativeCost(rel);
}
+ @SuppressWarnings("deprecation")
public RelOptCost getCost(RelNode rel) {
final RelMetadataQuery mq = RelMetadataQuery.instance();
return getCost(rel, mq);
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java b/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
index 277a6f9..b03f44b 100644
--- a/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
+++ b/core/src/main/java/org/apache/calcite/prepare/CalciteCatalogReader.java
@@ -250,10 +250,12 @@ public class CalciteCatalogReader implements Prepare.CatalogReader {
return getTable(names);
}
+ @SuppressWarnings("deprecation")
public RelDataTypeField field(RelDataType rowType, String alias) {
return nameMatcher.field(rowType, alias);
}
+ @SuppressWarnings("deprecation")
public boolean matches(String string, String name) {
return nameMatcher.matches(string, name);
}
@@ -394,6 +396,7 @@ public class CalciteCatalogReader implements Prepare.CatalogReader {
public void registerRules(RelOptPlanner planner) throws Exception {
}
+ @SuppressWarnings("deprecation")
@Override public boolean isCaseSensitive() {
return nameMatcher.isCaseSensitive();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java b/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
index 635b2c5..a143e1a 100644
--- a/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
+++ b/core/src/main/java/org/apache/calcite/prepare/PlannerImpl.java
@@ -210,6 +210,7 @@ public class PlannerImpl implements Planner {
return Pair.of(validatedNode, type);
}
+ @SuppressWarnings("deprecation")
public final RelNode convert(SqlNode sql) throws RelConversionException {
return rel(sql).rel;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
index 78ac0da..3b6be13 100644
--- a/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
+++ b/core/src/main/java/org/apache/calcite/rel/AbstractRelNode.java
@@ -140,6 +140,7 @@ public abstract class AbstractRelNode implements RelNode {
return collection.get(0);
}
+ @SuppressWarnings("deprecation")
public List<RexNode> getChildExps() {
return ImmutableList.of();
}
@@ -160,11 +161,13 @@ public abstract class AbstractRelNode implements RelNode {
return null;
}
+ @SuppressWarnings("deprecation")
public boolean isDistinct() {
final RelMetadataQuery mq = RelMetadataQuery.instance();
return Boolean.TRUE.equals(mq.areRowsUnique(this));
}
+ @SuppressWarnings("deprecation")
public boolean isKey(ImmutableBitSet columns) {
final RelMetadataQuery mq = RelMetadataQuery.instance();
return Boolean.TRUE.equals(mq.areColumnsUnique(this, columns));
@@ -179,6 +182,7 @@ public abstract class AbstractRelNode implements RelNode {
return inputs.get(i);
}
+ @SuppressWarnings("deprecation")
public final RelOptQuery getQuery() {
return getCluster().getQuery();
}
@@ -204,6 +208,7 @@ public abstract class AbstractRelNode implements RelNode {
return litmus.succeed();
}
+ @SuppressWarnings("deprecation")
public boolean isValid(boolean fail) {
return isValid(Litmus.THROW, null);
}
@@ -236,6 +241,7 @@ public abstract class AbstractRelNode implements RelNode {
return Collections.emptyList();
}
+ @SuppressWarnings("deprecation")
public final double getRows() {
return estimateRowCount(RelMetadataQuery.instance());
}
@@ -244,6 +250,7 @@ public abstract class AbstractRelNode implements RelNode {
return 1.0;
}
+ @SuppressWarnings("deprecation")
public final Set<String> getVariablesStopped() {
return CorrelationId.names(getVariablesSet());
}
@@ -276,6 +283,7 @@ public abstract class AbstractRelNode implements RelNode {
return this;
}
+ @SuppressWarnings("deprecation")
public final RelOptCost computeSelfCost(RelOptPlanner planner) {
return computeSelfCost(planner, RelMetadataQuery.instance());
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/rel/core/Sort.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/Sort.java b/core/src/main/java/org/apache/calcite/rel/core/Sort.java
index ec42fbf..001fcd2 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/Sort.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/Sort.java
@@ -173,6 +173,7 @@ public abstract class Sort extends SingleRel {
return collation;
}
+ @SuppressWarnings("deprecation")
@Override public List<RelCollation> getCollationList() {
return Collections.singletonList(getCollation());
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/rel/core/TableScan.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/core/TableScan.java b/core/src/main/java/org/apache/calcite/rel/core/TableScan.java
index 27f842d..d87715b 100644
--- a/core/src/main/java/org/apache/calcite/rel/core/TableScan.java
+++ b/core/src/main/java/org/apache/calcite/rel/core/TableScan.java
@@ -79,6 +79,7 @@ public abstract class TableScan extends AbstractRelNode {
return table;
}
+ @SuppressWarnings("deprecation")
@Override public List<RelCollation> getCollationList() {
return table.getCollationList();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
index 949c9eb..5457289 100644
--- a/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
+++ b/core/src/main/java/org/apache/calcite/rel/type/RelDataTypeFactoryImpl.java
@@ -147,7 +147,7 @@ public abstract class RelDataTypeFactoryImpl implements RelDataTypeFactory {
return canonize(kind, fieldNameList, typeList);
}
- // implement RelDataTypeFactory
+ @SuppressWarnings("deprecation")
public RelDataType createStructType(
final RelDataTypeFactory.FieldInfo fieldInfo) {
return canonize(StructKind.FULLY_QUALIFIED,
@@ -171,22 +171,26 @@ public abstract class RelDataTypeFactoryImpl implements RelDataTypeFactory {
});
}
- // implement RelDataTypeFactory
public final RelDataType createStructType(
final List<? extends Map.Entry<String, RelDataType>> fieldList) {
- return createStructType(
- new FieldInfo() {
- public int getFieldCount() {
- return fieldList.size();
- }
-
- public String getFieldName(int index) {
+ return canonize(StructKind.FULLY_QUALIFIED,
+ new AbstractList<String>() {
+ @Override public String get(int index) {
return fieldList.get(index).getKey();
}
- public RelDataType getFieldType(int index) {
+ @Override public int size() {
+ return fieldList.size();
+ }
+ },
+ new AbstractList<RelDataType>() {
+ @Override public RelDataType get(int index) {
return fieldList.get(index).getValue();
}
+
+ @Override public int size() {
+ return fieldList.size();
+ }
});
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/rex/RexBuilder.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexBuilder.java b/core/src/main/java/org/apache/calcite/rex/RexBuilder.java
index d8edee9..b6ef396 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexBuilder.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexBuilder.java
@@ -54,6 +54,7 @@ import com.google.common.collect.Lists;
import java.math.BigDecimal;
import java.math.MathContext;
+import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
@@ -536,7 +537,7 @@ public class RexBuilder {
final BigDecimal divider =
literal.getTypeName().getEndUnit().multiplier;
value = value2.multiply(multiplier)
- .divide(divider, 0, BigDecimal.ROUND_HALF_DOWN);
+ .divide(divider, 0, RoundingMode.HALF_DOWN);
}
// Not all types are allowed for literals
@@ -663,12 +664,12 @@ public class RexBuilder {
// E.g. multiplyDivide(e, 1000, 10) ==> e * 100
return makeCall(SqlStdOperatorTable.MULTIPLY, e,
makeExactLiteral(
- multiplier.divide(divider, BigDecimal.ROUND_UNNECESSARY)));
+ multiplier.divide(divider, RoundingMode.UNNECESSARY)));
case -1:
// E.g. multiplyDivide(e, 10, 1000) ==> e / 100
return makeCall(SqlStdOperatorTable.DIVIDE_INTEGER, e,
makeExactLiteral(
- divider.divide(multiplier, BigDecimal.ROUND_UNNECESSARY)));
+ divider.divide(multiplier, RoundingMode.UNNECESSARY)));
default:
throw new AssertionError(multiplier + "/" + divider);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/rex/RexCallBinding.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexCallBinding.java b/core/src/main/java/org/apache/calcite/rex/RexCallBinding.java
index 96ce806..4b21ec4 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexCallBinding.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexCallBinding.java
@@ -71,10 +71,12 @@ public class RexCallBinding extends SqlOperatorBinding {
//~ Methods ----------------------------------------------------------------
+ @SuppressWarnings("deprecation")
@Override public String getStringLiteralOperand(int ordinal) {
return RexLiteral.stringValue(operands.get(ordinal));
}
+ @SuppressWarnings("deprecation")
@Override public int getIntLiteralOperand(int ordinal) {
return RexLiteral.intValue(operands.get(ordinal));
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/rex/RexExecutable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/rex/RexExecutable.java b/core/src/main/java/org/apache/calcite/rex/RexExecutable.java
index 365dd1d..03047f3 100644
--- a/core/src/main/java/org/apache/calcite/rex/RexExecutable.java
+++ b/core/src/main/java/org/apache/calcite/rex/RexExecutable.java
@@ -29,6 +29,8 @@ import org.codehaus.janino.Scanner;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.List;
@@ -58,9 +60,12 @@ public class RexExecutable {
cbe.cook(new Scanner(null, new StringReader(code)));
Class c = cbe.getClazz();
//noinspection unchecked
- return (Function1<DataContext, Object[]>) c.newInstance();
+ final Constructor<Function1<DataContext, Object[]>> constructor =
+ c.getConstructor();
+ return constructor.newInstance();
} catch (CompileException | IOException | InstantiationException
- | IllegalAccessException e) {
+ | IllegalAccessException | InvocationTargetException
+ | NoSuchMethodException e) {
throw new RuntimeException("While compiling " + reason, e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
----------------------------------------------------------------------
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 45c53f3..634067c 100644
--- a/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
+++ b/core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
@@ -724,12 +724,12 @@ public class SqlFunctions {
public static int divide(int b0, BigDecimal b1) {
return BigDecimal.valueOf(b0)
- .divide(b1, BigDecimal.ROUND_HALF_DOWN).intValue();
+ .divide(b1, RoundingMode.HALF_DOWN).intValue();
}
public static long divide(long b0, BigDecimal b1) {
return BigDecimal.valueOf(b0)
- .divide(b1, BigDecimal.ROUND_HALF_DOWN).longValue();
+ .divide(b1, RoundingMode.HALF_DOWN).longValue();
}
// *
@@ -917,7 +917,7 @@ public class SqlFunctions {
}
public static BigDecimal floor(BigDecimal b0) {
- return b0.setScale(0, BigDecimal.ROUND_FLOOR);
+ return b0.setScale(0, RoundingMode.FLOOR);
}
/** SQL <code>FLOOR</code> operator applied to byte values. */
@@ -978,7 +978,7 @@ public class SqlFunctions {
}
public static BigDecimal ceil(BigDecimal b0) {
- return b0.setScale(0, BigDecimal.ROUND_CEILING);
+ return b0.setScale(0, RoundingMode.CEILING);
}
/** SQL <code>CEIL</code> operator applied to byte values. */
@@ -2178,7 +2178,7 @@ public class SqlFunctions {
i += a.length;
}
if (withOrdinality) {
- flatElements[i] = (E) new Integer(++ordinality); // 1-based
+ flatElements[i] = (E) Integer.valueOf(++ordinality); // 1-based
}
return FlatLists.ofComparable(list);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/schema/impl/TableFunctionImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/impl/TableFunctionImpl.java b/core/src/main/java/org/apache/calcite/schema/impl/TableFunctionImpl.java
index 1ef3dfd..7ee55ab 100644
--- a/core/src/main/java/org/apache/calcite/schema/impl/TableFunctionImpl.java
+++ b/core/src/main/java/org/apache/calcite/schema/impl/TableFunctionImpl.java
@@ -35,6 +35,7 @@ import org.apache.calcite.schema.Table;
import org.apache.calcite.schema.TableFunction;
import org.apache.calcite.util.BuiltInMethod;
+import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -143,7 +144,9 @@ public class TableFunctionImpl extends ReflectiveFunctionBase implements
try {
Object o = null;
if (!Modifier.isStatic(method.getModifiers())) {
- o = method.getDeclaringClass().newInstance();
+ final Constructor<?> constructor =
+ method.getDeclaringClass().getConstructor();
+ o = constructor.newInstance();
}
//noinspection unchecked
final Object table = method.invoke(o, arguments.toArray());
@@ -152,10 +155,9 @@ public class TableFunctionImpl extends ReflectiveFunctionBase implements
throw RESOURCE.illegalArgumentForTableFunctionCall(
method.toString(),
Arrays.toString(method.getParameterTypes()),
- arguments.toString()
- ).ex(e);
+ arguments.toString()).ex(e);
} catch (IllegalAccessException | InvocationTargetException
- | InstantiationException e) {
+ | InstantiationException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/schema/impl/TableMacroImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/schema/impl/TableMacroImpl.java b/core/src/main/java/org/apache/calcite/schema/impl/TableMacroImpl.java
index 609a16f..017a457 100644
--- a/core/src/main/java/org/apache/calcite/schema/impl/TableMacroImpl.java
+++ b/core/src/main/java/org/apache/calcite/schema/impl/TableMacroImpl.java
@@ -19,6 +19,7 @@ package org.apache.calcite.schema.impl;
import org.apache.calcite.schema.TableMacro;
import org.apache.calcite.schema.TranslatableTable;
+import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -74,7 +75,9 @@ public class TableMacroImpl extends ReflectiveFunctionBase
try {
Object o = null;
if (!Modifier.isStatic(method.getModifiers())) {
- o = method.getDeclaringClass().newInstance();
+ final Constructor<?> constructor =
+ method.getDeclaringClass().getConstructor();
+ o = constructor.newInstance();
}
//noinspection unchecked
return (TranslatableTable) method.invoke(o, arguments.toArray());
@@ -83,11 +86,8 @@ public class TableMacroImpl extends ReflectiveFunctionBase
+ Arrays.toString(method.getParameterTypes()) + " actual "
+ arguments,
e);
- } catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- } catch (InstantiationException e) {
+ } catch (IllegalAccessException | InvocationTargetException
+ | NoSuchMethodException | InstantiationException e) {
throw new RuntimeException(e);
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/SqlCallBinding.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlCallBinding.java b/core/src/main/java/org/apache/calcite/sql/SqlCallBinding.java
index 77e4b52..91b2ece 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlCallBinding.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlCallBinding.java
@@ -192,12 +192,14 @@ public class SqlCallBinding extends SqlOperatorBinding {
return call.getOperandList().get(ordinal).getMonotonicity(scope);
}
+ @SuppressWarnings("deprecation")
@Override public String getStringLiteralOperand(int ordinal) {
SqlNode node = call.operand(ordinal);
final Object o = SqlLiteral.value(node);
return o instanceof NlsString ? ((NlsString) o).getValue() : null;
}
+ @SuppressWarnings("deprecation")
@Override public int getIntLiteralOperand(int ordinal) {
SqlNode node = call.operand(ordinal);
final Object o = SqlLiteral.value(node);
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/SqlFilterOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlFilterOperator.java b/core/src/main/java/org/apache/calcite/sql/SqlFilterOperator.java
index 5661da3..3c0b527 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlFilterOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlFilterOperator.java
@@ -21,6 +21,7 @@ import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.type.ReturnTypes;
import org.apache.calcite.sql.type.SqlTypeUtil;
import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
import org.apache.calcite.sql.validate.SqlValidatorScope;
import static org.apache.calcite.util.Static.RESOURCE;
@@ -112,8 +113,8 @@ public class SqlFilterOperator extends SqlBinaryOperator {
RelDataType ret = aggCall.getOperator().inferReturnType(opBinding);
// Copied from validateOperands
- validator.setValidatedNodeType(call, ret);
- validator.setValidatedNodeType(agg, ret);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(call, ret);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(agg, ret);
return ret;
}
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java b/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
index a31b8ba..bd2969c 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlIntervalLiteral.java
@@ -84,6 +84,7 @@ public class SqlIntervalLiteral extends SqlLiteral {
writer.keyword(interval.intervalQualifier.toString());
}
+ @SuppressWarnings("deprecation")
public int signum() {
return ((IntervalValue) value).signum();
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java b/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
index 936d2c2..71a7e47 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlJdbcFunctionCall.java
@@ -22,6 +22,7 @@ import org.apache.calcite.sql.fun.SqlTrimFunction;
import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.type.OperandTypes;
import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
import org.apache.calcite.sql.validate.SqlValidatorScope;
import com.google.common.base.Preconditions;
@@ -456,7 +457,7 @@ public class SqlJdbcFunctionCall extends SqlFunction {
for (SqlNode operand : call.getOperandList()) {
RelDataType nodeType = validator.deriveType(scope, operand);
- validator.setValidatedNodeType(operand, nodeType);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType);
}
return validateOperands(validator, scope, call);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
index d558fce..7a65b10 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlOperator.java
@@ -28,6 +28,7 @@ import org.apache.calcite.sql.util.SqlBasicVisitor;
import org.apache.calcite.sql.util.SqlVisitor;
import org.apache.calcite.sql.validate.SqlMonotonicity;
import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
import org.apache.calcite.sql.validate.SqlValidatorScope;
import org.apache.calcite.sql.validate.SqlValidatorUtil;
import org.apache.calcite.util.Litmus;
@@ -434,7 +435,7 @@ public abstract class SqlOperator {
// Now infer the result type.
RelDataType ret = inferReturnType(opBinding);
- validator.setValidatedNodeType(call, ret);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(call, ret);
return ret;
}
@@ -581,7 +582,7 @@ public abstract class SqlOperator {
} else {
nodeType = validator.deriveType(operandScope, operand);
}
- validator.setValidatedNodeType(operand, nodeType);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(operand, nodeType);
argTypeBuilder.add(nodeType);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/SqlOverOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/SqlOverOperator.java b/core/src/main/java/org/apache/calcite/sql/SqlOverOperator.java
index 0c9accc..23ebbc4 100644
--- a/core/src/main/java/org/apache/calcite/sql/SqlOverOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/SqlOverOperator.java
@@ -23,6 +23,7 @@ import org.apache.calcite.sql.type.ReturnTypes;
import org.apache.calcite.sql.util.SqlBasicVisitor;
import org.apache.calcite.sql.util.SqlVisitor;
import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
import org.apache.calcite.sql.validate.SqlValidatorScope;
import static org.apache.calcite.util.Static.RESOURCE;
@@ -105,8 +106,8 @@ public class SqlOverOperator extends SqlBinaryOperator {
RelDataType ret = aggCall.getOperator().inferReturnType(opBinding);
// Copied from validateOperands
- validator.setValidatedNodeType(call, ret);
- validator.setValidatedNodeType(agg, ret);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(call, ret);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(agg, ret);
return ret;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlCaseOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlCaseOperator.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlCaseOperator.java
index 0b060a6..1e5e738 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlCaseOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlCaseOperator.java
@@ -35,6 +35,7 @@ import org.apache.calcite.sql.type.InferTypes;
import org.apache.calcite.sql.type.SqlOperandCountRanges;
import org.apache.calcite.sql.type.SqlTypeUtil;
import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
import org.apache.calcite.sql.validate.SqlValidatorScope;
import org.apache.calcite.util.Pair;
@@ -250,8 +251,10 @@ public class SqlCaseOperator extends SqlOperator {
if (null == ret) {
throw callBinding.newValidationError(RESOURCE.illegalMixingOfTypes());
}
+ final SqlValidatorImpl validator =
+ (SqlValidatorImpl) callBinding.getValidator();
for (SqlNode node : nullList) {
- callBinding.getValidator().setValidatedNodeType(node, ret);
+ validator.setValidatedNodeType(node, ret);
}
return ret;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
index a502a01..8092806 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlCastFunction.java
@@ -37,6 +37,7 @@ import org.apache.calcite.sql.type.SqlOperandCountRanges;
import org.apache.calcite.sql.type.SqlTypeFamily;
import org.apache.calcite.sql.type.SqlTypeUtil;
import org.apache.calcite.sql.validate.SqlMonotonicity;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
import com.google.common.collect.ImmutableSetMultimap;
import com.google.common.collect.SetMultimap;
@@ -101,9 +102,9 @@ public class SqlCastFunction extends SqlFunction {
if (((operand0 instanceof SqlLiteral)
&& (((SqlLiteral) operand0).getValue() == null))
|| (operand0 instanceof SqlDynamicParam)) {
- callBinding.getValidator().setValidatedNodeType(
- operand0,
- ret);
+ final SqlValidatorImpl validator =
+ (SqlValidatorImpl) callBinding.getValidator();
+ validator.setValidatedNodeType(operand0, ret);
}
}
return ret;
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
index dac4b21..ebfa084 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlCountAggFunction.java
@@ -65,12 +65,14 @@ public class SqlCountAggFunction extends SqlAggFunction {
return SqlSyntax.FUNCTION_STAR;
}
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
return ImmutableList.of(
typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.ANY), true));
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
return typeFactory.createSqlType(SqlTypeName.BIGINT);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
index edc6499..72dccd1 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlFirstLastValueAggFunction.java
@@ -60,12 +60,14 @@ public class SqlFirstLastValueAggFunction extends SqlAggFunction {
//~ Methods ----------------------------------------------------------------
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
return ImmutableList.of(
typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.ANY), true));
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
return typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.ANY), true);
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlHistogramAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlHistogramAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlHistogramAggFunction.java
index 1ba3821..a3fb5f2 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlHistogramAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlHistogramAggFunction.java
@@ -59,6 +59,7 @@ public class SqlHistogramAggFunction extends SqlAggFunction {
//~ Methods ----------------------------------------------------------------
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
return ImmutableList.of(type);
}
@@ -68,6 +69,7 @@ public class SqlHistogramAggFunction extends SqlAggFunction {
return type;
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
return type;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
index 2b80173..4639fbc 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlInOperator.java
@@ -33,6 +33,7 @@ import org.apache.calcite.sql.type.ReturnTypes;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.type.SqlTypeUtil;
import org.apache.calcite.sql.validate.SqlValidator;
+import org.apache.calcite.sql.validate.SqlValidatorImpl;
import org.apache.calcite.sql.validate.SqlValidatorScope;
import org.apache.calcite.util.Litmus;
@@ -126,9 +127,7 @@ public class SqlInOperator extends SqlBinaryOperator {
}
// Record the RHS type for use by SqlToRelConverter.
- validator.setValidatedNodeType(
- nodeList,
- rightType);
+ ((SqlValidatorImpl) validator).setValidatedNodeType(nodeList, rightType);
} else {
// Handle the 'IN (query)' form.
rightType = validator.deriveType(scope, right);
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlMinMaxAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlMinMaxAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlMinMaxAggFunction.java
index 54af0f8..438c7f1 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlMinMaxAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlMinMaxAggFunction.java
@@ -104,6 +104,7 @@ public class SqlMinMaxAggFunction extends SqlAggFunction {
return minMaxKind;
}
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
switch (minMaxKind) {
case MINMAX_PRIMITIVE:
@@ -116,6 +117,7 @@ public class SqlMinMaxAggFunction extends SqlAggFunction {
}
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
switch (minMaxKind) {
case MINMAX_PRIMITIVE:
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlSingleValueAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlSingleValueAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlSingleValueAggFunction.java
index c0c977c..6e745df 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlSingleValueAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlSingleValueAggFunction.java
@@ -57,10 +57,12 @@ public class SqlSingleValueAggFunction extends SqlAggFunction {
//~ Methods ----------------------------------------------------------------
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
return ImmutableList.of(type);
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
return type;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlSumAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlSumAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlSumAggFunction.java
index 5bf124d..eac5731 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlSumAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlSumAggFunction.java
@@ -60,6 +60,7 @@ public class SqlSumAggFunction extends SqlAggFunction {
//~ Methods ----------------------------------------------------------------
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
return ImmutableList.of(type);
}
@@ -69,6 +70,7 @@ public class SqlSumAggFunction extends SqlAggFunction {
return type;
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
return type;
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java b/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
index 6f18c08..daa66e2 100644
--- a/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/fun/SqlSumEmptyIsZeroAggFunction.java
@@ -53,12 +53,14 @@ public class SqlSumEmptyIsZeroAggFunction extends SqlAggFunction {
//~ Methods ----------------------------------------------------------------
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(RelDataTypeFactory typeFactory) {
return ImmutableList.of(
typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.ANY), true));
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
return typeFactory.createTypeWithNullability(
typeFactory.createSqlType(SqlTypeName.ANY), true);
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/validate/AbstractNamespace.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/AbstractNamespace.java b/core/src/main/java/org/apache/calcite/sql/validate/AbstractNamespace.java
index d0caa7c..687f26e 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/AbstractNamespace.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/AbstractNamespace.java
@@ -159,6 +159,7 @@ abstract class AbstractNamespace implements SqlValidatorNamespace {
return SqlMonotonicity.NOT_MONOTONIC;
}
+ @SuppressWarnings("deprecation")
public void makeNullable() {
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/validate/DelegatingNamespace.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/DelegatingNamespace.java b/core/src/main/java/org/apache/calcite/sql/validate/DelegatingNamespace.java
index 0aba477..c5754e8 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/DelegatingNamespace.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/DelegatingNamespace.java
@@ -97,6 +97,7 @@ public abstract class DelegatingNamespace implements SqlValidatorNamespace {
return namespace.getMonotonicity(columnName);
}
+ @SuppressWarnings("deprecation")
public void makeNullable() {
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java b/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
index 8b004cd..02823be 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/DelegatingScope.java
@@ -173,6 +173,7 @@ public abstract class DelegatingScope implements SqlValidatorScope {
parent.findAliases(result);
}
+ @SuppressWarnings("deprecation")
public Pair<String, SqlValidatorNamespace>
findQualifyingTableName(String columnName, SqlNode ctx) {
//noinspection deprecation
@@ -197,6 +198,7 @@ public abstract class DelegatingScope implements SqlValidatorScope {
return parent.nullifyType(node, type);
}
+ @SuppressWarnings("deprecation")
public SqlValidatorNamespace getTableNamespace(List<String> names) {
return parent.getTableNamespace(names);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/validate/EmptyScope.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/EmptyScope.java b/core/src/main/java/org/apache/calcite/sql/validate/EmptyScope.java
index b9a38cf..0dc9131 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/EmptyScope.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/EmptyScope.java
@@ -80,6 +80,7 @@ class EmptyScope implements SqlValidatorScope {
boolean deep, Resolved resolved) {
}
+ @SuppressWarnings("deprecation")
public SqlValidatorNamespace getTableNamespace(List<String> names) {
SqlValidatorTable table = validator.catalogReader.getTable(names);
return table != null
@@ -195,6 +196,7 @@ class EmptyScope implements SqlValidatorScope {
// valid
}
+ @SuppressWarnings("deprecation")
public Pair<String, SqlValidatorNamespace>
findQualifyingTableName(String columnName, SqlNode ctx) {
throw validator.newValidationError(ctx,
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/validate/ListScope.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/ListScope.java b/core/src/main/java/org/apache/calcite/sql/validate/ListScope.java
index 7228f63..e0f3427 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/ListScope.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/ListScope.java
@@ -127,6 +127,7 @@ public abstract class ListScope extends DelegatingScope {
parent.findAliases(result);
}
+ @SuppressWarnings("deprecation")
@Override public Pair<String, SqlValidatorNamespace>
findQualifyingTableName(final String columnName, SqlNode ctx) {
final SqlNameMatcher nameMatcher = validator.catalogReader.nameMatcher();
@@ -134,7 +135,6 @@ public abstract class ListScope extends DelegatingScope {
findQualifyingTables(columnName, nameMatcher);
switch (map.size()) {
case 0:
- //noinspection deprecation
return parent.findQualifyingTableName(columnName, ctx);
case 1:
final Map.Entry<String, ScopeChild> entry =
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/validate/SqlUserDefinedAggFunction.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql/validate/SqlUserDefinedAggFunction.java b/core/src/main/java/org/apache/calcite/sql/validate/SqlUserDefinedAggFunction.java
index a5592f3..f7b19f0 100644
--- a/core/src/main/java/org/apache/calcite/sql/validate/SqlUserDefinedAggFunction.java
+++ b/core/src/main/java/org/apache/calcite/sql/validate/SqlUserDefinedAggFunction.java
@@ -53,6 +53,7 @@ public class SqlUserDefinedAggFunction extends SqlAggFunction {
this.function = function;
}
+ @SuppressWarnings("deprecation")
public List<RelDataType> getParameterTypes(
final RelDataTypeFactory typeFactory) {
return Lists.transform(function.getParameters(),
@@ -63,6 +64,7 @@ public class SqlUserDefinedAggFunction extends SqlAggFunction {
});
}
+ @SuppressWarnings("deprecation")
public RelDataType getReturnType(RelDataTypeFactory typeFactory) {
return function.getReturnType(typeFactory);
}
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql/validate/SqlValidatorImpl.java
----------------------------------------------------------------------
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 f0d0ce9..0d0a608 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
@@ -427,7 +427,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
inferUnknownTypes(targetType, scope, expanded);
final RelDataType type = deriveType(selectScope, expanded);
- setValidatedNodeTypeImpl(expanded, type);
+ setValidatedNodeType(expanded, type);
types.add(Pair.of(alias, type));
return false;
}
@@ -1481,17 +1481,17 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
return null;
}
- public void setValidatedNodeType(
- SqlNode node,
- RelDataType type) {
- setValidatedNodeTypeImpl(node, type);
- }
-
- public void removeValidatedNodeType(SqlNode node) {
- nodeToTypeMap.remove(node);
- }
-
- void setValidatedNodeTypeImpl(SqlNode node, RelDataType type) {
+ /**
+ * Saves the type of a {@link SqlNode}, now that it has been validated.
+ *
+ * <p>Unlike the base class method, this method is not deprecated.
+ * It is available from within Calcite, but is not part of the public API.
+ *
+ * @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) {
Preconditions.checkNotNull(type);
Preconditions.checkNotNull(node);
if (type.equals(unknownType)) {
@@ -1502,6 +1502,10 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
nodeToTypeMap.put(node, type);
}
+ public void removeValidatedNodeType(SqlNode node) {
+ nodeToTypeMap.remove(node);
+ }
+
public RelDataType deriveType(
SqlValidatorScope scope,
SqlNode expr) {
@@ -1521,7 +1525,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
Preconditions.checkArgument(
type != null,
"SqlValidator.deriveTypeInternal returned null");
- setValidatedNodeTypeImpl(expr, type);
+ setValidatedNodeType(expr, type);
return type;
}
@@ -1648,7 +1652,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
inferredType.getCharset(),
inferredType.getCollation());
}
- setValidatedNodeTypeImpl(node, newInferredType);
+ setValidatedNodeType(node, newInferredType);
} else if (node instanceof SqlNodeList) {
SqlNodeList nodeList = (SqlNodeList) node;
if (inferredType.isStruct()) {
@@ -1689,9 +1693,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
scope,
caseCall.getElseOperand());
} else {
- setValidatedNodeTypeImpl(
- caseCall.getElseOperand(),
- returnType);
+ setValidatedNodeType(caseCall.getElseOperand(), returnType);
}
} else if (node instanceof SqlCall) {
final SqlCall call = (SqlCall) node;
@@ -1790,19 +1792,14 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
* this namespace)
* @param alias Alias by which parent will refer to this namespace
* @param ns Namespace
- * @param forceNullable Whether to force the type of namespace to be
+ * @param forceNullable Whether to force the type of namespace to be nullable
*/
protected void registerNamespace(
SqlValidatorScope usingScope,
String alias,
SqlValidatorNamespace ns,
boolean forceNullable) {
- if (forceNullable) {
- ns.makeNullable();
- }
- namespaces.put(
- ns.getNode(),
- ns);
+ namespaces.put(ns.getNode(), ns);
if (usingScope != null) {
usingScope.addChild(ns, alias, forceNullable);
}
@@ -2609,6 +2606,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
return aggFinder.findAgg(select.getSelectList());
}
+ @SuppressWarnings("deprecation")
public boolean isAggregate(SqlNode selectNode) {
return aggFinder.findAgg(selectNode) != null;
}
@@ -3420,7 +3418,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
final SqlValidatorScope scope = getOrderScope(select);
inferUnknownTypes(unknownType, scope, newSqlNode);
final RelDataType type = deriveType(scope, newSqlNode);
- setValidatedNodeTypeImpl(newSqlNode, type);
+ setValidatedNodeType(newSqlNode, type);
}
return newSqlNode;
}
@@ -3498,7 +3496,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
break;
}
final RelDataType type = deriveType(groupScope, groupItem);
- setValidatedNodeTypeImpl(groupItem, type);
+ setValidatedNodeType(groupItem, type);
}
}
@@ -3679,7 +3677,7 @@ public class SqlValidatorImpl implements SqlValidatorWithHints {
final SelectScope scope = (SelectScope) getWhereScope(parentSelect);
final RelDataType type = deriveType(scope, selectItem);
- setValidatedNodeTypeImpl(selectItem, type);
+ setValidatedNodeType(selectItem, type);
// we do not want to pass on the RelRecordType returned
// by the sub query. Just the type of the single expression
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/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 9ae5436..b6df686 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/SqlToRelConverter.java
@@ -3402,8 +3402,7 @@ public class SqlToRelConverter {
}, null, false);
}
RelDataType multisetType = validator.getValidatedNodeType(call);
- validator.setValidatedNodeType(
- list,
+ ((SqlValidatorImpl) validator).setValidatedNodeType(list,
multisetType.getComponentType());
input = convertQueryOrInList(usedBb, list, null);
break;
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
index da28296..f1c2e1e 100644
--- a/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
+++ b/core/src/main/java/org/apache/calcite/sql2rel/StandardConvertletTable.java
@@ -78,6 +78,7 @@ import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@@ -818,7 +819,7 @@ public class StandardConvertletTable extends ReflectiveConvertletTable {
&& val.signum() == 1) {
try {
final BigDecimal reciprocal =
- BigDecimal.ONE.divide(val, BigDecimal.ROUND_UNNECESSARY);
+ BigDecimal.ONE.divide(val, RoundingMode.UNNECESSARY);
return rexBuilder.makeCall(SqlStdOperatorTable.MULTIPLY, res,
rexBuilder.makeExactLiteral(reciprocal));
} catch (ArithmeticException e) {
http://git-wip-us.apache.org/repos/asf/calcite/blob/5181563f/core/src/main/java/org/apache/calcite/util/NumberUtil.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/util/NumberUtil.java b/core/src/main/java/org/apache/calcite/util/NumberUtil.java
index 7e9d532..a33b416 100644
--- a/core/src/main/java/org/apache/calcite/util/NumberUtil.java
+++ b/core/src/main/java/org/apache/calcite/util/NumberUtil.java
@@ -18,6 +18,7 @@ package org.apache.calcite.util;
import java.math.BigDecimal;
import java.math.BigInteger;
+import java.math.RoundingMode;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@@ -81,7 +82,7 @@ public class NumberUtil {
public static BigDecimal rescaleBigDecimal(BigDecimal bd, int scale) {
if (bd != null) {
- bd = bd.setScale(scale, BigDecimal.ROUND_HALF_UP);
+ bd = bd.setScale(scale, RoundingMode.HALF_UP);
}
return bd;
}