Skip to content

Commit 9453b3f

Browse files
committed
small update to JSON reading docs wrt unified numbers
1 parent 0c25a04 commit 9453b3f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/StardustDocs/topics/read.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,9 @@ DataFrame.readJson("https://covid.ourworldindata.org/data/owid-covid-data.json")
310310
### Column type inference from JSON
311311

312312
Type inference for JSON is much simpler than for CSV.
313-
JSON string literals are always supposed to have String type. Number literals
314-
take different `Number` kinds. Boolean literals are converted to `Boolean`.
313+
JSON string literals always become a `String`.
314+
Number literals are converted to a unified `Number` type which will fit all encountered numbers.
315+
Boolean literals are converted to `Boolean`.
315316

316317
Let's take a look at the following JSON:
317318

@@ -355,12 +356,12 @@ The corresponding [`DataFrame`](DataFrame.md) schema is:
355356
```text
356357
A: String
357358
B: Int
358-
C: Number
359+
C: Double
359360
D: Boolean?
360361
```
361362

362363
Column A has `String` type because all values are string literals, no implicit conversion is performed. Column C
363-
has `Number` type because it's the least common type for `Int` and `Double`.
364+
has the `Double` type because it's the smallest unified number type for `Int` and `Float`.
364365

365366
### JSON parsing options
366367

@@ -370,8 +371,8 @@ By default, if a type clash occurs when reading JSON, a new column group is crea
370371
any number of object properties:
371372

372373
"value" will be set to the value of the JSON element if it's a primitive, else it will be `null`.\
373-
"array" will be set to the array of values if the json element is an array, else it will be `[]`.\
374-
If the json element is an object, then each property will spread out to its own column in the group, else these columns
374+
"array" will be set to the array of values if the JSON element is an array, else it will be `[]`.\
375+
If the JSON element is an object, then each property will spread out to its own column in the group, else these columns
375376
will be `null`.
376377

377378
In this case `typeClashTactic = JSON.TypeClashTactic.ARRAY_AND_VALUE_COLUMNS`.

0 commit comments

Comments
 (0)