Skip to content

Commit

Permalink
SNOW-1203558 Fix geo types values (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pfus authored Mar 12, 2024
1 parent 730fbbf commit 5bb09bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,12 @@ static ColumnTypeInfo getSnowflakeType(
break;

case OBJECT:
int targetType =
"GEOGRAPHY".equals(extColTypeName) || "GEOMETRY".equals(extColTypeName)
? Types.VARCHAR
: Types.STRUCT;
columnTypeInfo =
new ColumnTypeInfo(Types.STRUCT, defaultIfNull(extColTypeName, "OBJECT"), baseType);
new ColumnTypeInfo(targetType, defaultIfNull(extColTypeName, "OBJECT"), baseType);
break;

case VARIANT:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ public void testGeoOutputTypes() throws Throwable {
regularStatement, false, "geoJson", "OBJECT", "java.lang.String", Types.STRUCT);

testGeoOutputTypeSingle(
regularStatement, true, "geoJson", "GEOGRAPHY", "java.lang.String", Types.STRUCT);
regularStatement, true, "geoJson", "GEOGRAPHY", "java.lang.String", Types.VARCHAR);

testGeoOutputTypeSingle(
regularStatement, false, "wkt", "VARCHAR", "java.lang.String", Types.VARCHAR);
Expand Down Expand Up @@ -989,10 +989,10 @@ public void testGeometryOutputTypes() throws Throwable {
"insert into t_geo2 values ('POINT(0 0)'), ('LINESTRING(1 1, 2 2)')");

testGeometryOutputTypeSingle(
regularStatement, true, "geoJson", "GEOMETRY", "java.lang.String", Types.STRUCT);
regularStatement, true, "geoJson", "GEOMETRY", "java.lang.String", Types.VARCHAR);

testGeometryOutputTypeSingle(
regularStatement, true, "wkt", "GEOMETRY", "java.lang.String", Types.STRUCT);
regularStatement, true, "wkt", "GEOMETRY", "java.lang.String", Types.VARCHAR);

} finally {
if (regularStatement != null) {
Expand Down

0 comments on commit 5bb09bf

Please sign in to comment.