ravinarayansingh commented on code in PR #8445:
URL: https://github.com/apache/nifi/pull/8445#discussion_r1505352955


##########
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java:
##########
@@ -1918,6 +1918,7 @@ public static DataType getDataTypeFromSQLTypeValue(final 
int sqlType) {
             case Types.BIGINT:
                 return RecordFieldType.BIGINT.getDataType();
             case Types.BOOLEAN:
+            case Types.BIT:

Review Comment:
   hi @Lehel44 and @mattyb149
   
   Have a look on below  sample table definition (Postgres14)
   
       CREATE TABLE test_table (
           id int4 NOT NULL,
           active bool NULL,
           col_bit bit(1) NULL,
           col_bit1 bit(1) NULL,
           col_varbit varbit(2) NULL,
           CONSTRAINT temp_market_cap_pkey PRIMARY KEY (id)
       );
   
   We can use something like below:
   
       # DataTypeUtils.java
       case Types.BOOLEAN:
           return RecordFieldType.BOOLEAN.getDataType();
       case Types.BIT:
           return RecordFieldType.INT.getDataType();
   <br>
   
       String typeName = columnResultSet.getString("TYPE_NAME");
       final int dataType;
       if (typeName.equalsIgnoreCase("bool")) {
           dataType = 16;
       } else {
           dataType = columnResultSet.getInt("DATA_TYPE");
       }
               
   then below will be result 
   
   | colName    | postgresType | javaSqlType | javaSqlTypeName | finalType |
   |------------|--------------|-------------|-----------------|-----------|
   | id         | int          | 4           | int4            | INT       |
   | active     | bool         | -7          | bool            | BOOLEAN   |
   | col_bit    | bit(1)       | -7          | bit             | INT       |
   | col_bit1   | bit(2)       | -7          | bit             | INT       |
   | col_varbit | varbit(2)    | 1111        | varbit          | STRING    |
   
   let me know your thoughts



-- 
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: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to