Skip to content

Commit

Permalink
[Fix][Connector-V2] Fix hana type loss of precision (#7912)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hisoka-X authored Oct 26, 2024
1 parent ba7fa23 commit 18dcca3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ public Column convert(BasicTypeDefine typeDefine) {
break;
case HANA_ST_POINT:
case HANA_ST_GEOMETRY:
builder.columnLength(typeDefine.getLength());
builder.dataType(PrimitiveByteArrayType.INSTANCE);
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,37 @@ public void testConvertDatetime() {
Assertions.assertEquals(typeDefine.getColumnType(), column.getSourceType());
}

@Test
public void testConvertSpecialType() {
BasicTypeDefine<Object> typeDefine =
BasicTypeDefine.builder()
.name("test")
.columnType("ST_POINT")
.length(8L)
.dataType("ST_POINT")
.build();
Column column = SapHanaTypeConverter.INSTANCE.convert(typeDefine);

Assertions.assertEquals(typeDefine.getName(), column.getName());
Assertions.assertEquals(PrimitiveByteArrayType.INSTANCE, column.getDataType());
Assertions.assertEquals(8, column.getColumnLength());
Assertions.assertEquals(typeDefine.getColumnType(), column.getSourceType());

typeDefine =
BasicTypeDefine.builder()
.name("test")
.columnType("ST_GEOMETRY")
.length(8L)
.dataType("ST_GEOMETRY")
.build();
column = SapHanaTypeConverter.INSTANCE.convert(typeDefine);

Assertions.assertEquals(typeDefine.getName(), column.getName());
Assertions.assertEquals(PrimitiveByteArrayType.INSTANCE, column.getDataType());
Assertions.assertEquals(8, column.getColumnLength());
Assertions.assertEquals(typeDefine.getColumnType(), column.getSourceType());
}

@Test
public void testReconvertUnsupported() {
Column column =
Expand Down

0 comments on commit 18dcca3

Please sign in to comment.