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

Unable to write a single column to cloud spanner #3435

Closed
vkedia opened this issue May 17, 2017 · 1 comment
Closed

Unable to write a single column to cloud spanner #3435

vkedia opened this issue May 17, 2017 · 1 comment
Assignees
Labels
api: spanner Issues related to the Spanner API. type: question Request for information or clarification. Not an issue.

Comments

@vkedia
Copy link

vkedia commented May 17, 2017

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.)>)
@vkedia vkedia added api: spanner Issues related to the Spanner API. priority: p0 Highest priority. Critical issue. P0 implies highest priority. labels May 17, 2017
@bjwatson bjwatson added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. status: acknowledged labels May 17, 2017
@lukesneeringer
Copy link
Contributor

lukesneeringer commented May 17, 2017

This is a coding error:

          columns=('SingerId'),

That is a string, not a tuple. You need ['SingerId'] or ('SingerId',).

As is, you are sending an iterable with length 8 and effectively the values ('S', 'i', 'n', 'g', 'e', 'r', 'I', 'd').

@lukesneeringer lukesneeringer added type: question Request for information or clarification. Not an issue. and removed priority: p0 Highest priority. Critical issue. P0 implies highest priority. status: acknowledged type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels May 17, 2017
parthea pushed a commit that referenced this issue Oct 21, 2023
…rm/python-docs-samples#3436)

* [container_registry] fix: fix broken test

fixes #3435

* Use Pub/Sub message receiver that can notify main thread
  when it has received expected number of messages.
* Only test one single occurence.
* Use uuid4 wherever makes sense.
* test if Pub/Sub client receives at least one message
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 Spanner API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants