Skip to content

Conversation

@zoercai
Copy link
Contributor

@zoercai zoercai commented Aug 24, 2021

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> ☕️

…ner-json

# Conflicts:
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractStructReaderTypesTest.java
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/ResultSetsTest.java
…ner-json

# Conflicts:
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueTest.java
…ner into spanner-json-test-suit

# Conflicts:
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITJsonWriteReadTest.java
#	google-cloud-spanner/src/test/resources/com/google/cloud/spanner/it/valid/y_100_nested.json
…nto spanner-json-test-suit

# Conflicts:
#	google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractStructReader.java
#	google-cloud-spanner/src/main/java/com/google/cloud/spanner/StructReader.java
#	google-cloud-spanner/src/main/java/com/google/cloud/spanner/Value.java
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/ResultSetsTest.java
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueBinderTest.java
#	google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueTest.java
#	proto-google-cloud-spanner-v1/src/main/java/com/google/spanner/v1/TypeCode.java
#	proto-google-cloud-spanner-v1/src/main/proto/google/spanner/v1/type.proto
@zoercai zoercai requested review from a team as code owners August 24, 2021 03:52
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Aug 24, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Aug 24, 2021
databaseClient.singleUse().executeQuery(Statement.of("SELECT * FROM " + TABLE_NAME));
int count = 0;
while (resultSet.next()) {
count++;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should either (in order of preference):

  1. Do a resultSet.getJson("json") here to verify that the value is also gettable in the client.
  2. Or: Just re-write the query to a SELECT COUNT(*) ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up going with option 2, because the JSON that gets returned is often not the same as what's inserted (e.g. [123e45] gets returned as [1.23e+47]), and it's difficult to automatically determine whether the returned value is equivalent to the inserted value without the same library that the backend uses to parse JSON. Since the tests are only there to confirm that the backend is able to accept the valid values, I don't think I'll bother spending the extra time manually adding the expected results for each file. Hopefully this is okay!

@zoercai zoercai requested a review from olavloite August 31, 2021 03:49
Copy link
Contributor

@thiagotnunes thiagotnunes left a comment

Choose a reason for hiding this comment

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

LGTM

.singleUse()
.executeQuery(Statement.of("SELECT COUNT(*) FROM " + TABLE_NAME))) {
resultSet.next();
assertEquals(resultSet.getLong(0), resources.size());
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we validate the JSON string as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We had a discussion about this above: #1376 (comment)

@zoercai zoercai added the automerge Merge the pull request once unit tests and other checks pass. label Sep 1, 2021
@gcf-merge-on-green gcf-merge-on-green bot merged commit 7efa796 into googleapis:master Sep 1, 2021
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Sep 1, 2021
@zoercai zoercai deleted the spanner-json-test-suit branch September 1, 2021 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants