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

ayushsaxena 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 7950967eae9 HIVE-28248: Upgrade opencsv to v5.9 (#5240). (Dmitriy 
Fingerman, reviewed by Ayush Saxena)
7950967eae9 is described below

commit 7950967eae9640fcc0aa22f4b6c7906b34281eac
Author: Dmitriy Fingerman <[email protected]>
AuthorDate: Wed May 8 19:29:02 2024 -0400

    HIVE-28248: Upgrade opencsv to v5.9 (#5240). (Dmitriy Fingerman, reviewed 
by Ayush Saxena)
---
 pom.xml                                                  |  2 +-
 ql/pom.xml                                               | 16 +++++++++++-----
 serde/pom.xml                                            |  2 +-
 .../java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java | 14 +++++++++-----
 4 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2a2cc9e29ee..1a497d15fbf 100644
--- a/pom.xml
+++ b/pom.xml
@@ -181,7 +181,7 @@
     <mysql.version>8.0.31</mysql.version>
     <postgres.version>42.7.3</postgres.version>
     <oracle.version>21.3.0.0</oracle.version>
-    <opencsv.version>2.3</opencsv.version>
+    <opencsv.version>5.9</opencsv.version>
     <orc.version>1.8.5</orc.version>
     <mockito-core.version>3.4.4</mockito-core.version>
     <mockito-inline.version>4.11.0</mockito-inline.version>
diff --git a/ql/pom.xml b/ql/pom.xml
index 48ff5748bf3..8135294ecf4 100644
--- a/ql/pom.xml
+++ b/ql/pom.xml
@@ -536,11 +536,6 @@
       <groupId>stax</groupId>
       <artifactId>stax-api</artifactId>
     </dependency>
-    <dependency>
-      <groupId>net.sf.opencsv</groupId>
-      <artifactId>opencsv</artifactId>
-      <version>${opencsv.version}</version>
-    </dependency>
     <dependency>
       <groupId>org.apache.hive</groupId>
       <artifactId>hive-standalone-metastore-server</artifactId>
@@ -759,6 +754,17 @@
         </exclusion>
       </exclusions>
     </dependency>
+    <dependency>
+      <groupId>com.opencsv</groupId>
+      <artifactId>opencsv</artifactId>
+      <version>${opencsv.version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>commons-beanutils</groupId>
+          <artifactId>commons-beanutils</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
     <dependency>
       <groupId>org.apache.tez</groupId>
       <artifactId>tez-dag</artifactId>
diff --git a/serde/pom.xml b/serde/pom.xml
index b6c0f53edac..ad0bbcb7f60 100644
--- a/serde/pom.xml
+++ b/serde/pom.xml
@@ -100,7 +100,7 @@
       </exclusions>
     </dependency>
     <dependency>
-      <groupId>net.sf.opencsv</groupId>
+      <groupId>com.opencsv</groupId>
       <artifactId>opencsv</artifactId>
       <version>${opencsv.version}</version>
     </dependency>
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 243eeacf771..9bb2d887527 100644
--- a/serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java
+++ b/serde/src/java/org/apache/hadoop/hive/serde2/OpenCSVSerde.java
@@ -39,8 +39,10 @@ import java.util.List;
 import java.util.Objects;
 import java.util.Properties;
 
-import au.com.bytecode.opencsv.CSVReader;
-import au.com.bytecode.opencsv.CSVWriter;
+import com.opencsv.CSVParserBuilder;
+import com.opencsv.CSVReader;
+import com.opencsv.CSVReaderBuilder;
+import com.opencsv.CSVWriter;
 
 /**
  * OpenCSVSerde use opencsv to deserialize CSV format.
@@ -179,15 +181,17 @@ public final class OpenCSVSerde extends 
AbstractEncodingAwareSerDe {
     // CSVReader will throw an exception if any of separator, quote, or escape 
is the same, but
     // the CSV format specifies that the escape character and quote char are 
the same... very weird
     if (CSVWriter.DEFAULT_ESCAPE_CHARACTER == escape) {
-      return new CSVReader(reader, separator, quote);
+      return new CSVReaderBuilder(reader).withCSVParser(
+          new 
CSVParserBuilder().withSeparator(separator).withQuoteChar(quote).build()).build();
     } else {
-      return new CSVReader(reader, separator, quote, escape);
+      return new CSVReaderBuilder(reader).withCSVParser(
+          new 
CSVParserBuilder().withSeparator(separator).withQuoteChar(quote).withEscapeChar(escape).build()).build();
     }
   }
 
   private CSVWriter newWriter(final Writer writer, char separator, char quote, 
char escape) {
     if (CSVWriter.DEFAULT_ESCAPE_CHARACTER == escape) {
-      return new CSVWriter(writer, separator, quote, "");
+      return new CSVWriter(writer, separator, quote, '"', "");
     } else {
       return new CSVWriter(writer, separator, quote, escape, "");
     }

Reply via email to