3 weeks ago
the if function is returning always the true value and the false value together in the same context, which makes my target structure take the false value (as being the first value).
I could manage the issue with the following udf-script and mapping:
def void conditionalMappingSingle(String[] conditions, String[] trueValues, String[] falseValues, Output output, MappingContext context) {
// Loop through the conditions and find the first true value
for (int i = 0; i < conditions.length; i++) {
if ("true".equalsIgnoreCase(conditions[i])) {
output.addValue(trueValues[i]); // Add the corresponding true value to the output
return; // Exit after finding the first true value
}
}
// If no true value is found, add the first false value to the output
if (falseValues.length > 0) {
output.addValue(falseValues[0]); // Default to the first false value
}
}
Using if (standard function)
using user-defined function:
Isn't there a way to solve it with the standard mapping functions?
Request clarification before answering.
User | Count |
---|---|
50 | |
10 | |
8 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.