Skip to content

Unable to write a single column to cloud spanner #3435

Closed
@vkedia

Description

@vkedia

Trying to write a single column value to cloud spanner raises an error saying mismatched number of columns and values:

def run_txn():
    from google.cloud import spanner
    spanner_client = spanner.Client()
    instance_id = 'your-instance'
    instance = spanner_client.instance(instance_id)
    database_id = 'example-db'
    database = instance.database(database_id)
    def f(t):
      t.insert_or_update(
          table="Singers",
          columns=('SingerId'),
          values = [[6]])
    database.run_in_transaction(f)

if __name__ == '__main__':
    run_txn()

This raises the error:

/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:335: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  SNIMissingWarning
/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:133: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecurePlatformWarning
Traceback (most recent call last):
  File "txn.py", line 16, in <module>
    run_txn()
  File "txn.py", line 13, in run_txn
    database.run_in_transaction(f)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/cloud/spanner/database.py", line 379, in run_in_transaction
    return session.run_in_transaction(func, *args, **kw)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/cloud/spanner/session.py", line 311, in run_in_transaction
    _delay_until_retry(exc, deadline)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/cloud/spanner/session.py", line 309, in run_in_transaction
    txn.commit()
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/cloud/spanner/transaction.py", line 114, in commit
    transaction_id=self._id, options=options)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/cloud/gapic/spanner/v1/spanner_client.py", line 832, in commit
    return self._commit(request, options)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 428, in inner
    return api_caller(api_call, this_settings, request)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 416, in base_caller
    return api_call(*args)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/gax/api_callable.py", line 376, in inner
    return a_func(*args, **kwargs)
  File "/usr/local/google/home/vikask/venvs/pythonq/local/lib/python2.7/site-packages/google/gax/retry.py", line 127, in inner
    ' classified as transient', exception)
google.gax.errors.RetryError: GaxError(Exception occurred in retry method that was not classified as transient, caused by <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Mutation has mismatched number of columns and values.)>)

Metadata

Metadata

Labels

api: spannerIssues related to the Spanner API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions