Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIFIs-0001TY-HY for pgsql-general@arkaria.postgresql.org; Thu, 10 Feb 2022 19:40:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nIFIr-0003Q2-Fo for pgsql-general@arkaria.postgresql.org; Thu, 10 Feb 2022 19:40:29 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nIFIr-0003Ni-1Q for pgsql-general@lists.postgresql.org; Thu, 10 Feb 2022 19:40:29 +0000 Received: from mail-pj1-x102e.google.com ([2607:f8b0:4864:20::102e]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nIFIo-0005ja-4g for pgsql-general@postgresql.org; Thu, 10 Feb 2022 19:40:28 +0000 Received: by mail-pj1-x102e.google.com with SMTP id ki18-20020a17090ae91200b001b8be87e9abso2531466pjb.1 for ; Thu, 10 Feb 2022 11:40:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:message-id:in-reply-to:references:subject :mime-version; bh=PmfReSfzRt64h5dx3gVAXlmC1L7SKxL9B5O+tuGorcg=; b=kYslZF1Ld+Un878isawqhijTaqXzVVDlMvZ02g+GPs3iw2txdg4Q5OXl9LRd6t1wrW msnlTFh0yaIw9hvtKds3kakQlpXVu9lD39wpiot7wRzKz7K83ABJds7ZNFfGL4bxSeWK OEq5IfwMaPDj3xA6bn48k+Ok80lprUVrKgYgbbK6N+BOTnIg652Ft3MU8eYiTKIydUTN iKp5ivACTg166xqM4fAoa6R7lY4xcYHE21sarnaskKBVBVDkpexCMyIn2HguzSUuYiwW CqdBpWZQBmvSKDXqtC74IsnPnujW+IJQ4uiQPl+7USjVh4gWi517jMJCRl9/FWQU+KMW FSoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to :references:subject:mime-version; bh=PmfReSfzRt64h5dx3gVAXlmC1L7SKxL9B5O+tuGorcg=; b=WKKEAZ0FtvKqUV1gLds3SM1y8zJZo97uAB0WEq6VCEer9IB7Fy9YXOs8wibxbYijNY jBsMNmvVdGFVDweoNTDX1m20SFDoDBARxkPTJ4A5k4qm8aCCSeva2ikfwrrpAgTlwAyR Z+PCDqNeXVxZTZYapTvvuu+vdTnApIsfKYqYE/z7SSWjoiXmDCSpftIK14TCK57frTQi SHyTdwDA3/ybAKE6Udp/gp3aLUEa9EOWMEsBbvbDZMrzjQYnOpFPsWqbwIo/Hfojwf/9 Q7m7SGq8Ib8A5L7cWQOLbh71W+FkPgFk3T3NHBSxYahfACB8EJ/ZNP2rcf8OBsaCzJdQ 7AdA== X-Gm-Message-State: AOAM532i1w1tMWvAPPo7jKvUwvCa/mIJKbt81D3zNSKuC5swCEvyCLPN hrTAwSChcGcF+M8FN37PoljTxzfRoWfFcg== X-Google-Smtp-Source: ABdhPJwZ1gHN+J2lBxUt/6FOLaBrJMnQP8M6X4oXVPEVnKTuPvbUULXKS+XDl8ooxivarR1zlnagLw== X-Received: by 2002:a17:903:40ce:: with SMTP id t14mr9095290pld.160.1644522024957; Thu, 10 Feb 2022 11:40:24 -0800 (PST) Received: from [2600:8801:8800:2:100::] ([2600:8801:8800:2::11]) by smtp.gmail.com with ESMTPSA id t1sm17199908pgj.43.2022.02.10.11.40.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Feb 2022 11:40:24 -0800 (PST) Date: Thu, 10 Feb 2022 11:40:04 -0800 From: Guyren Howe To: Merlin Moncure Cc: PG-General Mailing List Message-ID: <4e3f0ff8-6a5a-4f57-b5c0-f87b99f55dc7@Spark> In-Reply-To: References: <7117322c-185c-4283-990d-6646d8476409@Spark> Subject: Re: Can we go beyond the standard to make Postgres radically better? X-Readdle-Message-ID: 4e3f0ff8-6a5a-4f57-b5c0-f87b99f55dc7@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="62056a26_41b71efb_10f0d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --62056a26_41b71efb_10f0d Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I=E2=80=99d like to point out that sum types would be great. (Sum types let you have any of two or more different types in one value) =46or example, I could work around the issues with NULL by defining an en= umeration type with values like MISSING, UNKNOWN, INVALID, =E2=80=A6 and = then I can have a column that is a sum of that type with the type we norm= ally keep in the column. We would need some machinery to declare how aggregates work, but I think = that=E2=80=99s very much in the spirit of how types work in Postgres now.= In general, I would think we could make SQL a better functional programmi= ng language by just implementing good fp features like this. On =46eb 10, 2022, 11:09 -0800, Merlin Moncure , wr= ote: > On Thu, =46eb 10, 2022 at 10:54 AM Merlin Moncure wrote: > > > On Wed, =46eb 9, 2022 at 11:15 PM Guyren Howe = wrote: > > > > > > > > > > > > > > > =E2=80=A2 Also nested function definitions, so top-level fu= nctions can be built out of local auxiliary functions. > > > > > =E2=80=A2 Other languages > > > > > =E2=80=A2 Tutorial D, Datalog, Quell, let=E2=80=99s open th= is puppy up=21 > > > > > =E2=80=A2 SQL is a terrible, no good, very bad language > > > > > > > > > Postgres used to suport=C2=A0QUEL way back in the day.=C2=A0 Bein= g blunt, there is zero chance of this happening in core.=C2=A0 A query la= nguage translator out of core, preprocessing the language into SQL, might= work.=C2=A0 =C2=A0SQL has evolved far beyond what those languages could = practically offer.=C2=A0 =C2=A0Main benefit here would be to better suppo= rt relational division, which bizarrely has yet to arrive in SQL. > > > > =C2=A0A portable, low-level API > > > > =46YI, there was a semi-serious commercial attempt to do this back in= 2001, Dataphor. It's been opensourced.=C2=A0 Wikipedia has a pretty good= write up on it: > > https://en.wikipedia.org/wiki/Dataphor > > > > IMNSHO suggestions like these should travel this technical path; take= the data language you want and translate it into SQL.=C2=A0 Some of thes= e translations will end up being complicated (read: slow).=C2=A0 Iteratin= g this kind of thing outside of core would allow for faster development. > > > > merlin --62056a26_41b71efb_10f0d Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
I=E2=80=99d like to point out that sum types would = be great.

(Sum types let you have any of two or more different types in one value)<= br />
=46or example, I could work around the issues with NULL by defining an en= umeration type with values like MISSING, UNKNOWN, INVALID, =E2=80=A6 and = then I can have a column that is a sum of that type with the type we norm= ally keep in the column.

We would need some machinery to declare how aggregates work, but I think = that=E2=80=99s very much in the spirit of how types work in Postgres now.=

In general, I would think we could make SQL a better functional programmi= ng language by just implementing good fp features like this.
On =46eb 10, 2022, 11:09 -0800, Mer= lin Moncure <mmoncure=40gmail.com>, wrote:
On Thu, =46eb 10, 2022 at 10:54 AM Merlin Moncure &l= t;mmoncure=40gmail.com>= ; wrote:
On Wed, =46eb 9, 2022 at 11:15 PM Guyren Howe <guyren=40= gmail.com> wrote:
&=23160;
    • Also nested function definitions, so top-level functions can be b= uilt out of local auxiliary functions.
  • Other languages
    • Tutorial D, Datalog, Quell, let=E2=80=99s open this puppy up=21
    • SQL is a terrible, no good, very bad language
Postgres used to suport&=23160;QUEL way back in the day.&=23160; Bei= ng blunt, there is zero chance of this happening in core.&=23160; A query= language translator out of core, preprocessing the language into SQL, mi= ght work.&=23160; &=23160;SQL has evolved far beyond what those languages= could practically offer.&=23160; &=23160;Main benefit here would be to b= etter support relational division, which bizarrely has yet to arrive in S= QL.
&=23160;A portable, low-level API
&=23160;
=46YI, there was a semi-serious commercial attempt to do this back i= n 2001, Dataphor. It's been opensourced.&=23160; Wikipedia has a pretty g= ood write up on it:

IMNSHO suggestions like these should travel this technical path; tak= e the data language you want and translate it into SQL.&=23160; Some of t= hese translations will end up being complicated (read: slow).&=23160; Ite= rating this kind of thing outside of core would allow for faster developm= ent.

merlin
--62056a26_41b71efb_10f0d--