Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

HIVE-3840 : hive cli null representation in output is inconsistent (T…

…hejas Nair via Ashutosh Chauhan)

git-svn-id: https://svn.apache.org/repos/asf/hive/trunk@1465261 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
commit ba34b9927735d5364de106a38b02aa24de10608f 1 parent 0010fbd
ashutoshc ashutoshc authored
10 ql/src/test/results/clientpositive/avro_nullable_fields.q.out
@@ -171,10 +171,10 @@ string 42 3 100 NULL true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42
171 171 string 42 3 100 1412341 NULL 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] [50,51,53]
172 172 string 42 3 100 1412341 true NULL 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] [50,51,53]
173 173 string 42 3 100 1412341 true 42.43 NULL ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] [50,51,53]
174   -string 42 3 100 1412341 true 42.43 85.23423424 null {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] [50,51,53]
175   -string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] null {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] [50,51,53]
176   -string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} null BLUE 72 [0,1,2,3,4,5] [50,51,53]
  174 +string 42 3 100 1412341 true 42.43 85.23423424 NULL {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] [50,51,53]
  175 +string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] NULL {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] [50,51,53]
  176 +string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} NULL BLUE 72 [0,1,2,3,4,5] [50,51,53]
177 177 string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} NULL 72 [0,1,2,3,4,5] [50,51,53]
178 178 string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE NULL [0,1,2,3,4,5] [50,51,53]
179   -string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 null [50,51,53]
180   -string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] null
  179 +string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 NULL [50,51,53]
  180 +string 42 3 100 1412341 true 42.43 85.23423424 ["alpha","beta","gamma"] {"Earth":42,"Bob":31,"Control":86} {"sint":17,"sboolean":true,"sstring":"Abe Linkedin"} BLUE 72 [0,1,2,3,4,5] NULL
2  ql/src/test/results/clientpositive/columnarserde_create_shortcut.q.out
@@ -119,7 +119,7 @@ POSTHOOK: Lineage: columnarserde_create_shortcut.e SIMPLE [(src_thrift)src_thrif
119 119 [7,14,21] ["70","700","7000"] {"key_7":"value_7"} -1461153973 record_7
120 120 [8,16,24] ["80","800","8000"] {"key_8":"value_8"} 1638581578 record_8
121 121 [9,18,27] ["90","900","9000"] {"key_9":"value_9"} 336964413 record_9
122   -null null null 0 NULL
  122 +NULL NULL NULL 0 NULL
123 123 PREHOOK: query: SELECT columnarserde_create_shortcut.a[0], columnarserde_create_shortcut.b[0], columnarserde_create_shortcut.c['key2'], columnarserde_create_shortcut.d, columnarserde_create_shortcut.e FROM columnarserde_create_shortcut CLUSTER BY 1
124 124 PREHOOK: type: QUERY
125 125 PREHOOK: Input: default@columnarserde_create_shortcut
2  ql/src/test/results/clientpositive/create_nested_type.q.out
@@ -52,4 +52,4 @@ POSTHOOK: Input: default@table1
52 52 a0 ["b00","b01"] [{"c001":"C001","c002":"C002"},{"c011":null,"c012":"C012"}] {"d01":["d011","d012"],"d02":["d021","d022"]}
53 53 a1 ["b10"] [{"c001":"C001","c002":"C002"}] {"d01":["d011","d012"],"d02":null}
54 54 a2 [] [{"c001":null,"c002":"C002"},{"c011":"C011","c012":"C012"}] {"d01":[null,"d012"],"d02":["d021","d022"]}
55   -a3 null null null
  55 +a3 NULL NULL NULL
2  ql/src/test/results/clientpositive/input17.q.out
@@ -126,7 +126,7 @@ POSTHOOK: Input: default@dest1
126 126 #### A masked pattern was here ####
127 127 POSTHOOK: Lineage: dest1.key SCRIPT [(src_thrift)src_thrift.FieldSchema(name:aint, type:int, comment:from deserializer), (src_thrift)src_thrift.FieldSchema(name:lint, type:array<int>, comment:from deserializer), (src_thrift)src_thrift.FieldSchema(name:lintstring, type:array<struct<myint:int,mystring:string,underscore_int:int>>, comment:from deserializer), ]
128 128 POSTHOOK: Lineage: dest1.value SCRIPT [(src_thrift)src_thrift.FieldSchema(name:aint, type:int, comment:from deserializer), (src_thrift)src_thrift.FieldSchema(name:lint, type:array<int>, comment:from deserializer), (src_thrift)src_thrift.FieldSchema(name:lintstring, type:array<struct<myint:int,mystring:string,underscore_int:int>>, comment:from deserializer), ]
129   -NULL null
  129 +NULL NULL
130 130 -1461153966 {"myint":49,"mystring":"343","underscore_int":7}
131 131 -1952710705 {"myint":25,"mystring":"125","underscore_int":5}
132 132 -734328905 {"myint":16,"mystring":"64","underscore_int":4}
2  ql/src/test/results/clientpositive/input5.q.out
@@ -126,6 +126,7 @@ POSTHOOK: Input: default@dest1
126 126 #### A masked pattern was here ####
127 127 POSTHOOK: Lineage: dest1.key SCRIPT [(src_thrift)src_thrift.FieldSchema(name:lint, type:array<int>, comment:from deserializer), (src_thrift)src_thrift.FieldSchema(name:lintstring, type:array<struct<myint:int,mystring:string,underscore_int:int>>, comment:from deserializer), ]
128 128 POSTHOOK: Lineage: dest1.value SCRIPT [(src_thrift)src_thrift.FieldSchema(name:lint, type:array<int>, comment:from deserializer), (src_thrift)src_thrift.FieldSchema(name:lintstring, type:array<struct<myint:int,mystring:string,underscore_int:int>>, comment:from deserializer), ]
  129 +NULL NULL
129 130 [0,0,0] [{"myint":0,"mystring":"0","underscore_int":0}]
130 131 [1,2,3] [{"myint":1,"mystring":"1","underscore_int":1}]
131 132 [2,4,6] [{"myint":4,"mystring":"8","underscore_int":2}]
@@ -136,4 +137,3 @@ POSTHOOK: Lineage: dest1.value SCRIPT [(src_thrift)src_thrift.FieldSchema(name:l
136 137 [7,14,21] [{"myint":49,"mystring":"343","underscore_int":7}]
137 138 [8,16,24] [{"myint":64,"mystring":"512","underscore_int":8}]
138 139 [9,18,27] [{"myint":81,"mystring":"729","underscore_int":9}]
139   -null null
2  ql/src/test/results/clientpositive/input_columnarserde.q.out
@@ -129,7 +129,7 @@ POSTHOOK: Lineage: input_columnarserde.e SIMPLE [(src_thrift)src_thrift.FieldSch
129 129 [7,14,21] ["70","700","7000"] {"key_7":"value_7"} -1461153973 record_7
130 130 [8,16,24] ["80","800","8000"] {"key_8":"value_8"} 1638581578 record_8
131 131 [9,18,27] ["90","900","9000"] {"key_9":"value_9"} 336964413 record_9
132   -null null null 0 NULL
  132 +NULL NULL NULL 0 NULL
133 133 PREHOOK: query: SELECT input_columnarserde.a[0], input_columnarserde.b[0], input_columnarserde.c['key2'], input_columnarserde.d, input_columnarserde.e FROM input_columnarserde DISTRIBUTE BY 1
134 134 PREHOOK: type: QUERY
135 135 PREHOOK: Input: default@input_columnarserde
2  ql/src/test/results/clientpositive/input_dynamicserde.q.out
@@ -158,7 +158,7 @@ POSTHOOK: Lineage: dest1.e SIMPLE [(src_thrift)src_thrift.FieldSchema(name:astri
158 158 [7,14,21] ["70","700","7000"] {"key_7":"value_7"} -1461153973 record_7
159 159 [8,16,24] ["80","800","8000"] {"key_8":"value_8"} 1638581578 record_8
160 160 [9,18,27] ["90","900","9000"] {"key_9":"value_9"} 336964413 record_9
161   -null null null 0 NULL
  161 +NULL NULL NULL 0 NULL
162 162 PREHOOK: query: SELECT dest1.a[0], dest1.b[0], dest1.c['key2'], dest1.d, dest1.e FROM dest1
163 163 PREHOOK: type: QUERY
164 164 PREHOOK: Input: default@dest1
6 ql/src/test/results/clientpositive/input_lazyserde.q.out
@@ -131,7 +131,7 @@ POSTHOOK: Lineage: dest1.e SIMPLE [(src_thrift)src_thrift.FieldSchema(name:astri
131 131 [7,14,21] ["70","700","7000"] {"key_7":"value_7"} -1461153973 record_7
132 132 [8,16,24] ["80","800","8000"] {"key_8":"value_8"} 1638581578 record_8
133 133 [9,18,27] ["90","900","9000"] {"key_9":"value_9"} 336964413 record_9
134   -null null null 0 NULL
  134 +NULL NULL NULL 0 NULL
135 135 PREHOOK: query: SELECT dest1.a[0], dest1.b[0], dest1.c['key2'], dest1.d, dest1.e FROM dest1 CLUSTER BY 1
136 136 PREHOOK: type: QUERY
137 137 PREHOOK: Input: default@dest1
@@ -217,7 +217,7 @@ POSTHOOK: Lineage: dest1.e SIMPLE [(src_thrift)src_thrift.FieldSchema(name:astri
217 217 [7,14,21]
218 218 [8,16,24]
219 219 [9,18,27]
220   -null
  220 +NULL
221 221 PREHOOK: query: DROP TABLE dest1
222 222 PREHOOK: type: DROPTABLE
223 223 PREHOOK: Input: default@dest1
@@ -283,4 +283,4 @@ POSTHOOK: Lineage: dest1.e SIMPLE [(src_thrift)src_thrift.FieldSchema(name:astri
283 283 {"key_7":"value_7"}
284 284 {"key_8":"value_8"}
285 285 {"key_9":"value_9"}
286   -null
  286 +NULL
2  ql/src/test/results/clientpositive/input_testxpath3.q.out
@@ -59,4 +59,4 @@ NULL [36]
59 59 NULL [49]
60 60 NULL [64]
61 61 value_9 [81]
62   -NULL null
  62 +NULL NULL
2  ql/src/test/results/clientpositive/join_thrift.q.out
@@ -109,7 +109,7 @@ POSTHOOK: Input: default@src_thrift
109 109 -1461153973 [{"myint":49,"mystring":"343","underscore_int":7}]
110 110 -751827638 [{"myint":4,"mystring":"8","underscore_int":2}]
111 111 -734328909 [{"myint":16,"mystring":"64","underscore_int":4}]
112   -0 null
  112 +0 NULL
113 113 336964413 [{"myint":81,"mystring":"729","underscore_int":9}]
114 114 465985200 [{"myint":1,"mystring":"1","underscore_int":1}]
115 115 477111222 [{"myint":9,"mystring":"27","underscore_int":3}]
192 ql/src/test/results/clientpositive/udf_percentile.q.out
@@ -306,56 +306,56 @@ GROUP BY CAST(key AS INT) DIV 10
306 306 POSTHOOK: type: QUERY
307 307 POSTHOOK: Input: default@src
308 308 #### A masked pattern was here ####
309   -0 NULL null
310   -1 NULL null
311   -2 NULL null
312   -3 NULL null
313   -4 NULL null
314   -5 NULL null
315   -6 NULL null
316   -7 NULL null
317   -8 NULL null
318   -9 NULL null
319   -10 NULL null
320   -11 NULL null
321   -12 NULL null
322   -13 NULL null
323   -14 NULL null
324   -15 NULL null
325   -16 NULL null
326   -17 NULL null
327   -18 NULL null
328   -19 NULL null
329   -20 NULL null
330   -21 NULL null
331   -22 NULL null
332   -23 NULL null
333   -24 NULL null
334   -25 NULL null
335   -26 NULL null
336   -27 NULL null
337   -28 NULL null
338   -29 NULL null
339   -30 NULL null
340   -31 NULL null
341   -32 NULL null
342   -33 NULL null
343   -34 NULL null
344   -35 NULL null
345   -36 NULL null
346   -37 NULL null
347   -38 NULL null
348   -39 NULL null
349   -40 NULL null
350   -41 NULL null
351   -42 NULL null
352   -43 NULL null
353   -44 NULL null
354   -45 NULL null
355   -46 NULL null
356   -47 NULL null
357   -48 NULL null
358   -49 NULL null
  309 +0 NULL NULL
  310 +1 NULL NULL
  311 +2 NULL NULL
  312 +3 NULL NULL
  313 +4 NULL NULL
  314 +5 NULL NULL
  315 +6 NULL NULL
  316 +7 NULL NULL
  317 +8 NULL NULL
  318 +9 NULL NULL
  319 +10 NULL NULL
  320 +11 NULL NULL
  321 +12 NULL NULL
  322 +13 NULL NULL
  323 +14 NULL NULL
  324 +15 NULL NULL
  325 +16 NULL NULL
  326 +17 NULL NULL
  327 +18 NULL NULL
  328 +19 NULL NULL
  329 +20 NULL NULL
  330 +21 NULL NULL
  331 +22 NULL NULL
  332 +23 NULL NULL
  333 +24 NULL NULL
  334 +25 NULL NULL
  335 +26 NULL NULL
  336 +27 NULL NULL
  337 +28 NULL NULL
  338 +29 NULL NULL
  339 +30 NULL NULL
  340 +31 NULL NULL
  341 +32 NULL NULL
  342 +33 NULL NULL
  343 +34 NULL NULL
  344 +35 NULL NULL
  345 +36 NULL NULL
  346 +37 NULL NULL
  347 +38 NULL NULL
  348 +39 NULL NULL
  349 +40 NULL NULL
  350 +41 NULL NULL
  351 +42 NULL NULL
  352 +43 NULL NULL
  353 +44 NULL NULL
  354 +45 NULL NULL
  355 +46 NULL NULL
  356 +47 NULL NULL
  357 +48 NULL NULL
  358 +49 NULL NULL
359 359 PREHOOK: query: -- test empty array handling
360 360 SELECT CAST(key AS INT) DIV 10,
361 361 percentile(IF(CAST(key AS INT) DIV 10 < 5, 1, NULL), 0.5),
@@ -379,51 +379,51 @@ POSTHOOK: Input: default@src
379 379 2 1.0 [1.0,1.0,1.0,1.0]
380 380 3 1.0 [1.0,1.0,1.0,1.0]
381 381 4 1.0 [1.0,1.0,1.0,1.0]
382   -5 NULL null
383   -6 NULL null
384   -7 NULL null
385   -8 NULL null
386   -9 NULL null
387   -10 NULL null
388   -11 NULL null
389   -12 NULL null
390   -13 NULL null
391   -14 NULL null
392   -15 NULL null
393   -16 NULL null
394   -17 NULL null
395   -18 NULL null
396   -19 NULL null
397   -20 NULL null
398   -21 NULL null
399   -22 NULL null
400   -23 NULL null
401   -24 NULL null
402   -25 NULL null
403   -26 NULL null
404   -27 NULL null
405   -28 NULL null
406   -29 NULL null
407   -30 NULL null
408   -31 NULL null
409   -32 NULL null
410   -33 NULL null
411   -34 NULL null
412   -35 NULL null
413   -36 NULL null
414   -37 NULL null
415   -38 NULL null
416   -39 NULL null
417   -40 NULL null
418   -41 NULL null
419   -42 NULL null
420   -43 NULL null
421   -44 NULL null
422   -45 NULL null
423   -46 NULL null
424   -47 NULL null
425   -48 NULL null
426   -49 NULL null
  382 +5 NULL NULL
  383 +6 NULL NULL
  384 +7 NULL NULL
  385 +8 NULL NULL
  386 +9 NULL NULL
  387 +10 NULL NULL
  388 +11 NULL NULL
  389 +12 NULL NULL
  390 +13 NULL NULL
  391 +14 NULL NULL
  392 +15 NULL NULL
  393 +16 NULL NULL
  394 +17 NULL NULL
  395 +18 NULL NULL
  396 +19 NULL NULL
  397 +20 NULL NULL
  398 +21 NULL NULL
  399 +22 NULL NULL
  400 +23 NULL NULL
  401 +24 NULL NULL
  402 +25 NULL NULL
  403 +26 NULL NULL
  404 +27 NULL NULL
  405 +28 NULL NULL
  406 +29 NULL NULL
  407 +30 NULL NULL
  408 +31 NULL NULL
  409 +32 NULL NULL
  410 +33 NULL NULL
  411 +34 NULL NULL
  412 +35 NULL NULL
  413 +36 NULL NULL
  414 +37 NULL NULL
  415 +38 NULL NULL
  416 +39 NULL NULL
  417 +40 NULL NULL
  418 +41 NULL NULL
  419 +42 NULL NULL
  420 +43 NULL NULL
  421 +44 NULL NULL
  422 +45 NULL NULL
  423 +46 NULL NULL
  424 +47 NULL NULL
  425 +48 NULL NULL
  426 +49 NULL NULL
427 427 PREHOOK: query: select percentile(cast(key as bigint), 0.5) from src where false
428 428 PREHOOK: type: QUERY
429 429 PREHOOK: Input: default@src
@@ -443,4 +443,4 @@ select percentile(cast(key as bigint), array()) from src where false
443 443 POSTHOOK: type: QUERY
444 444 POSTHOOK: Input: default@src
445 445 #### A masked pattern was here ####
446   -null
  446 +NULL
2  ql/src/test/results/clientpositive/udf_substr.q.out
@@ -181,7 +181,7 @@ FROM (
181 181 POSTHOOK: type: QUERY
182 182 POSTHOOK: Input: default@src
183 183 #### A masked pattern was here ####
184   -NULL NULL null null null A AB ABC ABC A AB ABC ABC B BC BC BC C C C C C C C C B BC BC BC A AB ABC ABC
  184 +NULL NULL NULL NULL NULL A AB ABC ABC A AB ABC ABC B BC BC BC C C C C C C C C B BC BC BC A AB ABC ABC
185 185 PREHOOK: query: -- test UTF-8 substr
186 186 SELECT
187 187 substr("玩", 1),
2  ql/src/test/results/clientpositive/udtf_stack.q.out
@@ -156,7 +156,7 @@ POSTHOOK: type: QUERY
156 156 POSTHOOK: Input: default@src
157 157 #### A masked pattern was here ####
158 158 x [1]
159   -z null
  159 +z NULL
160 160 PREHOOK: query: SELECT x, y FROM src LATERAL VIEW STACK(2, 'x', array(1), 'z', array(4)) a AS x, y LIMIT 2
161 161 PREHOOK: type: QUERY
162 162 PREHOOK: Input: default@src
4 serde/src/java/org/apache/hadoop/hive/serde2/DelimitedJSONSerDe.java
@@ -55,8 +55,9 @@ public Object deserialize(Writable field) throws SerDeException {
55 55 protected void serializeField(ByteStream.Output out, Object obj, ObjectInspector objInspector,
56 56 SerDeParameters serdeParams) throws SerDeException {
57 57 if (!objInspector.getCategory().equals(Category.PRIMITIVE) || (objInspector.getTypeName().equalsIgnoreCase(serdeConstants.BINARY_TYPE_NAME))) {
  58 + //do this for all complex types and binary
58 59 try {
59   - serialize(out, SerDeUtils.getJSONString(obj, objInspector),
  60 + serialize(out, SerDeUtils.getJSONString(obj, objInspector, serdeParams.getNullSequence().toString()),
60 61 PrimitiveObjectInspectorFactory.javaStringObjectInspector, serdeParams.getSeparators(),
61 62 1, serdeParams.getNullSequence(), serdeParams.isEscaped(), serdeParams.getEscapeChar(),
62 63 serdeParams.getNeedsEscape());
@@ -66,6 +67,7 @@ protected void serializeField(ByteStream.Output out, Object obj, ObjectInspector
66 67 }
67 68
68 69 } else {
  70 + //primitives except binary
69 71 super.serializeField(out, obj, objInspector, serdeParams);
70 72 }
71 73 }
41 serde/src/java/org/apache/hadoop/hive/serde2/SerDeUtils.java
@@ -62,6 +62,9 @@
62 62 public static final String LBRACE = "{";
63 63 public static final String RBRACE = "}";
64 64
  65 + // lower case null is used within json objects
  66 + private static final String JSON_NULL = "null";
  67 +
65 68 private static ConcurrentHashMap<String, Class<?>> serdes =
66 69 new ConcurrentHashMap<String, Class<?>>();
67 70
@@ -216,18 +219,32 @@ public static String lightEscapeString(String str) {
216 219 }
217 220
218 221 public static String getJSONString(Object o, ObjectInspector oi) {
  222 + return getJSONString(o, oi, JSON_NULL);
  223 + }
  224 +
  225 + /**
  226 + * Use this if you need to have custom representation of top level null .
  227 + * (ie something other than 'null')
  228 + * eg, for hive output, we want to to print NULL for a null map object.
  229 + * @param o Object
  230 + * @param oi ObjectInspector
  231 + * @param nullStr The custom string used to represent null value
  232 + * @return
  233 + */
  234 + public static String getJSONString(Object o, ObjectInspector oi, String nullStr) {
219 235 StringBuilder sb = new StringBuilder();
220   - buildJSONString(sb, o, oi);
  236 + buildJSONString(sb, o, oi, nullStr);
221 237 return sb.toString();
222 238 }
223 239
224   - static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi) {
  240 +
  241 + static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi, String nullStr) {
225 242
226 243 switch (oi.getCategory()) {
227 244 case PRIMITIVE: {
228 245 PrimitiveObjectInspector poi = (PrimitiveObjectInspector) oi;
229 246 if (o == null) {
230   - sb.append("null");
  247 + sb.append(nullStr);
231 248 } else {
232 249 switch (poi.getPrimitiveCategory()) {
233 250 case BOOLEAN: {
@@ -297,14 +314,14 @@ static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi) {
297 314 .getListElementObjectInspector();
298 315 List<?> olist = loi.getList(o);
299 316 if (olist == null) {
300   - sb.append("null");
  317 + sb.append(nullStr);
301 318 } else {
302 319 sb.append(LBRACKET);
303 320 for (int i = 0; i < olist.size(); i++) {
304 321 if (i > 0) {
305 322 sb.append(COMMA);
306 323 }
307   - buildJSONString(sb, olist.get(i), listElementObjectInspector);
  324 + buildJSONString(sb, olist.get(i), listElementObjectInspector, JSON_NULL);
308 325 }
309 326 sb.append(RBRACKET);
310 327 }
@@ -317,7 +334,7 @@ static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi) {
317 334 .getMapValueObjectInspector();
318 335 Map<?, ?> omap = moi.getMap(o);
319 336 if (omap == null) {
320   - sb.append("null");
  337 + sb.append(nullStr);
321 338 } else {
322 339 sb.append(LBRACE);
323 340 boolean first = true;
@@ -328,9 +345,9 @@ static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi) {
328 345 sb.append(COMMA);
329 346 }
330 347 Map.Entry<?, ?> e = (Map.Entry<?, ?>) entry;
331   - buildJSONString(sb, e.getKey(), mapKeyObjectInspector);
  348 + buildJSONString(sb, e.getKey(), mapKeyObjectInspector, JSON_NULL);
332 349 sb.append(COLON);
333   - buildJSONString(sb, e.getValue(), mapValueObjectInspector);
  350 + buildJSONString(sb, e.getValue(), mapValueObjectInspector, JSON_NULL);
334 351 }
335 352 sb.append(RBRACE);
336 353 }
@@ -340,7 +357,7 @@ static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi) {
340 357 StructObjectInspector soi = (StructObjectInspector) oi;
341 358 List<? extends StructField> structFields = soi.getAllStructFieldRefs();
342 359 if (o == null) {
343   - sb.append("null");
  360 + sb.append(nullStr);
344 361 } else {
345 362 sb.append(LBRACE);
346 363 for (int i = 0; i < structFields.size(); i++) {
@@ -352,7 +369,7 @@ static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi) {
352 369 sb.append(QUOTE);
353 370 sb.append(COLON);
354 371 buildJSONString(sb, soi.getStructFieldData(o, structFields.get(i)),
355   - structFields.get(i).getFieldObjectInspector());
  372 + structFields.get(i).getFieldObjectInspector(), JSON_NULL);
356 373 }
357 374 sb.append(RBRACE);
358 375 }
@@ -361,13 +378,13 @@ static void buildJSONString(StringBuilder sb, Object o, ObjectInspector oi) {
361 378 case UNION: {
362 379 UnionObjectInspector uoi = (UnionObjectInspector) oi;
363 380 if (o == null) {
364   - sb.append("null");
  381 + sb.append(nullStr);
365 382 } else {
366 383 sb.append(LBRACE);
367 384 sb.append(uoi.getTag(o));
368 385 sb.append(COLON);
369 386 buildJSONString(sb, uoi.getField(o),
370   - uoi.getObjectInspectors().get(uoi.getTag(o)));
  387 + uoi.getObjectInspectors().get(uoi.getTag(o)), JSON_NULL);
371 388 sb.append(RBRACE);
372 389 }
373 390 break;

0 comments on commit ba34b99

Please sign in to comment.
Something went wrong with that request. Please try again.