wgtmac commented on code in PR #1349:
URL: https://github.com/apache/parquet-mr/pull/1349#discussion_r1600949595


##########
parquet-hadoop/pom.xml:
##########
@@ -118,6 +118,11 @@
       <artifactId>jackson-core</artifactId>
       <version>${jackson.version}</version>
     </dependency>
+    <dependency>

Review Comment:
   Perhaps add a comment to explain it is required to serialize Optional type?



##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/metadata/StatisticsSerializer.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.parquet.hadoop.metadata;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import java.io.IOException;
+import org.apache.parquet.column.statistics.Statistics;
+
+class StatisticsSerializer extends JsonSerializer<Statistics<?>> {

Review Comment:
   Should we add a test?



##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/metadata/ParquetMetadata.java:
##########
@@ -32,6 +35,13 @@ public class ParquetMetadata {
 
   private static final ObjectMapper objectMapper = new ObjectMapper();
 
+  // Enable FAIL_ON_EMPTY_BEANS on objectmapper. Without this feature 
parquet-casdacing tests fail,
+  // because LogicalTypeAnnotation implementations are classes without any 
property.
+  static {
+    objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+    objectMapper.registerModule(new Jdk8Module());

Review Comment:
   ditto, add comment to explain why is it required?



##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/metadata/ParquetMetadata.java:
##########
@@ -50,19 +60,23 @@ public static String toPrettyJSON(ParquetMetadata 
parquetMetaData) {
 
   private static String toJSON(ParquetMetadata parquetMetaData, boolean 
isPrettyPrint) {
     try (StringWriter stringWriter = new StringWriter()) {
+      Object objectToPrint;
+      if (parquetMetaData.getFileMetaData() == null
+          || parquetMetaData.getFileMetaData().getEncryptionType()
+              == FileMetaData.EncryptionType.UNENCRYPTED) {
+        objectToPrint = parquetMetaData;
+      } else {
+        objectToPrint = parquetMetaData.getFileMetaData();
+      }
+
+      ObjectWriter writer;
       if (isPrettyPrint) {
-        Object objectToPrint;
-        if (parquetMetaData.getFileMetaData() == null
-            || parquetMetaData.getFileMetaData().getEncryptionType()
-                == FileMetaData.EncryptionType.UNENCRYPTED) {
-          objectToPrint = parquetMetaData;
-        } else {
-          objectToPrint = parquetMetaData.getFileMetaData();
-        }
-        objectMapper.writerWithDefaultPrettyPrinter().writeValue(stringWriter, 
objectToPrint);
+        writer = objectMapper.writerWithDefaultPrettyPrinter();
       } else {
-        objectMapper.writeValue(stringWriter, parquetMetaData);

Review Comment:
   cc @ggershinsky to see if this is fine.



##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/metadata/StatisticsSerializer.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.parquet.hadoop.metadata;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import java.io.IOException;
+import org.apache.parquet.column.statistics.Statistics;
+
+class StatisticsSerializer extends JsonSerializer<Statistics<?>> {

Review Comment:
   BTW, what is the original behavior?



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to