Skip to content

Commit 81d08a7

Browse files
authored
Fixed stripTypeName function (#1012)
## Description <!-- Provide a brief summary of the changes made and the issue they aim to address.--> Updated the stripTypeName function to strip the type only when it contains the close bracket in the end. This would parse ARRAY<DECIMAL(10,2)> correctly. ## Testing <!-- Describe how the changes have been tested--> Added unit test ## Additional Notes to the Reviewer <!-- Share any additional context or insights that may help the reviewer understand the changes better. This could include challenges faced, limitations, or compromises made during the development process. Also, mention any areas of the code that you would like the reviewer to focus on specifically. --> [PECOBLR-951](https://databricks.atlassian.net/browse/PECOBLR-951) [PECOBLR-951]: https://databricks.atlassian.net/browse/PECOBLR-951?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ NO_CHANGELOG=true
1 parent d60246f commit 81d08a7

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

development/.release-freeze.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"freeze": true,
33
"reason": "Releasing JDBC - 16th Sep",
4-
"allow_list": ["jayantsing-db/default-max-rows-per-block", "ResultSetMetadataFix"]
4+
"allow_list": ["jayantsing-db/default-max-rows-per-block", "ResultSetMetadataFix", "PECOBLR-951"]
55
}

src/main/java/com/databricks/jdbc/dbclient/impl/common/MetadataResultSetBuilder.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -499,11 +499,10 @@ public String stripTypeName(String typeName) {
499499
if (typeName == null) {
500500
return null;
501501
}
502-
int typeArgumentIndex = typeName.indexOf('(');
503-
if (typeArgumentIndex != -1) {
504-
return typeName.substring(0, typeArgumentIndex);
502+
boolean endsWithClosingBracket = typeName.endsWith(")");
503+
if (endsWithClosingBracket) {
504+
typeName = typeName.substring(0, typeName.lastIndexOf('('));
505505
}
506-
507506
return typeName;
508507
}
509508

src/test/java/com/databricks/jdbc/dbclient/impl/common/MetadataResultSetBuilderTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private static Stream<Arguments> stripTypeNameArguments() {
121121
Arguments.of("VARCHAR", "VARCHAR"),
122122
Arguments.of("CHAR(255)", "CHAR"),
123123
Arguments.of("TEXT", "TEXT"),
124-
Arguments.of("VARCHAR(", "VARCHAR"),
124+
Arguments.of("VARCHAR()", "VARCHAR"),
125125
Arguments.of("VARCHAR(100,200)", "VARCHAR"),
126126
Arguments.of("CHAR(123)", "CHAR"),
127127
Arguments.of("ARRAY<DOUBLE>", "ARRAY<DOUBLE>"),
@@ -131,7 +131,8 @@ private static Stream<Arguments> stripTypeNameArguments() {
131131
Arguments.of("MAP<STRING,INT>(50)", "MAP<STRING,INT>"),
132132
Arguments.of(null, null),
133133
Arguments.of("", ""),
134-
Arguments.of("INTEGER(10,5)", "INTEGER"));
134+
Arguments.of("INTEGER(10,5)", "INTEGER"),
135+
Arguments.of("ARRAY<DECIMAL(10,2)>", "ARRAY<DECIMAL(10,2)>"));
135136
}
136137

137138
private static Stream<Arguments> stripBaseTypeNameArguments() {

0 commit comments

Comments
 (0)