Re: Unit conversion database (was: multiple paramters in aggregate function)

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Unit conversion database (was: multiple paramters in aggregate function)
Дата
Msg-id 407d949e0908191240p57abb22el3ca2b5d35e792d25@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Unit conversion database (was: multiple paramters in aggregate function)  (Alvaro Herrera <alvherre@commandprompt.com>)
Ответы Re: Re: Unit conversion database (was: multiple paramters in aggregate function)
Список pgsql-general
On Wed, Aug 19, 2009 at 8:24 PM, Alvaro
Herrera<alvherre@commandprompt.com> wrote:
>> [1] It doesn't correctly convert °C to °F or vv, that was one of the
>> first things I tried.
>
> Seems it's easy to misuse it.  You need tempF(x) and tempC notation for
> converting absolute temperature differences:
>
> You have: tempF(212)
> You want: tempC
>        100

That depends on whether you're converting a temperature or a
temperature difference. If you want to know what a 100 degree C drop
in temperature equates to in Fahrenheit the answer is not 212 but
rather 180.

I think it would be useful to have a builtin data type which contained
a float and an opaque text unit. It could support linear operations
like +, -, and sum() by just throwing an error if the units didn't
match.

Then you could add an add-on function which converted one such datum
to another with a desired new units by calling out to the units
program.

That would allow people to store values with heterogenous units. So
for example you could have SMART stats in a single table where the
time values, unitless values, and temperature values are all in the
same column. As long as you only compare, say, drive temperatures to
max temperatures you never actually need to know about the units. It
would serve as an assertion check to ensure you don't compare drive
temperatures to error counts or something like that.

--
greg
http://mit.edu/~gsstark/resume.pdf

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Unit conversion database (was: multiple paramters in aggregate function)
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Re: Unit conversion database (was: multiple paramters in aggregate function)