icCube定义的icc-schema.xml

icCube definition of the icc-schema.xml

icc-schema.xml jdbcDatatable column 中有一个 tableType 和一个 type 属性。

示例:

column name="first_opened_date" tableType="TIMESTAMP" type="DATETIME" selected="true" primaryKey="false"

column name="prepared_food" tableType="BIT" type="BOOLEAN" selected="true" primaryKey="false"

我猜tableType指的是数据库中定义的数据类型,type是一个icCube内部标识符,大致与java.sql.Types有关。

如果这是正确的,前者[table类型可以从java.sql.Metadata.getColumns.getString("TYPE_NAME")中读取,后面的[类型]必须从java.sql.Metadata.getColumns.getString("DATA_TYPE")中推断出来。

我的猜测对吗?你有来信吗table?属性错误或缺失的影响是什么?

假设我们正在谈论 JDBC tables.

"tableType" 在代码中没有这样使用;它显示为指示。 该名称源自元信息返回的 java.sql.Types 整数。

"type" 是列的实际数据类型。从数据库读取的值被转换 到此数据类型,然后用于构建维度和事实。这是显示的类型 在 table UI 为 "Output Type"。可能的值为:

DATE     
DATETIME
BOOLEAN
DOUBLE
FLOAT
SHORT
INTEGER
LONG
STRING
UPPERCASE_STRING
JAVA_OBJECT
DB_TYPE_UNSUPPORTED

来自java.sql.Types的映射如下:

DATE                from: Types.DATE
DATETIME            from: Types.TIMESTAMP
BOOLEAN             from: Types.BIT, Types.BOOLEAN
DOUBLE              from: Types.FLOAT, Types.DOUBLE, Types.NUMERIC, Types.DECIMAL
FLOAT               from: Types.REAL
SHORT               from: Types.TINYINT, Types.SMALLINT
INTEGER             from: Types.INTEGER
LONG                from: Types.BIGINT, Types.ROWID
STRING              from: Types.VARCHAR, Types.LONGVARCHAR, Types.NVARCHAR, Types.LONGNVARCHAR, Types.CHAR, Types.NCHAR
UPPERCASE_STRING    from: n/a
JAVA_OBJECT         from: Types.JAVA_OBJECT
DB_TYPE_UNSUPPORTED from: n/a

希望对您有所帮助。

作为对@Polizzi 回答的补充,以防万一您需要它:

    tableType = JDBCType.valueOf(dbtype).getName();
    switch(dbtype){
        case Types.DATE:
            type = "DATE";
            break;
        case Types.TIMESTAMP:
            type = "DATETIME";
            break;            
        case Types.BIT:
            type = "BOOLEAN";
            break;             
        case Types.BOOLEAN:
            type = "BOOLEAN";
            break;             
        case Types.FLOAT:
            type = "DOUBLE";
            break;          
        case Types.DOUBLE:
            type = "DOUBLE";
            break;          
        case Types.NUMERIC:
            type = "DOUBLE";
            break;              
        case Types.DECIMAL:
            type = "DOUBLE";
            break;          
        case Types.REAL:
            type = "FLOAT";
            break;           
        case Types.TINYINT:
            type = "SHORT";
            break;           
        case Types.SMALLINT:
            type = "SHORT";
            break;           
        case Types.INTEGER:
            type = "INTEGER";
            break;         
        case Types.BIGINT:
            type = "LONG";
            break;           
        case Types.ROWID:
            type = "LONG";
            break;            
        case Types.VARCHAR:
            type = "STRING";
            tableType = "VARCHAR("+length+")";
            break;          
        case Types.LONGVARCHAR:
            type = "STRING";
            tableType = "LONGVARCHAR("+length+")";
            break;         
        case Types.NVARCHAR:
            type = "STRING";
            tableType = "NVARCHAR("+length+")";
            break;              
        case Types.LONGNVARCHAR:
            type = "STRING";
            tableType = "LONGVARCHAR("+length+")";
            break;          
        case Types.CHAR:
            type = "STRING";
            tableType = "CHAR("+length+")";
            break;              
        case Types.NCHAR:
            type = "STRING";
            tableType = "NCHAR("+length+")";
            break;               
        case Types.JAVA_OBJECT:
            type = "JAVA_OBJECT";
            break; 
        default:
            type = "DB_TYPE_UNSUPPORTED";
    }