From 5bb09bff36222bb66ce08c9b105faa071c3d9af4 Mon Sep 17 00:00:00 2001 From: Piotr Fus Date: Tue, 12 Mar 2024 12:08:02 +0100 Subject: [PATCH] SNOW-1203558 Fix geo types values (#1663) --- src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java | 6 +++++- .../net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java index ebe8a9eac..73d07d6c4 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeUtil.java @@ -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: diff --git a/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java b/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java index 39f610a2c..b7cdb839d 100644 --- a/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java +++ b/src/test/java/net/snowflake/client/jdbc/SnowflakeDriverLatestIT.java @@ -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); @@ -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) {