Re: Re: Add generate_series(date, date) and generate_series(date, date, integer)

Поиск
Список
Период
Сортировка
От Corey Huinker
Тема Re: Re: Add generate_series(date, date) and generate_series(date, date, integer)
Дата
Msg-id CADkLM=d7bj39qH3b9xvLX2c+6po4kUBO+8kGirrGjfsM5G_X1w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Re: Add generate_series(date, date) and generate_series(date, date, integer)  (Simon Riggs <simon@2ndQuadrant.com>)
Ответы Re: Re: Add generate_series(date, date) and generate_series(date, date, integer)  (Vik Fearing <vik@2ndquadrant.fr>)
Список pgsql-hackers

[step] is in days, but is not documented as such.


It is in days, and is not documented as such, but since a day is the smallest unit of time for a date, I felt there was no other interpretation.

 
My understanding is you want to replace this

SELECT d.dt::date as dt
FROM generate_series('2015-01-01'::date,
                     '2016-01-04'::date
                     interval '1 day') AS d(dt);

with this

SELECT d.dt
FROM generate_series('
2015-01-01'::date,
                     '2016-01-04'::date,
                     7) as d(dt);


I'd also like to be able to join the values of d.dt without typecasting them.
To me it's as awkward as (select 1::double + 1::double)::integer
 

Personally, I think writing  INTERVAL '7 days' to be clearer than just typing 7.

Well, nearly all my use cases involve the step being 1 (and thus omitted) or -1. 

Maybe this example will appeal to you

SELECT d.birth_date, COUNT(r.kiddo_name) 
FROM generate_series('2016-01-01'::date,'2016-01-10'::date) as d(birth_date)
LEFT OUTER JOIN birth_records r ON r.birth_date = d.birth_date
GROUP BY 1
ORDER BY 1;


Other than that, the only difference is the ::date part. Is it really worth adding extra code just for that? I would say not.

I would argue it belongs for the sake of completeness. 
We added generate_series for numerics when generate_series for floats already existed.

No comments on the patch itself, which seems to do the job, so apologies to give this opinion on your work, I do hope it doesn't put you off further contributions.

Thanks. I appreciate that.
 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [COMMITTERS] pgsql: Cosmetic improvements in new config_info code.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Relaxing SSL key permission checks