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

django: crash when comparing TIMESTAMP and DATE #255

Closed
timgraham opened this issue Dec 29, 2019 · 4 comments
Closed

django: crash when comparing TIMESTAMP and DATE #255

timgraham opened this issue Dec 29, 2019 · 4 comments
Labels
api: spanner Issues related to the googleapis/python-spanner-django API. blocked Issues that cannot be implemented because of some limit django-test-suite priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. we-cannot-typecheck-spanner-columns wontfix This will not be worked on

Comments

@timgraham
Copy link
Contributor

======================================================================
ERROR: test_mixed_comparisons1 (expressions.tests.FTimeDeltaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/.virtualenvs/django37/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 79, in next
    return six.next(self._wrapped)
  File "/home/tim/.virtualenvs/django37/lib/python3.7/site-packages/grpc/_channel.py", line 392, in __next__
    return self._next()
  File "/home/tim/.virtualenvs/django37/lib/python3.7/site-packages/grpc/_channel.py", line 561, in _next
    raise self
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
	status = StatusCode.INVALID_ARGUMENT
	details = "No matching signature for operator > for argument types: DATE, TIMESTAMP. Supported signature: ANY > ANY [at 1:263]\n...end` FROM expressions_ExPeRiMeNt WHERE expressions_ExPeRiMeNt.assigned > (...\n                                          ^"
	debug_error_string = "{"created":"@1576630086.782303263","description":"Error received from peer ipv4:172.217.6.234:443","file":"src/core/lib/surface/call.cc","file_line":1055,"grpc_message":"No matching signature for operator > for argument types: DATE, TIMESTAMP. Supported signature: ANY > ANY [at 1:263]\n...end` FROM expressions_ExPeRiMeNt WHERE expressions_ExPeRiMeNt.assigned > (...\n                                          ^","grpc_status":3}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/tim/code/django/django/test/testcases.py", line 1229, in skip_wrapper
    return test_func(*args, **kwargs)
  File "/home/tim/code/django/tests/expressions/tests.py", line 1202, in test_mixed_comparisons1
    test_set = [e.name for e in Experiment.objects.filter(assigned__gt=F('start') - delay)]
  File "/home/tim/code/django/django/db/models/query.py", line 274, in __iter__
    self._fetch_all()
  File "/home/tim/code/django/django/db/models/query.py", line 1242, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/tim/code/django/django/db/models/query.py", line 55, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 1166, in execute_sql
    return list(result)
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 1545, in cursor_iter
    for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 1545, in <lambda>
    for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
  File "/home/tim/code/django/django/db/utils.py", line 96, in inner
    return func(*args, **kwargs)
  File "/home/tim/code/spanner-orm/spanner/dbapi/cursor.py", line 250, in fetchmany
    items.append(tuple(self.__next__()))
  File "/home/tim/code/spanner-orm/spanner/dbapi/cursor.py", line 213, in __next__
    return next(self.__itr)
  File "/home/tim/.virtualenvs/django37/lib/python3.7/site-packages/google/cloud/spanner_v1/streamed.py", line 143, in __iter__
    self._consume_next()
  File "/home/tim/.virtualenvs/django37/lib/python3.7/site-packages/google/cloud/spanner_v1/streamed.py", line 116, in _consume_next
    response = six.next(self._response_iterator)
  File "/home/tim/.virtualenvs/django37/lib/python3.7/site-packages/google/cloud/spanner_v1/snapshot.py", line 45, in _restart_on_unavailable
    for item in iterator:
  File "/home/tim/.virtualenvs/django37/lib/python3.7/site-packages/google/api_core/grpc_helpers.py", line 81, in next
    six.raise_from(exceptions.from_grpc_error(exc), exc)
  File "<string>", line 3, in raise_from
google.api_core.exceptions.InvalidArgument: 400 No matching signature for operator > for argument types: DATE, TIMESTAMP. Supported signature: ANY > ANY [at 1:263]\n...end` FROM expressions_ExPeRiMeNt WHERE expressions_ExPeRiMeNt.assigned > (...\n                                          ^
@odeke-em
Copy link
Contributor

odeke-em commented Mar 4, 2020

Since there doesn't seem to be a Cloud Spanner function for casting DATE to TIMESTAMP and vice versa, I think that given that ISO 8601 allows for string comparison by magnitude, we'll need to format both to YYYYMMDD and then compare them in this normalized form.

@odeke-em
Copy link
Contributor

Perhaps we can convert DATE to TIMESTAMP with

TIMESTAMP(date_field, "GMT")

@timgraham
Copy link
Contributor Author

I believe this is another case of "we-cannot-typecheck-spanner-columns".

@timgraham timgraham removed their assignment Mar 20, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 7, 2020
@JustinBeckwith JustinBeckwith added the api: spanner Issues related to the googleapis/python-spanner-django API. label Apr 8, 2020
@odeke-em odeke-em added wontfix This will not be worked on and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 16, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 16, 2020
@odeke-em odeke-em added priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 16, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. and removed triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 16, 2020
@mf2199 mf2199 added the blocked Issues that cannot be implemented because of some limit label Aug 20, 2020
@asthamohta
Copy link
Contributor

Adding support to this would have serious performance impacts of this. In addition, real Spanner supports non-typed parameters, and the missing support for non-typed parameters for some type (DATE and TIMESTAMP) in the emulator is considered a bug: GoogleCloudPlatform/cloud-spanner-emulator#31
Further details about the decisions can be checked here: googleapis/python-spanner#200

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/python-spanner-django API. blocked Issues that cannot be implemented because of some limit django-test-suite priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. we-cannot-typecheck-spanner-columns wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants