vvysotskyi commented on a change in pull request #1537: DRILL-6744: Support 
varchar and decimal push down
URL: https://github.com/apache/drill/pull/1537#discussion_r233397050
 
 

 ##########
 File path: 
exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestParquetReaderConfig.java
 ##########
 @@ -0,0 +1,122 @@
+/*
+ * 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.drill.exec.store.parquet;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.drill.common.config.DrillConfig;
+import org.apache.drill.exec.ExecConstants;
+import org.apache.drill.exec.server.options.SystemOptionManager;
+import org.apache.hadoop.conf.Configuration;
+import org.apache.parquet.ParquetReadOptions;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class TestParquetReaderConfig {
+
+  @Test
+  public void testDefaultsDeserialization() throws Exception {
+    ObjectMapper mapper = new ObjectMapper();
+    ParquetReaderConfig readerConfig = ParquetReaderConfig.builder().build(); 
// all defaults
+    String value = mapper.writeValueAsString(readerConfig);
+    assertEquals("{}", value);
+
+    readerConfig = mapper.readValue(value, ParquetReaderConfig.class);
+    assertTrue(readerConfig.autoCorrectCorruptedDates); // check that default 
value is restored
+
+    readerConfig.autoCorrectCorruptedDates = false; // change the default
+    readerConfig.enableStringsSignedMinMax = false; // update to the default
+
+    value = mapper.writeValueAsString(readerConfig);
+    assertEquals("{\"autoCorrectCorruptedDates\":false}", value);
+  }
+
+  @Test
+  public void testAddConfigToConf() {
+    Configuration conf = new Configuration();
+    conf.setBoolean(ParquetReaderConfig.ENABLE_BYTES_READ_COUNTER, true);
+    conf.setBoolean(ParquetReaderConfig.ENABLE_BYTES_TOTAL_COUNTER, true);
+    conf.setBoolean(ParquetReaderConfig.ENABLE_TIME_READ_COUNTER, true);
+
+    ParquetReaderConfig readerConfig = 
ParquetReaderConfig.builder().withConf(conf).build();
+    Configuration newConf = readerConfig.addCountersToConf(new 
Configuration());
+    checkConfigValue(newConf, ParquetReaderConfig.ENABLE_BYTES_READ_COUNTER, 
"true");
+    checkConfigValue(newConf, ParquetReaderConfig.ENABLE_BYTES_TOTAL_COUNTER, 
"true");
+    checkConfigValue(newConf, ParquetReaderConfig.ENABLE_TIME_READ_COUNTER, 
"true");
+
+    conf = new Configuration();
+    conf.setBoolean(ParquetReaderConfig.ENABLE_BYTES_READ_COUNTER, false);
+    conf.setBoolean(ParquetReaderConfig.ENABLE_BYTES_TOTAL_COUNTER, false);
+    conf.setBoolean(ParquetReaderConfig.ENABLE_TIME_READ_COUNTER, false);
+
+    readerConfig = ParquetReaderConfig.builder().withConf(conf).build();
+    newConf = readerConfig.addCountersToConf(new Configuration());
+    checkConfigValue(newConf, ParquetReaderConfig.ENABLE_BYTES_READ_COUNTER, 
"false");
+    checkConfigValue(newConf, ParquetReaderConfig.ENABLE_BYTES_TOTAL_COUNTER, 
"false");
+    checkConfigValue(newConf, ParquetReaderConfig.ENABLE_TIME_READ_COUNTER, 
"false");
+  }
+
+  @Test
+  public void testReadOptions() {
+    ParquetReaderConfig readerConfig = new ParquetReaderConfig();
 
 Review comment:
   Looks like we contravene the recommendation from its Javadoc

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to