You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by li...@apache.org on 2017/11/26 06:03:59 UTC
kylin git commit: KYLIN-2966 add pushdown jdbc columntype mapping
Repository: kylin
Updated Branches:
refs/heads/KYLIN-2966 [created] 0b6b0625d
KYLIN-2966 add pushdown jdbc columntype mapping
Signed-off-by: Li Yang <li...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/0b6b0625
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/0b6b0625
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/0b6b0625
Branch: refs/heads/KYLIN-2966
Commit: 0b6b0625d83b357ceae7aeab3d3e303d6fdd6f47
Parents: d837e18
Author: zhaiyuyong <zh...@126.com>
Authored: Wed Oct 25 17:06:04 2017 +0800
Committer: Li Yang <li...@apache.org>
Committed: Sun Nov 26 14:03:11 2017 +0800
----------------------------------------------------------------------
.../query/adhoc/PushDownRunnerJdbcImpl.java | 45 +++++++++++++++++++-
1 file changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/kylin/blob/0b6b0625/query/src/main/java/org/apache/kylin/query/adhoc/PushDownRunnerJdbcImpl.java
----------------------------------------------------------------------
diff --git a/query/src/main/java/org/apache/kylin/query/adhoc/PushDownRunnerJdbcImpl.java b/query/src/main/java/org/apache/kylin/query/adhoc/PushDownRunnerJdbcImpl.java
index 503e273..7283d66 100644
--- a/query/src/main/java/org/apache/kylin/query/adhoc/PushDownRunnerJdbcImpl.java
+++ b/query/src/main/java/org/apache/kylin/query/adhoc/PushDownRunnerJdbcImpl.java
@@ -23,6 +23,7 @@ import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
+import java.sql.Types;
import java.util.LinkedList;
import java.util.List;
@@ -66,7 +67,7 @@ public class PushDownRunnerJdbcImpl implements IPushDownRunner {
columnMetas.add(new SelectedColumnMeta(metaData.isAutoIncrement(i), metaData.isCaseSensitive(i), false,
metaData.isCurrency(i), metaData.isNullable(i), false, metaData.getColumnDisplaySize(i),
metaData.getColumnLabel(i), metaData.getColumnName(i), null, null, null,
- metaData.getPrecision(i), metaData.getScale(i), metaData.getColumnType(i),
+ metaData.getPrecision(i), metaData.getScale(i), toSqlType(metaData.getColumnTypeName(i)),
metaData.getColumnTypeName(i), metaData.isReadOnly(i), false, false));
}
} finally {
@@ -76,6 +77,48 @@ public class PushDownRunnerJdbcImpl implements IPushDownRunner {
}
}
+ // calcite does not understand all java SqlTypes, for example LONGNVARCHAR -16, thus need this mapping (KYLIN-2966)
+ public static int toSqlType(String type) throws SQLException {
+ if ("string".equalsIgnoreCase(type)) {
+ return Types.VARCHAR;
+ } else if ("varchar".equalsIgnoreCase(type)) {
+ return Types.VARCHAR;
+ } else if ("char".equalsIgnoreCase(type)) {
+ return Types.CHAR;
+ } else if ("float".equalsIgnoreCase(type)) {
+ return Types.FLOAT;
+ } else if ("real".equalsIgnoreCase(type)) {
+ return Types.REAL;
+ } else if ("double".equalsIgnoreCase(type)) {
+ return Types.DOUBLE;
+ } else if ("boolean".equalsIgnoreCase(type)) {
+ return Types.BOOLEAN;
+ } else if ("tinyint".equalsIgnoreCase(type)) {
+ return Types.TINYINT;
+ } else if ("smallint".equalsIgnoreCase(type)) {
+ return Types.SMALLINT;
+ } else if ("int".equalsIgnoreCase(type)) {
+ return Types.INTEGER;
+ } else if ("bigint".equalsIgnoreCase(type)) {
+ return Types.BIGINT;
+ } else if ("date".equalsIgnoreCase(type)) {
+ return Types.DATE;
+ } else if ("timestamp".equalsIgnoreCase(type)) {
+ return Types.TIMESTAMP;
+ } else if ("decimal".equalsIgnoreCase(type)) {
+ return Types.DECIMAL;
+ } else if ("binary".equalsIgnoreCase(type)) {
+ return Types.BINARY;
+ } else if ("map".equalsIgnoreCase(type)) {
+ return Types.JAVA_OBJECT;
+ } else if ("array".equalsIgnoreCase(type)) {
+ return Types.ARRAY;
+ } else if ("struct".equalsIgnoreCase(type)) {
+ return Types.STRUCT;
+ }
+ throw new SQLException("Unrecognized column type: " + type);
+ }
+
@Override
public void executeUpdate(String sql) throws Exception {
Statement statement = null;