mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 09:06:41 +03:00
Update docs
This commit is contained in:
parent
191eac4424
commit
7946a2a272
|
@ -4,6 +4,7 @@ Change Log
|
||||||
Unreleased
|
Unreleased
|
||||||
----------
|
----------
|
||||||
- Add PREWHERE support to querysets (M1hacka)
|
- Add PREWHERE support to querysets (M1hacka)
|
||||||
|
- Add WITH TOTALS support to querysets (M1hacka)
|
||||||
- Extend date field range (trthhrtz)
|
- Extend date field range (trthhrtz)
|
||||||
- Fix parsing of server errors in ClickHouse v19.3.3+
|
- Fix parsing of server errors in ClickHouse v19.3.3+
|
||||||
- Fix pagination when asking for the last page on a query that matches no records
|
- Fix pagination when asking for the last page on a query that matches no records
|
||||||
|
|
|
@ -912,6 +912,9 @@ The result is a namedtuple containing `objects` (list), `number_of_objects`,
|
||||||
#### select_fields_as_sql()
|
#### select_fields_as_sql()
|
||||||
|
|
||||||
|
|
||||||
|
Returns the selected fields or expressions as a SQL string.
|
||||||
|
|
||||||
|
|
||||||
### AggregateQuerySet
|
### AggregateQuerySet
|
||||||
|
|
||||||
Extends QuerySet
|
Extends QuerySet
|
||||||
|
@ -1030,3 +1033,14 @@ The result is a namedtuple containing `objects` (list), `number_of_objects`,
|
||||||
#### select_fields_as_sql()
|
#### select_fields_as_sql()
|
||||||
|
|
||||||
|
|
||||||
|
Returns the selected fields or expressions as a SQL string.
|
||||||
|
|
||||||
|
|
||||||
|
#### with_totals()
|
||||||
|
|
||||||
|
|
||||||
|
Adds WITH TOTALS modifier ot GROUP BY, making query return extra row
|
||||||
|
with aggregate function calculated across all the rows. More information:
|
||||||
|
https://clickhouse.yandex/docs/en/query_language/select/#with-totals-modifier
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -214,14 +214,14 @@ If you limit aggregation results, it might be useful to get total aggregation va
|
||||||
To achieve this, you can use `with_totals` method. It will return extra row (last) with
|
To achieve this, you can use `with_totals` method. It will return extra row (last) with
|
||||||
values aggregated for all rows suitable for filters.
|
values aggregated for all rows suitable for filters.
|
||||||
|
|
||||||
qs = Person.objects_in(database).aggregate('first_name' num='count()').with_totals().order_by('-count')[:3]
|
qs = Person.objects_in(database).aggregate('first_name', num='count()').with_totals().order_by('-count')[:3]
|
||||||
>>> print qs.count()
|
>>> print qs.count()
|
||||||
4
|
4
|
||||||
>>> for row in qs:
|
>>> for row in qs:
|
||||||
>>> print(row.first_name, row.count)
|
>>> print("'{}': {}".format(row.first_name, row.count))
|
||||||
'Cassandra' 2
|
'Cassandra': 2
|
||||||
'Alexandra' 2
|
'Alexandra': 2
|
||||||
'' 100
|
'': 100
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -333,6 +333,9 @@ class QuerySet(object):
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def select_fields_as_sql(self):
|
def select_fields_as_sql(self):
|
||||||
|
"""
|
||||||
|
Returns the selected fields or expressions as a SQL string.
|
||||||
|
"""
|
||||||
return comma_join('`%s`' % field for field in self._fields) if self._fields else '*'
|
return comma_join('`%s`' % field for field in self._fields) if self._fields else '*'
|
||||||
|
|
||||||
def as_sql(self):
|
def as_sql(self):
|
||||||
|
@ -574,6 +577,9 @@ class AggregateQuerySet(QuerySet):
|
||||||
raise NotImplementedError('Cannot re-aggregate an AggregateQuerySet')
|
raise NotImplementedError('Cannot re-aggregate an AggregateQuerySet')
|
||||||
|
|
||||||
def select_fields_as_sql(self):
|
def select_fields_as_sql(self):
|
||||||
|
"""
|
||||||
|
Returns the selected fields or expressions as a SQL string.
|
||||||
|
"""
|
||||||
return comma_join(list(self._fields) + ['%s AS %s' % (v, k) for k, v in self._calculated_fields.items()])
|
return comma_join(list(self._fields) + ['%s AS %s' % (v, k) for k, v in self._calculated_fields.items()])
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user