Skip to content
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 @@ -271,4 +271,9 @@ CREATE TABLE dbo.extreme_test_multi_block
IPv4_Nullable VARCHAR(15) NULL,
IPv6_Col VARCHAR(39) NOT NULL, -- e.g., 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF'
IPv6_Nullable VARCHAR(39) NULL
);
);

CREATE TABLE dbo.test_identity_decimal (
id decimal(18,0) IDENTITY(1,1),
col int
);
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,5 @@ insert into dbo.extreme_test_multi_block select * from dbo.extreme_test_multi_bl
insert into dbo.extreme_test_multi_block select * from dbo.extreme_test_multi_block;
insert into dbo.extreme_test_multi_block select * from dbo.extreme_test_multi_block;
insert into dbo.extreme_test_multi_block select * from dbo.extreme_test;

INSERT INTO dbo.test_identity_decimal(col) select 1;
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ protected Type jdbcTypeToDoris(JdbcFieldSchema fieldSchema) {
String originSqlserverType = fieldSchema.getDataTypeName().orElse("unknown");
// For sqlserver IDENTITY type, such as 'INT IDENTITY'
// originSqlserverType is "int identity", so we only get "int".
// For types with parameters like 'decimal(18,0) IDENTITY(1,1)', we need to extract the base type
String sqlserverType = originSqlserverType.split(" ")[0];

// Handle types with parentheses like decimal(18,0), varchar(50), etc.
if (sqlserverType.contains("(")) {
sqlserverType = sqlserverType.substring(0, sqlserverType.indexOf("("));
}

switch (sqlserverType) {
case "bit":
return Type.BOOLEAN;
Expand All @@ -55,7 +62,7 @@ protected Type jdbcTypeToDoris(JdbcFieldSchema fieldSchema) {
case "numeric": {
int precision = fieldSchema.getColumnSize().orElse(0);
int scale = fieldSchema.getDecimalDigits().orElse(0);
return ScalarType.createDecimalV3Type(precision, scale);
return createDecimalOrStringType(precision, scale);
}
case "date":
return ScalarType.createDateV2Type();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ timestamp_col text Yes true \N
1 doris 18 0 1 1 123.123 123.123 123.123 12345678901234567890123456789012345678 12345678901234567890123456789012345678 1234567890123456789012345678.0123456789 1234567890123456789012345678.0123456789 Make Doris Great! Make Doris Great! Make Doris Great! Make Doris Great! Make Doris Great! Make Doris Great! 2023-01-17 16:49:05.123 2023-01-17T16:49:05 2023-01-17T16:49:05.123456 2023-01-17T16:49 2023-01-17 16:49:05 +08:00 Make Doris Great! Make Doris Great! 922337203685477.5807 214748.3647 false
2 \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N \N

-- !identity_decimal --
1 1

-- !sql --
db_accessadmin
db_backupoperator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ suite("test_sqlserver_jdbc_catalog", "p0,external,sqlserver,external_docker,exte

order_qt_all_types_tvf """ select * from query('catalog' = '${catalog_name}', 'query' = 'select * from all_type;') order by 1"""

order_qt_identity_decimal """ select * from test_identity_decimal order by id; """

sql """ drop catalog if exists ${catalog_name} """

sql """ create catalog if not exists ${catalog_name} properties(
Expand Down
Loading