Skip to content

Commit

Permalink
[Kernel] Handle long values in FieldMetadata parsing (#3186)
Browse files Browse the repository at this point in the history
## Description
Currently when parsing the `FieldMetadata` in `StructField` (as part of
the schema parsing), we always assume the integral values are of `int`
type, but it could be of value `long`.

## How was this patch tested?
Add couple of cases to existing test
  • Loading branch information
vkorukanti authored Jun 3, 2024
1 parent eccb75e commit 40896bc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ private static FieldMetadata parseFieldMetadata(JsonNode json) {

if (value.isNull()) {
builder.putNull(key);
} else if (value.isInt()) {
builder.putLong(key, value.intValue());
} else if (value.isIntegralNumber()) { // covers both int and long
builder.putLong(key, value.longValue());
} else if (value.isDouble()) {
builder.putDouble(key, value.doubleValue());
} else if (value.isBoolean()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ class DataTypeParserSuite extends AnyFunSuite {
|{
| "null" : null,
| "int" : 10,
| "long-1" : -16070400023423400,
| "long-2" : 16070400023423400,
| "double" : 2.22,
| "boolean" : true,
| "string" : "10",
Expand All @@ -161,6 +163,8 @@ class DataTypeParserSuite extends AnyFunSuite {
val expectedFieldMetadataAllTypes = FieldMetadata.builder()
.putNull("null")
.putLong("int", 10)
.putLong("long-1", -16070400023423400L)
.putLong("long-2", 16070400023423400L)
.putDouble("double", 2.22)
.putBoolean("boolean", true)
.putString("string", "10")
Expand Down

0 comments on commit 40896bc

Please # to comment.