cgivre commented on a change in pull request #2485:
URL: https://github.com/apache/drill/pull/2485#discussion_r826960727



##########
File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/TextFormatConfig.java
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.easy.text;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.drill.common.PlanStringBuilder;
+import org.apache.drill.common.logical.FormatPluginConfig;
+import org.apache.drill.shaded.guava.com.google.common.base.Strings;
+import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
+
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+@JsonTypeName(TextFormatPlugin.PLUGIN_NAME)
+@JsonInclude(Include.NON_DEFAULT)
+public class TextFormatConfig implements FormatPluginConfig {
+
+  public final List<String> extensions;
+  public final String lineDelimiter;
+  public final char fieldDelimiter;
+  public final char quote;
+  public final char escape;
+  public final char comment;
+  public final boolean skipFirstLine;
+  public final boolean extractHeader;
+
+  @JsonCreator
+  public TextFormatConfig(
+      @JsonProperty("extensions") List<String> extensions,
+      @JsonProperty("lineDelimiter") String lineDelimiter,
+      // Drill 1.17 and before used "delimiter" in the
+      // bootstrap storage plugins file, assume many instances
+      // exist in the field.
+      @JsonAlias("delimiter")

Review comment:
       That's cool... I didn't know you could do that.  

##########
File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/TextFormatConfig.java
##########
@@ -0,0 +1,125 @@
+/*
+ * 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.easy.text;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.apache.drill.common.PlanStringBuilder;
+import org.apache.drill.common.logical.FormatPluginConfig;
+import org.apache.drill.shaded.guava.com.google.common.base.Strings;
+import org.apache.drill.shaded.guava.com.google.common.collect.ImmutableList;
+
+import com.fasterxml.jackson.annotation.JsonAlias;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+
+@JsonTypeName(TextFormatPlugin.PLUGIN_NAME)
+@JsonInclude(Include.NON_DEFAULT)
+public class TextFormatConfig implements FormatPluginConfig {
+
+  public final List<String> extensions;
+  public final String lineDelimiter;
+  public final char fieldDelimiter;
+  public final char quote;
+  public final char escape;
+  public final char comment;
+  public final boolean skipFirstLine;
+  public final boolean extractHeader;
+
+  @JsonCreator
+  public TextFormatConfig(
+      @JsonProperty("extensions") List<String> extensions,
+      @JsonProperty("lineDelimiter") String lineDelimiter,
+      // Drill 1.17 and before used "delimiter" in the
+      // bootstrap storage plugins file, assume many instances
+      // exist in the field.
+      @JsonAlias("delimiter")
+      @JsonProperty("fieldDelimiter") String fieldDelimiter,
+      @JsonProperty("quote") String quote,
+      @JsonProperty("escape") String escape,
+      @JsonProperty("comment") String comment,
+      @JsonProperty("skipFirstLine") Boolean skipFirstLine,
+      @JsonProperty("extractHeader") Boolean extractHeader) {
+    this.extensions = extensions == null ?
+        ImmutableList.of() : ImmutableList.copyOf(extensions);
+    this.lineDelimiter = lineDelimiter == null ? "\n" : lineDelimiter;
+    this.fieldDelimiter = Strings.isNullOrEmpty(fieldDelimiter) ? ',' : 
fieldDelimiter.charAt(0);
+    this.quote = Strings.isNullOrEmpty(quote) ? '"' : quote.charAt(0);
+    this.escape = Strings.isNullOrEmpty(escape) ? '"' : escape.charAt(0);
+    this.comment = Strings.isNullOrEmpty(comment) ? '#' : comment.charAt(0);
+    this.skipFirstLine = skipFirstLine == null ? false : skipFirstLine;
+    this.extractHeader = extractHeader == null ? false : extractHeader;

Review comment:
       One of the major annoyances of Drill (IMHO) is the weird behavior with 
CSV files.   IMHO, we could give the users a better experience by making the 
`extractHeader` field `true` by default and that way the user gets what one 
would expect when you query tabular data.... a table.

##########
File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/easy/text/TextFormatPlugin.java
##########
@@ -81,9 +68,8 @@
  * to allow tight control of the size of produced batches (as well
  * as to support provided schema.)
  */
-public class TextFormatPlugin extends 
EasyFormatPlugin<TextFormatPlugin.TextFormatConfig> {
-
-  private final static String PLUGIN_NAME = "text";
+public class TextFormatPlugin extends EasyFormatPlugin<TextFormatConfig> {
+  final static String PLUGIN_NAME = "text";

Review comment:
       I know this would probably break things, but I'll ask anyway.  Do you 
think this plugin would be better named `delimited`?  It really refers to 
delimited formats such as PSV, TSV, etc.   If this is a major breaking change, 
don't worry about it.  It's always bothered me though.




-- 
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: dev-unsubscr...@drill.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to