26
26
*/
27
27
public final class CsvOptions extends FormatOptions {
28
28
29
- private static final long serialVersionUID = 2193570529308612708L ;
29
+ private static final long serialVersionUID = 2193570529308612709L ;
30
30
31
31
private final Boolean allowJaggedRows ;
32
32
private final Boolean allowQuotedNewLines ;
33
33
private final String encoding ;
34
34
private final String fieldDelimiter ;
35
+ private final String nullMarker ;
35
36
private final String quote ;
36
37
private final Long skipLeadingRows ;
37
38
private final Boolean preserveAsciiControlCharacters ;
@@ -42,6 +43,7 @@ public static final class Builder {
42
43
private Boolean allowQuotedNewLines ;
43
44
private String encoding ;
44
45
private String fieldDelimiter ;
46
+ private String nullMarker ;
45
47
private String quote ;
46
48
private Long skipLeadingRows ;
47
49
private Boolean preserveAsciiControlCharacters ;
@@ -53,6 +55,7 @@ private Builder(CsvOptions csvOptions) {
53
55
this .allowQuotedNewLines = csvOptions .allowQuotedNewLines ;
54
56
this .encoding = csvOptions .encoding ;
55
57
this .fieldDelimiter = csvOptions .fieldDelimiter ;
58
+ this .nullMarker = csvOptions .nullMarker ;
56
59
this .quote = csvOptions .quote ;
57
60
this .skipLeadingRows = csvOptions .skipLeadingRows ;
58
61
this .preserveAsciiControlCharacters = csvOptions .preserveAsciiControlCharacters ;
@@ -110,6 +113,18 @@ public Builder setFieldDelimiter(String fieldDelimiter) {
110
113
return this ;
111
114
}
112
115
116
+ /**
117
+ * [Optional] Specifies a string that represents a null value in a CSV file. For example, if you
118
+ * specify \"\\N\", BigQuery interprets \"\\N\" as a null value when querying a CSV file. The
119
+ * default value is the empty string. If you set this property to a custom value, BigQuery
120
+ * throws an error if an empty string is present for all data types except for STRING and BYTE.
121
+ * For STRING and BYTE columns, BigQuery interprets the empty string as an empty value.
122
+ */
123
+ public Builder setNullMarker (String nullMarker ) {
124
+ this .nullMarker = nullMarker ;
125
+ return this ;
126
+ }
127
+
113
128
/**
114
129
* Sets the value that is used to quote data sections in a CSV file. BigQuery converts the
115
130
* string to ISO-8859-1 encoding, and then uses the first byte of the encoded string to split
@@ -154,6 +169,7 @@ private CsvOptions(Builder builder) {
154
169
this .allowQuotedNewLines = builder .allowQuotedNewLines ;
155
170
this .encoding = builder .encoding ;
156
171
this .fieldDelimiter = builder .fieldDelimiter ;
172
+ this .nullMarker = builder .nullMarker ;
157
173
this .quote = builder .quote ;
158
174
this .skipLeadingRows = builder .skipLeadingRows ;
159
175
this .preserveAsciiControlCharacters = builder .preserveAsciiControlCharacters ;
@@ -192,6 +208,11 @@ public String getFieldDelimiter() {
192
208
return fieldDelimiter ;
193
209
}
194
210
211
+ /** Returns the string that represents a null value in a CSV file. */
212
+ public String getNullMarker () {
213
+ return nullMarker ;
214
+ }
215
+
195
216
/** Returns the value that is used to quote data sections in a CSV file. */
196
217
public String getQuote () {
197
218
return quote ;
@@ -226,6 +247,7 @@ public String toString() {
226
247
.add ("allowQuotedNewLines" , allowQuotedNewLines )
227
248
.add ("encoding" , encoding )
228
249
.add ("fieldDelimiter" , fieldDelimiter )
250
+ .add ("nullMarker" , nullMarker )
229
251
.add ("quote" , quote )
230
252
.add ("skipLeadingRows" , skipLeadingRows )
231
253
.add ("preserveAsciiControlCharacters" , preserveAsciiControlCharacters )
@@ -240,6 +262,7 @@ public int hashCode() {
240
262
allowQuotedNewLines ,
241
263
encoding ,
242
264
fieldDelimiter ,
265
+ nullMarker ,
243
266
quote ,
244
267
skipLeadingRows ,
245
268
preserveAsciiControlCharacters );
@@ -258,6 +281,7 @@ com.google.api.services.bigquery.model.CsvOptions toPb() {
258
281
csvOptions .setAllowQuotedNewlines (allowQuotedNewLines );
259
282
csvOptions .setEncoding (encoding );
260
283
csvOptions .setFieldDelimiter (fieldDelimiter );
284
+ csvOptions .setNullMarker (nullMarker );
261
285
csvOptions .setQuote (quote );
262
286
csvOptions .setSkipLeadingRows (skipLeadingRows );
263
287
csvOptions .setPreserveAsciiControlCharacters (preserveAsciiControlCharacters );
@@ -283,6 +307,9 @@ static CsvOptions fromPb(com.google.api.services.bigquery.model.CsvOptions csvOp
283
307
if (csvOptions .getFieldDelimiter () != null ) {
284
308
builder .setFieldDelimiter (csvOptions .getFieldDelimiter ());
285
309
}
310
+ if (csvOptions .getNullMarker () != null ) {
311
+ builder .setNullMarker (csvOptions .getNullMarker ());
312
+ }
286
313
if (csvOptions .getQuote () != null ) {
287
314
builder .setQuote (csvOptions .getQuote ());
288
315
}
0 commit comments