Search in sources :

Example 36 with SQLDataType

use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.

the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_11.

public void test_oracle2pg_int_11() throws Exception {
    String sql = "number(11, 0)";
    SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
    SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
    assertEquals("BIGINT", pgDataType.toString());
}
Also used : SQLDataType(com.alibaba.druid.sql.ast.SQLDataType)

Example 37 with SQLDataType

use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.

the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_7.

public void test_oracle2pg_int_7() throws Exception {
    String sql = "number(7, 0)";
    SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
    SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
    assertEquals("INT", pgDataType.toString());
}
Also used : SQLDataType(com.alibaba.druid.sql.ast.SQLDataType)

Example 38 with SQLDataType

use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.

the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_8.

public void test_oracle2pg_int_8() throws Exception {
    String sql = "number(8, 0)";
    SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
    SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
    assertEquals("INT", pgDataType.toString());
}
Also used : SQLDataType(com.alibaba.druid.sql.ast.SQLDataType)

Example 39 with SQLDataType

use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.

the class Oracle2PG_DataTypeTest_number_int method test_oracle2pg_int_18.

public void test_oracle2pg_int_18() throws Exception {
    String sql = "number(18, 0)";
    SQLDataType dataType = SQLParserUtils.createExprParser(sql, JdbcConstants.ORACLE).parseDataType();
    SQLDataType pgDataType = SQLTransformUtils.transformOracleToPostgresql(dataType);
    assertEquals("BIGINT", pgDataType.toString());
}
Also used : SQLDataType(com.alibaba.druid.sql.ast.SQLDataType)

Example 40 with SQLDataType

use of com.alibaba.druid.sql.ast.SQLDataType in project druid by alibaba.

the class TPCDS_ALL_Resolve method test_q01.

public void test_q01() throws Exception {
    for (int q = 1; q <= 99; ++q) {
        System.out.println("tpcds query-" + q);
        System.out.println("-----------------------------------------------------");
        String sql = TPCDS.getQuery(q);
        final List<SQLStatement> statements = SQLUtils.parseStatements(sql, DbType.mysql);
        for (SQLStatement stmt : statements) {
            repository.resolve(stmt);
            final SQLSelect select = ((SQLSelectStatement) stmt).getSelect();
            final SQLSelectQueryBlock firstQueryBlock = select.getFirstQueryBlock();
            if (firstQueryBlock == null) {
                continue;
            }
            final List<SQLSelectItem> selectList = firstQueryBlock.getSelectList();
            for (int i = 0; i < selectList.size(); i++) {
                SQLSelectItem selectItem = selectList.get(i);
                if (selectItem.getExpr() instanceof SQLAllColumnExpr) {
                    continue;
                }
                final SQLDataType dataType = selectItem.computeDataType();
                if (dataType == null) {
                // fail("dataType is null : " + selectItem);
                }
            }
        }
    }
}
Also used : SQLSelectItem(com.alibaba.druid.sql.ast.statement.SQLSelectItem) SQLAllColumnExpr(com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr) SQLDataType(com.alibaba.druid.sql.ast.SQLDataType) SQLSelect(com.alibaba.druid.sql.ast.statement.SQLSelect) SQLSelectStatement(com.alibaba.druid.sql.ast.statement.SQLSelectStatement) SQLSelectQueryBlock(com.alibaba.druid.sql.ast.statement.SQLSelectQueryBlock) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement)

Aggregations

SQLDataType (com.alibaba.druid.sql.ast.SQLDataType)93 SQLDataTypeImpl (com.alibaba.druid.sql.ast.SQLDataTypeImpl)7 SQLExpr (com.alibaba.druid.sql.ast.SQLExpr)7 SQLCharacterDataType (com.alibaba.druid.sql.ast.statement.SQLCharacterDataType)5 SQLAllColumnExpr (com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr)4 SQLIntegerExpr (com.alibaba.druid.sql.ast.expr.SQLIntegerExpr)4 SQLNumericLiteralExpr (com.alibaba.druid.sql.ast.expr.SQLNumericLiteralExpr)3 SQLColumnDefinition (com.alibaba.druid.sql.ast.statement.SQLColumnDefinition)3 SQLVariantRefExpr (com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr)2 SQLName (com.alibaba.druid.sql.ast.SQLName)1 SQLStatement (com.alibaba.druid.sql.ast.SQLStatement)1 SQLCharExpr (com.alibaba.druid.sql.ast.expr.SQLCharExpr)1 SQLIdentifierExpr (com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr)1 SQLIntervalExpr (com.alibaba.druid.sql.ast.expr.SQLIntervalExpr)1 SQLMethodInvokeExpr (com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr)1 SQLNullExpr (com.alibaba.druid.sql.ast.expr.SQLNullExpr)1 SQLAlterTableAlterColumn (com.alibaba.druid.sql.ast.statement.SQLAlterTableAlterColumn)1 SQLColumnConstraint (com.alibaba.druid.sql.ast.statement.SQLColumnConstraint)1 SQLColumnPrimaryKey (com.alibaba.druid.sql.ast.statement.SQLColumnPrimaryKey)1 SQLColumnUniqueKey (com.alibaba.druid.sql.ast.statement.SQLColumnUniqueKey)1