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

Unsupported query: unknown signature: avg(interval) #72

Closed
timgraham opened this issue Nov 6, 2019 · 1 comment · Fixed by cockroachdb/cockroach#42457
Closed

Unsupported query: unknown signature: avg(interval) #72

timgraham opened this issue Nov 6, 2019 · 1 comment · Fixed by cockroachdb/cockroach#42457

Comments

@timgraham
Copy link
Collaborator

Use the AVG database function on an interval column isn't supported by cockroachdb:

SELECT AVG("aggregation_publisher"."duration") AS "duration__avg"
FROM "aggregation_publisher";

It might be possible to workaround this as done for Oracle.

Django test failure:

======================================================================
ERROR: test_avg_duration_field (aggregation.tests.AggregateTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.UndefinedFunction: unknown signature: avg(interval)


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

Traceback (most recent call last):
  File "/home/tim/code/django/tests/aggregation/tests.py", line 465, in test_avg_duration_field
    Publisher.objects.aggregate(Avg('duration', output_field=DurationField())),
  File "/home/tim/code/django/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/tim/code/django/django/db/models/query.py", line 379, in aggregate
    return query.get_aggregation(self.db, kwargs)
  File "/home/tim/code/django/django/db/models/sql/query.py", line 489, in get_aggregation
    result = compiler.execute_sql(SINGLE)
  File "/home/tim/code/django/django/db/models/sql/compiler.py", line 1100, in execute_sql
    cursor.execute(sql, params)
  File "/home/tim/code/django/django/db/backends/utils.py", line 99, in execute
    return super().execute(sql, params)
  File "/home/tim/code/django/django/db/backends/utils.py", line 67, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/tim/code/django/django/db/backends/utils.py", line 76, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/tim/code/django/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/tim/code/django/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: unknown signature: avg(interval)

@rafiss
Copy link
Contributor

rafiss commented Nov 13, 2019

Linking to CockroachDB issue: cockroachdb/cockroach#42449

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants