fix(#4235): Make SpannerSchemaUtilsTests deterministic by implementing SQL column sorting in SpannerSchemaUtils #4236
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, I implement a fix here for issue #4235 . The details of the issue can be found in that description, but to summarize briefly, the unit tests in
SpannerSchemaUtilsTeststhat verify SQL statements may fail occasionally since the generated SQL strings may have different column orderings on different runs due to how they are obtained. Though the tests may be stable now, it's not guaranteed to remain this way if the underlying environment changes for whatever reason, so it might be beneficial to address this.Fix:
The fix I implemented is the one I propose in the issue as well, which sorts the columns in the
addColumnDdlStrings()method ofSpannerSchemaUtils. I created a new methodcollectColumnDdlStrings()as a helper that preserves the original recursive column collection logic. Lastly, I changed the column ordering of the expected SQL strings in the 2 unit tests that are affected by this to alphabetical order.I ran all tests using
./mvnw clean testand observed a passing result. I'm assuming that column name ordering in the SQL statements is not important; apologies if I've misunderstood or missed something. If it is necessary to preserve a certain order (ie the ones present currently in expected strings of the unit tests), or if there is a better way to address this issue, please let me know. Thank you!