[cloud-spanner-leaderboard-java]:

Open Beginner friendly
#767 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
68/100
Issue type
Documentation
Clarity
Clearly specified
Activity status
Stale
Tech stack
google-cloud, java
Domain
documentation

Research direction

In the codelab's “5. Load Data” section, compare the Java snippet and App.java stack trace with the linked Cloud Spanner commit-timestamp documentation. Update the instructions so the documented operation matches the API behavior, then verify the sample's timestamp insertion no longer produces the reported binding exception.

Written by the indexing model from the issue text.

Description

  1. Load Data

To auto-populate the Timestamp column with the timestamp of exactly when the "Insert" transaction takes place, you can instead insert the Java constant Value.COMMIT_TIMESTAMP like in the following code snippet:

.bind("Timestamp")
.to(Value.COMMIT_TIMESTAMP)

This is instruction doesn't seem to be right.

Exception in thread "main" com.google.cloud.spanner.SpannerException: UNKNOWN: Mutation.COMMIT_TIMESTAMP cannot be bound as a query parameter
        at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:151)
        at com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:45)
        at com.google.cloud.spanner.SpannerImpl$TransactionRunnerImpl.runInternal(SpannerImpl.java:1365)
        at com.google.cloud.spanner.SpannerImpl$TransactionRunnerImpl.run(SpannerImpl.java:1317)
        at com.google.cloud.spanner.SessionPool$PooledSession$1.run(SessionPool.java:408)
        at com.google.codelabs.App.insertScores(App.java:118)
        at com.google.codelabs.App.insert(App.java:59)
        at com.google.codelabs.App.main(App.java:247)
Caused by: java.lang.IllegalArgumentException: Mutation.COMMIT_TIMESTAMP cannot be bound as a query parameter
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:141)
        at com.google.cloud.spanner.Statement$Builder$Binder.handle(Statement.java:103)
        at com.google.cloud.spanner.Statement$Builder$Binder.handle(Statement.java:100)
        at com.google.cloud.spanner.ValueBinder.to(ValueBinder.java:99)
        at com.google.codelabs.App$2.run(App.java:155)
        at com.google.codelabs.App$2.run(App.java:119)
        at com.google.cloud.spanner.SpannerImpl$TransactionRunnerImpl.runInternal(SpannerImpl.java:1349)

As per doc[1], mutation instead of statement should be used in such case.

https://cloud.google.com/spanner/docs/commit-timestamp#insert-row

Dominant language
No language data
Stars
30
Forks
60
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from googlecodelabs/feedback

All issues in googlecodelabs/feedback

Similar issues

More Documentation issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.