Drabble commented on code in PR #855:
URL: 
https://github.com/apache/incubator-baremaps/pull/855#discussion_r1619084887


##########
baremaps-core/src/main/java/org/apache/baremaps/storage/geoparquet/GeoParquetTypeConversion.java:
##########
@@ -0,0 +1,77 @@
+/*
+ * 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.baremaps.storage.geoparquet;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.baremaps.data.schema.DataColumn;
+import org.apache.baremaps.data.schema.DataColumn.Type;
+import org.apache.baremaps.data.schema.DataColumnImpl;
+import org.apache.baremaps.data.schema.DataRowType;
+import org.apache.baremaps.data.schema.DataRowTypeImpl;
+import org.apache.baremaps.geoparquet.data.GeoParquetGroup;
+import org.apache.baremaps.geoparquet.data.GeoParquetGroup.Field;
+import org.apache.baremaps.geoparquet.data.GeoParquetGroup.Schema;
+
+public class GeoParquetTypeConversion {
+
+  public static DataRowType asDataRowType(String table, Schema schema) {
+    List<DataColumn> fields = schema.fields().stream()
+        .map(field -> (DataColumn) new DataColumnImpl(field.name(), 
asDataRowType(field.type())))
+        .toList();
+    return new DataRowTypeImpl(table, fields);
+  }
+
+  public static Type asDataRowType(GeoParquetGroup.Type type) {
+    return switch (type) {
+      case BINARY -> Type.BYTE_ARRAY;
+      case BOOLEAN -> Type.BOOLEAN;
+      case INTEGER -> Type.INTEGER;
+      case INT96 -> Type.LONG;
+      case LONG -> Type.LONG;
+      case FLOAT -> Type.FLOAT;
+      case DOUBLE -> Type.DOUBLE;
+      case STRING -> Type.STRING;
+      case GEOMETRY -> Type.GEOMETRY;
+      case GROUP -> null;
+    };
+  }
+
+  public static List<Object> asDataRow(GeoParquetGroup group) {

Review Comment:
   Here it means that we will insert all the fields into the database as 
columns. Then if we want to return all the fields inside of JSONB field, we 
have to make a materialized view that regroups them right?



-- 
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