Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
1 change: 1 addition & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Fixed `PARSE_SYNTAX_ERROR` for column names containing special characters (e.g., dots) when `EnableBatchedInserts` is enabled, by re-quoting column names with backticks in reconstructed multi-row INSERT statements.
- Fixed Volume ingestion for SEA mode, which was broken due to statement being closed prematurely.
- Fixed escaped pattern characters in catalogName for `getSchemas`, as returned catalogName should be unescaped.
- Fixed `getColumns()` returning `DATA_TYPE=0` (NULL) for GEOMETRY/GEOGRAPHY columns in Thrift mode. Now returns `Types.VARCHAR` (12) when geospatial is disabled and `Types.OTHER` (1111) when enabled, consistent with SEA mode.

---
*Note: When making changes, please add your change under the appropriate section
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1131,6 +1131,8 @@ int getCode(String s) {
case "CHARACTER":
return 1;
case "VARIANT":
case "GEOMETRY":
case "GEOGRAPHY":
return 1111;
}
if (s.startsWith(INTERVAL)) {
Expand Down Expand Up @@ -1626,8 +1628,10 @@ List<List<Object>> getThriftRows(List<List<Object>> rows, List<ResultColumn> col
}
}
if (column.getColumnName().equals(DATA_TYPE_COLUMN.getColumnName())) {
// Check if complex datatype support is disabled and this is a complex type
if (!ctx.isComplexDatatypeSupportEnabled() && isComplexType(typeVal)) {
// Check if geospatial support is disabled and this is a geospatial type
if (!ctx.isGeoSpatialSupportEnabled() && isGeospatialType(typeVal)) {
object = Types.VARCHAR;
} else if (!ctx.isComplexDatatypeSupportEnabled() && isComplexType(typeVal)) {
object = Types.VARCHAR;
} else {
object = getCode(stripBaseTypeName(typeVal));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ void testGetCode() {
assert metadataResultSetBuilder.getCode("SMALLINT") == 5;
assert metadataResultSetBuilder.getCode("INTEGER") == 4;
assert metadataResultSetBuilder.getCode("VARIANT") == 1111;
assert metadataResultSetBuilder.getCode("GEOMETRY") == 1111;
assert metadataResultSetBuilder.getCode("GEOGRAPHY") == 1111;
assert metadataResultSetBuilder.getCode("INTERVAL") == 12;
assert metadataResultSetBuilder.getCode("INTERVAL YEAR") == 12;
}
Expand Down Expand Up @@ -818,6 +820,48 @@ void testColumnDefIsPreservedInGetThriftRowsWhenDefaultExists() {
"'42'", updatedRows.get(0).get(12), "COLUMN_DEF should return the actual default value");
}

@Test
void testGetThriftRowsGeospatialDataTypeWhenDisabled() {
// When geospatial support is disabled, GEOMETRY/GEOGRAPHY DATA_TYPE should be VARCHAR (12)
when(connectionContext.isGeoSpatialSupportEnabled()).thenReturn(false);
lenient().when(connectionContext.isComplexDatatypeSupportEnabled()).thenReturn(true);

for (String typeName : List.of("GEOMETRY", "GEOGRAPHY")) {
List<Object> row =
Arrays.asList(
"cat", "schema", "tbl", "col", 0, typeName, 10, null, 0, 10, 1, "", null, null, null,
null, 0, "YES", null, null, null, null, "NO", "NO");
List<List<Object>> updatedRows =
metadataResultSetBuilder.getThriftRows(List.of(row), COLUMN_COLUMNS);

assertEquals(
Types.VARCHAR,
updatedRows.get(0).get(4),
typeName + " DATA_TYPE should be VARCHAR (12) when geospatial is disabled");
}
}

@Test
void testGetThriftRowsGeospatialDataTypeWhenEnabled() {
// When geospatial support is enabled, GEOMETRY/GEOGRAPHY DATA_TYPE should be OTHER (1111)
when(connectionContext.isGeoSpatialSupportEnabled()).thenReturn(true);
when(connectionContext.isComplexDatatypeSupportEnabled()).thenReturn(true);

for (String typeName : List.of("GEOMETRY", "GEOGRAPHY")) {
List<Object> row =
Arrays.asList(
"cat", "schema", "tbl", "col", 0, typeName, 10, null, 0, 10, 1, "", null, null, null,
null, 0, "YES", null, null, null, null, "NO", "NO");
List<List<Object>> updatedRows =
metadataResultSetBuilder.getThriftRows(List.of(row), COLUMN_COLUMNS);

assertEquals(
Types.OTHER,
updatedRows.get(0).get(4),
typeName + " DATA_TYPE should be OTHER (1111) when geospatial is enabled");
}
}

private static Stream<Arguments> provideColumnDefTypeNames() {
return Stream.of(
Arguments.of("INT"),
Expand Down
Loading