Uploaded image for project: 'Talend Component Kit'
  1. Talend Component Kit
  2. TCOMP-2259

Support db column name/length/precision with guess schema for all types

Apply templateInsert Lucidchart Diagram




      On the TCK JDBCcomponent we do not support db column name/length/precision when we use guess schema for all types.

      Though we provide pros like this when guess schema:

      final String javaType = metaData.getColumnClassName(columnIndex);
      final int sqlType = metaData.getColumnType(columnIndex);
      final String columnName = metaData.getColumnLabel(columnIndex);// select field as f1, 1 as f2, here return
                                                                     // f1 and f2
      final String dbColumnName = metaData.getColumnName(columnIndex);// select field as f1 from t1, here return
                                                                      // "field"?
      // TODO use talend db mapping files to do type convert to talend type
      final String columnTypeName = metaData.getColumnTypeName(columnIndex).toUpperCase();
      final int size = metaData.getPrecision(columnIndex);
      final int scale = metaData.getScale(columnIndex);
      final boolean ignorePrecision = false;
      inal boolean ignoreScale = false;
      final boolean isNullable = metaData.isNullable(columnIndex) != ResultSetMetaData.columnNoNulls;
      final Schema.Entry.Builder entryBuilder = recordBuilderFactory.newEntryBuilder()
                  // .withRawName(columnName)//no need this as withName will do it
                     .withProp("talend.studio.key", "false")// as metadata from sql query, not table metadata, so no key
                                                            // info or no need
      switch (sqlType) {
      case java.sql.Types.SMALLINT:
      case java.sql.Types.TINYINT:
      case java.sql.Types.INTEGER:
          if (javaType.equals(Integer.class.getName()) || Short.class.getName().equals(javaType)) {
               entryBuilder.withType(INT).withProp("talend.studio.type", "id_Integer");
               withPrecision(entryBuilder, ignorePrecision, size);

      But the wrapper don't treat them rightly in TaCoKitGuessSchema.

      This is one part of schema support.


      Proposed PR fix length and precision for all types.
      It was only supported for float/double/date/decimal before.

      Now, if developers set the length and precision in their schema entry object, studio will show it in Talend schema UI.

      Also fix the default length and precision to null, so the setup of it is optional and comportment is the same as before without.


        Issue Links



              Unassigned Unassigned
              wwang Wei Wang
              Axel Catoire, emmanuel gallois, Fabien Desiles, Wei Wang
              0 Vote for this issue
              1 Start watching this issue