Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1649161 Fix NaN value handling in schematization #920

Merged
merged 2 commits into from
Sep 9, 2024

Conversation

sfc-gh-mbobowski
Copy link
Contributor

@sfc-gh-mbobowski sfc-gh-mbobowski commented Sep 4, 2024

Overview

SNOW-1649161

Special floating point value NaN was causing exception with schematization enabled. The reason for this failure was parsing data to an intermediate JsonNode format and then calling writeValueAsString which returned ""NaN"".

This PR contains:

  • bugfix itself
  • integration test that was rewritten and moved to a separated file
  • e2e tests to validate NaN working in Snowpipe / Snowpipe Streaming ingestion

Pre-review checklist

  • This change should be part of a Behavior Change Release. See go/behavior-change.
  • This change has passed Merge gate tests
  • Snowpipe Changes
  • Snowpipe Streaming Changes
  • This change is TEST-ONLY
  • This change is README/Javadocs only
  • This change is protected by a config parameter <PARAMETER_NAME> eg snowflake.ingestion.method.
    • Yes - Added end to end and Unit Tests.
    • No - Suggest why it is not param protected
  • Is his change protected by parameter <PARAMETER_NAME> on the server side?
    • The parameter/feature is not yet active in production (partial rollout or PrPr, see Changes for Unreleased Features and Fixes).
    • If there is an issue, it can be safely mitigated by turning the parameter off. This is also verified by a test (See go/ppp).

@sfc-gh-mbobowski sfc-gh-mbobowski force-pushed the mbobowski-SNOW-1649161 branch 4 times, most recently from 9d85b23 to 62ab727 Compare September 6, 2024 10:59
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

public class SnowflakeSinkServiceV2AvroSchematizationIT {
Copy link
Contributor Author

@sfc-gh-mbobowski sfc-gh-mbobowski Sep 6, 2024

Choose a reason for hiding this comment

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

The logic of this test is the same as before with added NaN field. A couple of things I fixed here:

  1. Use String constants to avoid typos
  2. Use awaitility instead of custom code
  3. Use StringUtils.deleteWhitespace instead of custom code
  4. Use JUnit assertions instead of assert
  5. Use Junit @BeforeEach / @AfterEach
  6. Restructure the code to have a given / when / then
  7. Move test data to test class
  8. Make assertion explicit (if you have doubts take a look at what happens in checkTableContentOneRow())

So while it still can be better please keep your review bar at reasonable level here :)

@@ -204,6 +204,5 @@ if [ $testError -ne 0 ]; then
RED='\033[0;31m'
NC='\033[0m' # No Color
echo -e "${RED} There is error above this line ${NC}"
cat $APACHE_LOG_PATH/kc.log
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we need it at all. Printing 10k log lines might be useful in CI but for local development it makes things worse.

@sfc-gh-mbobowski sfc-gh-mbobowski marked this pull request as ready for review September 6, 2024 11:10
@sfc-gh-mbobowski sfc-gh-mbobowski requested a review from a team as a code owner September 6, 2024 11:10
@sfc-gh-mbobowski sfc-gh-mbobowski changed the title SNOW-1649161 Test float values in Avro SNOW-1649161 Fix NaN value handling in schematization Sep 6, 2024
Copy link
Contributor

@sfc-gh-achyzy sfc-gh-achyzy left a comment

Choose a reason for hiding this comment

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

LGTM

@sfc-gh-mbobowski sfc-gh-mbobowski merged commit 0b8af94 into master Sep 9, 2024
66 of 80 checks passed
@sfc-gh-mbobowski sfc-gh-mbobowski deleted the mbobowski-SNOW-1649161 branch September 9, 2024 08:25
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.

4 participants