kalencaya opened a new issue #1283:
URL: https://github.com/apache/incubator-seatunnel/issues/1283


   ### Search before asking
   
   - [X] I had searched in the 
[issues](https://github.com/apache/incubator-seatunnel/issues?q=is%3Aissue+label%3A%22bug%22)
 and found no similar issues.
   
   
   ### What happened
   
   As described by title,  I got a NullPointerException when trying to extract 
datas from mysql by seatunnel JdbcSource plugin.
   mysql table ddl below:
   CREATE TABLE `sys_user` (
     `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT 'id',
     ......
     `deleted` tinyint unsigned NOT NULL DEFAULT '0' COMMENT '删除标识。0: 未删除, 1: 
已删除',
     ......
     PRIMARY KEY (`id`),
     
   ) ENGINE=InnoDB COMMENT='用户表';
   
   As you can see, I add unsigned type to my id and deleted column. 
   ResultSet provides BIGINT UNSIGNED jdbc type but not BIGINT, then absence of 
mapping from BIGINT UNSIGNED to TypeInformation causes JdbcSource genrating 
RowTypeInfo failure.
   
   related source code below:
   public class JdbcSource implements FlinkBatchSource<Row> {
   
       {
           informationMapping.put("VARCHAR", STRING_TYPE_INFO);
           informationMapping.put("BOOLEAN", BOOLEAN_TYPE_INFO);
           informationMapping.put("TINYINT", BYTE_TYPE_INFO);
           informationMapping.put("SMALLINT", SHORT_TYPE_INFO);
           informationMapping.put("INTEGER", INT_TYPE_INFO);
           informationMapping.put("MEDIUMINT", INT_TYPE_INFO);
           informationMapping.put("INT", INT_TYPE_INFO);
           informationMapping.put("BIGINT", LONG_TYPE_INFO);
           informationMapping.put("FLOAT", FLOAT_TYPE_INFO);
           informationMapping.put("DOUBLE", DOUBLE_TYPE_INFO);
           informationMapping.put("CHAR", STRING_TYPE_INFO);
           informationMapping.put("TEXT", STRING_TYPE_INFO);
           informationMapping.put("LONGTEXT", STRING_TYPE_INFO);
           informationMapping.put("DATE", SqlTimeTypeInfo.DATE);
           informationMapping.put("TIME", SqlTimeTypeInfo.TIME);
           informationMapping.put("TIMESTAMP", SqlTimeTypeInfo.TIMESTAMP);
           informationMapping.put("DECIMAL", BIG_DEC_TYPE_INFO);
           informationMapping.put("BINARY", BYTE_PRIMITIVE_ARRAY_TYPE_INFO);
   
       }
   
       private RowTypeInfo getRowTypeInfo() {
           HashMap<String, TypeInformation> map = new LinkedHashMap<>();
   
           try {
               ResultSet columns = metaData.getColumns(connection.getCatalog(), 
connection.getSchema(), tableName, "%");
               while (columns.next()) {
                   String columnName = columns.getString("COLUMN_NAME");
                   // id or deleted field jdbc type: BIGINT UNSIGNED
                   String dataTypeName = columns.getString("TYPE_NAME");
                   if (fields == null || fields.contains(columnName)) {
                       map.put(columnName, 
informationMapping.get(dataTypeName));
                   }
               }
           } catch (Exception e) {
           
           }
       }
   }
   
   ### SeaTunnel Version
   
   dev branch
   
   ### SeaTunnel Config
   
   ```conf
   source {
     JdbcSource {
       driver = com.mysql.cj.jdbc.Driver
       url = "jdbc:mysql://localhost:3306/data_service"
       username = root
       password = 123
       query = "select * from sys_user"
       result_table_name = jdbc
     }
   }
   ```
   
   
   ### Running Command
   
   ```shell
   .
   ```
   
   
   ### Error Exception
   
   ```log
   .
   ```
   
   
   ### Flink or Spark Version
   
   _No response_
   
   ### Java or Scala Version
   
   _No response_
   
   ### Screenshots
   
   _No response_
   
   ### Are you willing to submit PR?
   
   - [X] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to