Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TCOMP-2565): support origin type pass for studio dynamic type #822

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static java.util.stream.Collectors.toMap;
import static org.talend.sdk.component.api.record.SchemaProperty.ALLOW_SPECIAL_NAME;
import static org.talend.sdk.component.api.record.SchemaProperty.IS_KEY;
import static org.talend.sdk.component.api.record.SchemaProperty.ORIGIN_TYPE;
import static org.talend.sdk.component.api.record.SchemaProperty.PATTERN;
import static org.talend.sdk.component.api.record.SchemaProperty.SCALE;
import static org.talend.sdk.component.api.record.SchemaProperty.SIZE;
Expand Down Expand Up @@ -268,6 +269,11 @@ private DynamicMetadataWrapper generateMetadata(final Entry entry) {
metadata.getDynamicMetadata().setKey(isKey);
metadata.getDynamicMetadata().setType(studioType);

final String originType = entry.getProp(ORIGIN_TYPE);
if (originType != null && !originType.isEmpty()) {
metadata.getDynamicMetadata().setDbType(originType);
}

if (length != null) {
metadata.getDynamicMetadata().setLength(length);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.talend.sdk.component.api.record.SchemaProperty.ORIGIN_TYPE;
import static org.talend.sdk.component.api.record.SchemaProperty.STUDIO_TYPE;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.junit.jupiter.api.Assertions;
Expand All @@ -44,7 +43,7 @@
class DiRecordVisitorTest extends VisitorsTest {

@Test
void visit() {

Check warning on line 46 in component-studio/component-runtime-di/src/test/java/org/talend/sdk/component/runtime/di/record/DiRecordVisitorTest.java

View check run for this annotation

sonar-eks / Component Runtime Sonarqube Results

component-studio/component-runtime-di/src/test/java/org/talend/sdk/component/runtime/di/record/DiRecordVisitorTest.java#L46

Refactor this method to reduce the number of assertions from 67 to less than 25.
final Record record = factory
.newRecordBuilder()
.withString("id", ":testing:")
Expand Down Expand Up @@ -99,6 +98,7 @@
.withName("dynBigDecimal")
.withType(Type.STRING)
.withProp(STUDIO_TYPE, StudioTypes.BIGDECIMAL)
.withProp(ORIGIN_TYPE, "DECIMAL")
.build(), BIGDEC.toString())
.withDecimal(factory.newEntryBuilder()
.withName("dynBigDecimal2")
Expand Down Expand Up @@ -247,6 +247,8 @@
assertTrue(byte[].class.isInstance(dynObject));
assertArrayEquals(String.valueOf(BYTES0).getBytes(), (byte[]) dynObject);

String originType = rowStruct.dynamic.getColumnMetadata(7).getDbType();
assertEquals("DECIMAL", originType);
dynObject = rowStruct.dynamic.getColumnValue("dynBigDecimal");
assertTrue(BigDecimal.class.isInstance(dynObject));
assertEquals(BIGDEC, dynObject);
Expand Down
Loading