Skip to content

Commit

Permalink
Add supported edge values
Browse files Browse the repository at this point in the history
  • Loading branch information
szehon-ho committed Sep 19, 2024
1 parent 0f28823 commit 38bf6f2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
2 changes: 1 addition & 1 deletion format/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Notes:
3. Character strings must be stored as UTF-8 encoded byte arrays.
4. Crs (coordinate reference system) is a mapping of how coordinates refer to precise locations on earth. Defaults to "OGC:CRS84". Fixed and cannot be changed by schema evolution.
5. Crs-encoding (coordinate reference system encoding) is the type of crs field. Must be set if crs is set. Defaults to "PROJJSON". Fixed and cannot be changed by schema evolution.
6. Edges is the interpretation for non-point geometries in geometry object, i.e. whether an edge between points represent a straight cartesian line or the shortest line on the sphere. Defaults to "planar". Fixed and cannot be changed by schema evolution.
6. Edges is the interpretation for non-point geometries in geometry object, i.e. whether an edge between points represent a straight cartesian line or the shortest line on the sphere. Supported values are "planar" (default) and "spherical". Fixed and cannot be changed by schema evolution.

For details on how to serialize a schema to JSON, see Appendix C.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,20 @@ public void testMergeWithAllClauses() {
+ "{ \"id\": 2, \"dep\": \"emp-id-2\" }\n"
+ "{ \"id\": 5, \"dep\": \"emp-id-5\" }");

String query = String.format("MERGE INTO %s AS t USING source AS s "
+ "ON t.id == s.id "
+ "WHEN MATCHED AND t.id = 1 THEN "
+ " UPDATE SET * "
+ "WHEN MATCHED AND t.id = 2 THEN "
+ " DELETE "
+ "WHEN NOT MATCHED THEN "
+ " INSERT * "
+ "WHEN NOT MATCHED BY SOURCE AND t.id = 3 THEN "
+ " UPDATE SET dep = 'invalid' "
+ "WHEN NOT MATCHED BY SOURCE AND t.id = 4 THEN "
+ " DELETE ", commitTarget());
System.out.println(spark.sql(query).logicalPlan());

sql(
"MERGE INTO %s AS t USING source AS s "
+ "ON t.id == s.id "
Expand Down Expand Up @@ -141,6 +155,13 @@ public void testMergeWithOneNotMatchedBySourceClause() {

createOrReplaceView("source", ImmutableList.of(1, 4), Encoders.INT());

String query = String.format("MERGE INTO %s AS t USING source AS s "
+ "ON t.id == s.value "
+ "WHEN NOT MATCHED BY SOURCE THEN "
+ " DELETE ", commitTarget());

System.out.println(spark.sql(query).logicalPlan());

sql(
"MERGE INTO %s AS t USING source AS s "
+ "ON t.id == s.value "
Expand Down Expand Up @@ -277,12 +298,18 @@ public void testCoalesceMerge() {
() -> {
sql(
"MERGE INTO %s t USING source "
+ "ON t.id = source.id "
+ "WHEN MATCHED THEN "
+ " UPDATE SET salary = -1 ",
+ " ON t.id = source.id "
+ " WHEN MATCHED THEN "
+ " UPDATE SET salary = -1 ",
commitTarget());
});

String query = String.format("MERGE INTO %s t USING source" +
" ON t.id = source.id" +
" WHEN MATCHED THEN" +
" UPDATE SET salary = -1", commitTarget());
System.out.println(spark.sql(query).logicalPlan());

Table table = validationCatalog.loadTable(tableIdent);
Snapshot currentSnapshot = SnapshotUtil.latestSnapshot(table, branch);

Expand Down

0 comments on commit 38bf6f2

Please sign in to comment.