13
13
# limitations under the License.
14
14
15
15
import json
16
- import math
17
16
18
17
import numpy as np
19
18
import pandas as pd
@@ -160,20 +159,15 @@ def test_json_arrow_to_pandas():
160
159
s = arr .to_pandas ()
161
160
assert isinstance (s .dtypes , db_dtypes .JSONDtype )
162
161
assert s [0 ]
163
- assert s [1 ] == 100
164
- assert math .isclose (s [2 ], 0.98 )
165
- assert s [3 ] == "hello world"
166
- assert math .isclose (s [4 ][0 ], 0.1 )
167
- assert math .isclose (s [4 ][1 ], 0.2 )
168
- assert s [5 ] == {
169
- "null_field" : None ,
170
- "order" : {
171
- "items" : ["book" , "pen" , "computer" ],
172
- "total" : 15 ,
173
- "address" : {"street" : "123 Main St" , "city" : "Anytown" },
174
- },
175
- }
176
- assert pd .isna (s [6 ])
162
+ assert s [1 ] == "100"
163
+ assert s [2 ] == "0.98"
164
+ assert s [3 ] == '"hello world"'
165
+ assert s [4 ] == "[0.1,0.2]"
166
+ assert (
167
+ s [5 ]
168
+ == '{"null_field":null,"order":{"address":{"city":"Anytown","street":"123 Main St"},"items":["book","pen","computer"],"total":15}}'
169
+ )
170
+ assert s [6 ] == "null"
177
171
178
172
179
173
def test_json_arrow_to_pylist ():
@@ -186,20 +180,15 @@ def test_json_arrow_to_pylist():
186
180
s = arr .to_pylist ()
187
181
assert isinstance (s , list )
188
182
assert s [0 ]
189
- assert s [1 ] == 100
190
- assert math .isclose (s [2 ], 0.98 )
191
- assert s [3 ] == "hello world"
192
- assert math .isclose (s [4 ][0 ], 0.1 )
193
- assert math .isclose (s [4 ][1 ], 0.2 )
194
- assert s [5 ] == {
195
- "null_field" : None ,
196
- "order" : {
197
- "items" : ["book" , "pen" , "computer" ],
198
- "total" : 15 ,
199
- "address" : {"street" : "123 Main St" , "city" : "Anytown" },
200
- },
201
- }
202
- assert s [6 ] is None
183
+ assert s [1 ] == "100"
184
+ assert s [2 ] == "0.98"
185
+ assert s [3 ] == '"hello world"'
186
+ assert s [4 ] == "[0.1,0.2]"
187
+ assert (
188
+ s [5 ]
189
+ == '{"null_field":null,"order":{"address":{"city":"Anytown","street":"123 Main St"},"items":["book","pen","computer"],"total":15}}'
190
+ )
191
+ assert s [6 ] == "null"
203
192
204
193
205
194
def test_json_arrow_record_batch ():
@@ -226,17 +215,12 @@ def test_json_arrow_record_batch():
226
215
227
216
assert isinstance (s , list )
228
217
assert s [0 ]
229
- assert s [1 ] == 100
230
- assert math .isclose (s [2 ], 0.98 )
231
- assert s [3 ] == "hello world"
232
- assert math .isclose (s [4 ][0 ], 0.1 )
233
- assert math .isclose (s [4 ][1 ], 0.2 )
234
- assert s [5 ] == {
235
- "null_field" : None ,
236
- "order" : {
237
- "items" : ["book" , "pen" , "computer" ],
238
- "total" : 15 ,
239
- "address" : {"street" : "123 Main St" , "city" : "Anytown" },
240
- },
241
- }
242
- assert s [6 ] is None
218
+ assert s [1 ] == "100"
219
+ assert s [2 ] == "0.98"
220
+ assert s [3 ] == '"hello world"'
221
+ assert s [4 ] == "[0.1,0.2]"
222
+ assert (
223
+ s [5 ]
224
+ == '{"null_field":null,"order":{"address":{"city":"Anytown","street":"123 Main St"},"items":["book","pen","computer"],"total":15}}'
225
+ )
226
+ assert s [6 ] == "null"
0 commit comments