Skip to content

Feat: to_json Infinity/-Infinity Nan values support#3875

Merged
andygrove merged 68 commits into
apache:mainfrom
kazantsev-maksim:to_json_infinity_nan_support
May 26, 2026
Merged

Feat: to_json Infinity/-Infinity Nan values support#3875
andygrove merged 68 commits into
apache:mainfrom
kazantsev-maksim:to_json_infinity_nan_support

Conversation

@kazantsev-maksim
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #3016

Rationale for this change

What changes are included in this PR?

How are these changes tested?

Tested with existing unit tests

Kazantsev Maksim and others added 3 commits April 24, 2026 21:59
@andygrove andygrove requested a review from comphead May 1, 2026 17:54
@andygrove
Copy link
Copy Markdown
Member

I started CI. I will review once CI has run. Thanks @kazantsev-maksim

@kazantsev-maksim
Copy link
Copy Markdown
Contributor Author

Tests using expect_fallback work incorrectly on Spark versions >= 4.0


statement
INSERT INTO test_to_json VALUES (1, 'hello'), (NULL, NULL), (0, '')
INSERT INTO test_to_json VALUES (1, 'hello', cast('NaN' as float), cast('Infinity' as double)), (NULL, NULL, NULL, NULL), (0, '', 0.0, 0.0)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add -Infinity to this test

.newBuilder()
.setChild(p)
.setTimezone(expr.timeZoneId.getOrElse("UTC"))
.setIgnoreNullFields(true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should setIgnoreNullFields be hard-coded to true?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the native code seems to ignore this field?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to respect SQLConf.get.jsonGeneratorIgnoreNullFields

Kazantsev Maksim and others added 6 commits May 20, 2026 20:51
…support

# Conflicts:
#	spark/src/main/spark-4.0/org/apache/comet/shims/CometExprShim.scala
#	spark/src/main/spark-4.1/org/apache/comet/shims/CometExprShim.scala
#	spark/src/main/spark-4.2/org/apache/comet/shims/CometExprShim.scala
@kazantsev-maksim
Copy link
Copy Markdown
Contributor Author

@andygrove I addressed the feedback. Could you take another look when you have time?

Copy link
Copy Markdown
Member

@andygrove andygrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM pending CI. Thanks for persevering with this @kazantsev-maksim

@kazantsev-maksim
Copy link
Copy Markdown
Contributor Author

Thanks for the review @andygrove.

@andygrove andygrove merged commit 9467917 into apache:main May 26, 2026
77 checks passed
@kazantsev-maksim kazantsev-maksim deleted the to_json_infinity_nan_support branch May 26, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: to_json does not support +Infinity, -Infinity for numeric types

3 participants