byronellis commented on code in PR #2328:
URL: https://github.com/apache/polaris/pull/2328#discussion_r2278041539


##########
persistence/google-cloud-spanner/src/main/java/org/apache/polaris/persistence/relational/spanner/util/SpannerUtil.java:
##########
@@ -0,0 +1,154 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.persistence.relational.spanner.util;
+
+import com.google.cloud.ServiceOptions;
+import com.google.cloud.spanner.DatabaseId;
+import com.google.cloud.spanner.Dialect;
+import com.google.cloud.spanner.InstanceId;
+import com.google.cloud.spanner.Key;
+import com.google.cloud.spanner.KeySet;
+import com.google.cloud.spanner.ResultSet;
+import com.google.cloud.spanner.Spanner;
+import com.google.cloud.spanner.SpannerOptions;
+import com.google.cloud.spanner.Struct;
+import com.google.cloud.spanner.StructReader;
+import com.google.cloud.spanner.Type;
+import com.google.cloud.spanner.Value;
+import com.google.gson.Gson;
+import com.google.gson.JsonObject;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.Stream;
+import java.util.stream.StreamSupport;
+import 
org.apache.polaris.persistence.relational.spanner.GoogleCloudSpannerConfiguration;
+
+public final class SpannerUtil {
+
+  public static final String INT64_TYPE =
+      Type.int64().getSpannerTypeName(Dialect.GOOGLE_STANDARD_SQL);
+  public static final String STRING_TYPE =
+      Type.string().getSpannerTypeName(Dialect.GOOGLE_STANDARD_SQL);
+
+  public static final String JSON_TYPE =
+      Type.json().getSpannerTypeName(Dialect.GOOGLE_STANDARD_SQL);
+
+  private static final Gson GSON = new Gson();
+
+  public static Value jsonValue(Map<String, String> properties) {
+    JsonObject jsonObject = new JsonObject();
+    if (properties != null) {
+      properties.forEach(jsonObject::addProperty);
+    }
+    return Value.json(jsonObject.toString());
+  }
+
+  public static Map<String, String> jsonMap(String properties) {
+    HashMap<String, String> map = new HashMap<>();
+    if (properties != null && !properties.isBlank()) {
+      JsonObject obj = GSON.fromJson(properties, JsonObject.class);

Review Comment:
   I don't think it's a strict requirement. It comes along for the ride with 
Spanner so I used it more or less out of habit. Jackson would be fine too I 
think? Let me try it



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to