Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-20917: Support applyQuotesToAll option in OpenCSVSerde. #5513

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ anullint
anullstring
aoig
api
APPLYQUOTESTOALL
arecord
args
arraycopy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
*/
@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;
Expand All @@ -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)
Expand All @@ -92,6 +95,7 @@ public void initialize(Configuration configuration, Properties tableProperties,
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))
deniskuzZ marked this conversation as resolved.
Show resolved Hide resolved
}

private char getProperty(final Properties tbl, final String property, final char def) {
Expand Down Expand Up @@ -136,7 +140,7 @@ public Writable doSerialize(Object obj, ObjectInspector objInspector) throws Ser
final CSVWriter csv = newWriter(writer, separatorChar, quoteChar, escapeChar);

try {
csv.writeNext(outputFields);
csv.writeNext(outputFields, applyQuotesToAll);
csv.close();

return new Text(writer.toString());
Expand Down
Loading