Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-bli committed Mar 7, 2024
1 parent 881a425 commit a6d266f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/main/java/com/snowflake/snowpark_java/Row.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ private static Object[] javaObjectToScalaObject(Object[] input) {
result[i] =
com.snowflake.snowpark.types.Geography.fromGeoJSON(((Geography) result[i]).asGeoJSON());
} else if (result[i] instanceof Geometry) {
result[i] =
com.snowflake.snowpark.types.Geometry.fromGeoJSON(((Geometry) result[i]).toString());
result[i] = com.snowflake.snowpark.types.Geometry.fromGeoJSON(result[i].toString());
}
}
return result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
package com.snowflake.snowpark_test;

import com.snowflake.snowpark_java.types.Geography;
import com.snowflake.snowpark_java.types.Geometry;
import org.junit.Test;

public class JavaGeographySuite {

private final String testData =
"{\"geometry\":{\"type\":\"Point\",\"coordinates\":[125.6, 10.1]}}";

private final String testData2 =
"{\"coordinates\": [3.000000000000000e+01,1.000000000000000e+01],\"type\": \"Point\"}";

@Test
public void testRoundTrip() {
assert (Geography.fromGeoJSON(testData).asGeoJSON().equals(testData));
assert (Geography.fromGeoJSON(testData).toString().equals(testData));

assert (Geometry.fromGeoJSON(testData2).toString().equals(testData));
}

@Test
Expand All @@ -26,5 +32,8 @@ public void testEqual() {
assert Geography.fromGeoJSON(testData).hashCode() == Geography.fromGeoJSON(testData).hashCode();
assert Geography.fromGeoJSON(testData2).hashCode()
!= Geography.fromGeoJSON(testData).hashCode();

assert (Geometry.fromGeoJSON(this.testData2).equals(Geometry.fromGeoJSON(this.testData2)));
assert !(Geometry.fromGeoJSON(this.testData2).equals(Geometry.fromGeoJSON(testData2)));
}
}
13 changes: 10 additions & 3 deletions src/test/java/com/snowflake/snowpark_test/JavaRowSuite.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,24 @@ public void getters2() {
binary,
new Variant(3),
Geography.fromGeoJSON("{\"type\":\"Point\",\"coordinates\":[30,10]}"),
new BigDecimal(12345));
new BigDecimal(12345),
Geometry.fromGeoJSON(
"{\"coordinates\": [3.000000000000000e+01,1.000000000000000e+01],\"type\": \"Point\"}"));

assert row.size() == 4;
assert row.size() == 5;
assert Arrays.equals(row.getBinary(0), binary);
assert row.getVariant(1).equals(new Variant(3));
assert row.getGeography(2)
.equals(Geography.fromGeoJSON("{\"type\":\"Point\",\"coordinates\":[30,10]}"));
assert row.getDecimal(3).equals(new BigDecimal(12345));
assert row.getGeometry(4)
.equals(
Geometry.fromGeoJSON(
"{\"coordinates\": [3.000000000000000e+01,1.000000000000000e+01],\"type\": \"Point\"}"));

assert row.toString()
.equals("Row[Binary(1,2),3,{\"type\":\"Point\",\"coordinates\":[30,10]},12345]");
.equals(
"Row[Binary(1,2),3,{\"type\":\"Point\",\"coordinates\":[30,10]},12345,{\"coordinates\": [3.000000000000000e+01,1.000000000000000e+01],\"type\": \"Point\"}]");
}

@Test
Expand Down

0 comments on commit a6d266f

Please sign in to comment.