This is an automated email from the ASF dual-hosted git repository.

dkuzmenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 883d5dfe259 HIVE-20917: Support applyQuotesToAll option in 
OpenCSVSerde (David Engel, reviewed by Denys Kuzmenko)
883d5dfe259 is described below

commit 883d5dfe25929ba5dcac635e752adf5561d28402
Author: David Engel <[email protected]>
AuthorDate: Fri Nov 8 08:52:25 2024 -0600

    HIVE-20917: Support applyQuotesToAll option in OpenCSVSerde (David Engel, 
reviewed by Denys Kuzmenko)
    
    Closes #5513
---
 .github/actions/spelling/expect.txt                            | 1 +
 serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/.github/actions/spelling/expect.txt 
b/.github/actions/spelling/expect.txt
index 98ab7679399..d7d233d3b4a 100644
--- a/.github/actions/spelling/expect.txt
+++ b/.github/actions/spelling/expect.txt
@@ -22,6 +22,7 @@ anullint
 anullstring
 aoig
 api
+APPLYQUOTESTOALL
 arecord
 args
 arraycopy
diff --git a/serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java 
b/serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java
index 9bb2d887527..7823bae125a 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java
@@ -52,7 +52,8 @@ import com.opencsv.CSVWriter;
  */
 @SerDeSpec(schemaProps = {
     serdeConstants.LIST_COLUMNS, serdeConstants.SERIALIZATION_ENCODING,
-    OpenCSVSerde.SEPARATORCHAR, OpenCSVSerde.QUOTECHAR, 
OpenCSVSerde.ESCAPECHAR})
+    OpenCSVSerde.SEPARATORCHAR, OpenCSVSerde.QUOTECHAR, 
OpenCSVSerde.ESCAPECHAR,
+    OpenCSVSerde.APPLYQUOTESTOALL})
 public final class OpenCSVSerde extends AbstractEncodingAwareSerDe {
 
   private ObjectInspector inspector;
@@ -63,10 +64,12 @@ public final class OpenCSVSerde extends 
AbstractEncodingAwareSerDe {
   private char separatorChar;
   private char quoteChar;
   private char escapeChar;
+  private boolean applyQuotesToAll;
 
   public static final String SEPARATORCHAR = "separatorChar";
   public static final String QUOTECHAR = "quoteChar";
   public static final String ESCAPECHAR = "escapeChar";
+  public static final String APPLYQUOTESTOALL = "applyQuotesToAll";
 
   @Override
   public void initialize(Configuration configuration, Properties 
tableProperties, Properties partitionProperties)
@@ -92,6 +95,7 @@ public final class OpenCSVSerde extends 
AbstractEncodingAwareSerDe {
     separatorChar = getProperty(properties, SEPARATORCHAR, 
CSVWriter.DEFAULT_SEPARATOR);
     quoteChar = getProperty(properties, QUOTECHAR, 
CSVWriter.DEFAULT_QUOTE_CHARACTER);
     escapeChar = getProperty(properties, ESCAPECHAR, 
CSVWriter.DEFAULT_ESCAPE_CHARACTER);
+    applyQuotesToAll = 
Boolean.parseBoolean(properties.getProperty(APPLYQUOTESTOALL, "true"));
   }
 
   private char getProperty(final Properties tbl, final String property, final 
char def) {
@@ -136,7 +140,7 @@ public final class OpenCSVSerde extends 
AbstractEncodingAwareSerDe {
     final CSVWriter csv = newWriter(writer, separatorChar, quoteChar, 
escapeChar);
 
     try {
-      csv.writeNext(outputFields);
+      csv.writeNext(outputFields, applyQuotesToAll);
       csv.close();
 
       return new Text(writer.toString());

Reply via email to