fskorgen opened a new issue, #8260:
URL: https://github.com/apache/hop/issues/8260
### Apache Hop version?
2.20.0-SNAPSHOT and 2.19.0
### Java version?
21
### Operating system
Windows
### What happened?
When a return value has a **Type** set, `DatabaseLookupMeta.getFields()`
builds the output field from
scratch:
```java
int typeId =
ValueMetaFactory.getIdForValueMeta(returnValue.getDefaultType());
if (typeId != IValueMeta.TYPE_NONE) {
v = ValueMetaFactory.createValueMeta(fieldName, typeId); // length -1,
precision -1, no mask
} else {
...
v = source.clone();
}
```
Only the type survives. Length, precision, conversion mask and the
`original*` JDBC metadata are
lost, so a `varchar(30)` column arrives as a String with length `-1`. The
user cannot put them back:
the *Fields* tab has Field, New name, Default, Type and Trim type, but no
Length or Precision column.
This reaches DDL generation. Table Output and the bulk loaders size
`VARCHAR` columns from the field
length.
Leaving the Type empty does keep the length, but that is not a realistic
escape: **Get Fields** fills
the Type column automatically (`DatabaseLookupDialog` passes column 4 as the
type column to
`BaseTransformDialog.getFieldsFromPrevious`), so in practice every return
value has a type.
The behaviour changed in [#7574](https://github.com/apache/hop/pull/7574)
(`3e21c0cd34`, 2026-07-20),
which made a configured Type win over the table metadata. That change was
right for
[#5084](https://github.com/apache/hop/issues/5084) (empty Type must be
inferred) and
[#3100](https://github.com/apache/hop/issues/3100) (an explicit Type must
apply). The problem is that
it discards the whole source value meta when only the type needed to change.
### Steps to reproduce
1. `create table item_type (code varchar(3), description varchar(30))`
2. Add a **Database lookup** on that table and press **Get Fields** in the
*Fields* tab, so
`description` is returned with Type `String`.
3. Check the input fields of the next transform (**Transform fields and
their origin**), or run the
pipeline and inspect the output row metadata.
**Expected:** `description` is `String(30)`, as on 2.18.
**Actual:** `String` with no length; precision and mask are empty. Clearing
the Type cell by hand
restores the length, which is the current workaround.
### Suggested fix
Keep the new precedence, but clone the table field instead of creating a new
one:
```java
IValueMeta source =
tableFields == null ? null :
tableFields.searchValueMeta(returnValue.getTableField());
if (source == null) {
v = ValueMetaFactory.createValueMeta(fieldName, typeId);
} else {
v = ValueMetaFactory.cloneValueMeta(source, typeId);
v.setName(fieldName);
}
```
`cloneValueMeta(source, targetType)` returns `source.clone()` when the types
match, and otherwise
creates the target type carrying `getLength()`/`getPrecision()`, with
`cloneInfo` copying the mask
and the `original*` metadata. No extra lookup is needed: `tableFields` is
the info row the caller
already supplies.
### Issue Priority
Priority: 2
### Issue Component
Component: Transforms
--
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]