public inbox for [email protected]
help / color / mirror / Atom feedFrom: Zhang Mingli <[email protected]>
To: Richard Guo <[email protected]>
To: jian he <[email protected]>
Cc: Peter Eisentraut <[email protected]>
Cc: Dean Rasheed <[email protected]>
Cc: Alexander Lakhin <[email protected]>
Cc: pgsql-hackers <[email protected]>
Subject: Re: Virtual generated columns
Date: Mon, 10 Feb 2025 13:15:58 +0800
Message-ID: <12d5cce9-917f-4a99-86d3-715bb3b363bb@Spark> (raw)
In-Reply-To: <CACJufxHVsCoxhqeDV973Hny3EtgCGztDJj=KKvErexnH=2k6yQ@mail.gmail.com>
References: <[email protected]>
<[email protected]>
<[email protected]>
<CAEZATCUHnmOu7RtDuP+PCtS_dqvU8hFsAYYFPdiB8gyFszj5WQ@mail.gmail.com>
<[email protected]>
<[email protected]>
<[email protected]>
<CAEZATCXQcjZPq+OsczFc13M6v+OP_NiqmUAcRAzi1K60KFuWmQ@mail.gmail.com>
<[email protected]>
<CAEZATCXnp5XTkUCsmfjLXVWZ7TaibWatnXDdu52J6zN3XsyZhw@mail.gmail.com>
<[email protected]>
<[email protected]>
<CAEZATCX6SHevKrVfAOq+88b4Ysm4Rqq2yeO6He3N0pttEbjYag@mail.gmail.com>
<[email protected]>
<CAEZATCVsfdp5MQpENpbrFAAfpC2tYU7y-Q=uOG57UubGy48Gyw@mail.gmail.com>
<[email protected]>
<[email protected]>
<8d6a3d4c-f630-4cf9-aced-6cead95776e5@Spark>
<CAMbWs4-h49s0ehfSq4CnztRLSwOF79ZQUkSPzGCQLNroAG7joA@mail.gmail.com>
<CACJufxHVsCoxhqeDV973Hny3EtgCGztDJj=KKvErexnH=2k6yQ@mail.gmail.com>
On Feb 10, 2025 at 12:53 +0800, jian he <[email protected]>, wrote:
>
> please check attached.
>
> > BTW, I was curious about what happens if the replacement expression is
> > constant, so I tried running the query below.
> >
> > CREATE TABLE t (a int, b int GENERATED ALWAYS AS (1 + 1));
> > INSERT INTO t VALUES (1);
> > INSERT INTO t VALUES (2);
> >
> > # SELECT t2.a, t2.b FROM t t1 LEFT JOIN t t2 ON FALSE;
> > a | b
> > ---+---
> > | 2
> > | 2
> > (2 rows)
> >
> > Is this the expected behavior? I was expecting that t2.b should be
> > all NULLs.
> >
> SELECT t2.a, t2.b FROM t t1 LEFT JOIN t t2 ON FALSE;
> should be same as
> SELECT t2.a, 2 as b FROM t t1 LEFT JOIN t t2 ON FALSE;
> so i think this is expected.
Hi,
I believe virtual columns should behave like stored columns, except they don't actually use storage.
Virtual columns are computed when the table is read, and they should adhere to the same rules of join semantics.
I agree with Richard, the result seems incorrect. The right outcome should be:
gpadmin=# SELECT t2.a, t2.b FROM t t1 LEFT JOIN t t2 ON FALSE;
a | b
------+------
NULL | NULL
NULL | NULL
(2 rows)
--
Zhang Mingli
HashData
view thread (29+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: Virtual generated columns
In-Reply-To: <12d5cce9-917f-4a99-86d3-715bb3b363bb@Spark>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox