Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1thM9X-001SeH-Az for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Feb 2025 05:16:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1thM9W-002T9x-2G for pgsql-hackers@arkaria.postgresql.org; Mon, 10 Feb 2025 05:16:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1thM9V-002T9o-Kz for pgsql-hackers@lists.postgresql.org; Mon, 10 Feb 2025 05:16:13 +0000 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1thM9T-004Gof-1d for pgsql-hackers@postgresql.org; Mon, 10 Feb 2025 05:16:12 +0000 Received: by mail-pl1-x643.google.com with SMTP id d9443c01a7336-21f44e7eae4so58476745ad.2 for ; Sun, 09 Feb 2025 21:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739164571; x=1739769371; darn=postgresql.org; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=Hrp/ael+um6Ka4o3Ac1oVVDi/AisdWIMH0wRQEdkqA4=; b=JJygT8/TEhtZ4joNQq/lIEYaoWPYSsjUmM6MvTNC+ImQjYQs84EAjL1A8nO031N/cP wskooWNjO7OhwaR2HJxS8LMmpVWYAMkHd/pRA/RCvz8jZxaLaq8A53SwEZVr9wMa8ugZ 7FvKT7jV+/cWkH+pAfko1Awt744+TO/bENaH2mf504OkJ/pDxSJoSjuVWWlmdOhf0S9z sdE7jG9FEn5zIgaSOTtJDHUxcVajgSMMDeb4nQFvFemuxvGA7CIloKIeOJmVMWj5n+jS kkwfr04xghwyUULaqRHkDOIdwCKfX2sEi7zlOUAzhwSwHGrJdLeHBWxRtY/dXfZr/hrc /oOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739164571; x=1739769371; h=mime-version:subject:references:in-reply-to:message-id:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Hrp/ael+um6Ka4o3Ac1oVVDi/AisdWIMH0wRQEdkqA4=; b=aNlhEyOk1q6JtOG81ZlyFwp46XSBWko+XcGnmmuJvez+mYOrJyumXOywcCuXZKcONG lT2dJWjeiroq125ns1jc8DIvVxhM9D8XogRbHSBEonf9eEf/HaojtSw98DXmP4WEe3yh o7UJwa5bCV5MbmlodM1SZPRgV74Dy07iaVADe0lVvqXp9QklByvFNq2m+6jfIENQq/yY aNek6rV+tMDMUxm5LE1XfRM08ZV/8y9eajVcZ99DoF3uK4d9K3mYFszhbK+MFfRX0PzF uyLW+T6abVDjWPQM2/3OHf3EnCV2J819pwnXFdYcwIS1N+f9COM3uVM6VVjUYxr/igBr QzQg== X-Forwarded-Encrypted: i=1; AJvYcCXz0Uy45lzXfVLCgHZQ1RUd71xIRb2l5Veb1oJqjOaQ7kn+l9mi9w1kzprEpW+Cr5nDCeolmAb7TUUG5hpI@postgresql.org X-Gm-Message-State: AOJu0YyLZfCZN+LYqdD8AK2W4gFqDNLVcSxbha877kCzws222tBkLhN2 evmDDG/iz/ssGNOEJWLDewFRsLKbhhS3drigLUd1UQA5X1IKPzeA X-Gm-Gg: ASbGncsdJYd6uytQL8ewRG/FmEMZ/AHLmJoUY5dUo0X/q5SObR+iwpjmrFvQqaFg4Sf mirSnMdBlan7kVHViu8Bquj5UAfmiy+54Glo770lrzym8YBoz5hjWN+LsZ+chofPYDPReIrN3wa Y/MMeCcPBJeAe/nbal0LsumU7rQY8is1PjqEA/5k9AeXTJ05Yx7FRdij+nhuMb2yc25dWpfLEbU v+B4Vmah9ostNzduv4DUqRgTJ1tHRN1X8xFl2mhaXZQ5tzyBiroM2z0iMGOuqE7ZZmtMqq/0JN7 glnPN5DUeWFce5tD+rM= X-Google-Smtp-Source: AGHT+IHyeAD0Pm+ZQJZEaIUVFoAvZBKnigt20FbRdurxTEQHTfZAuLtMiIPP7qJywCJGxj16sClIUw== X-Received: by 2002:a17:902:f60a:b0:21f:3e2d:7d48 with SMTP id d9443c01a7336-21f4e129872mr203827675ad.0.1739164570911; Sun, 09 Feb 2025 21:16:10 -0800 (PST) Received: from [127.0.0.1] ([2406:da18:f9d:7d01:d528:4a39:fd47:7591]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21f3653afdbsm68998445ad.64.2025.02.09.21.16.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 09 Feb 2025 21:16:10 -0800 (PST) Date: Mon, 10 Feb 2025 13:15:58 +0800 From: Zhang Mingli To: Richard Guo , jian he Cc: Peter Eisentraut , Dean Rasheed , Alexander Lakhin , pgsql-hackers Message-ID: <12d5cce9-917f-4a99-86d3-715bb3b363bb@Spark> In-Reply-To: References: <09800cb1-43aa-4239-8918-46b71ede4900@eisentraut.org> <536b281b-2cb3-4477-971f-c64838bc6263@eisentraut.org> <51875199-d5f5-41ed-92dc-3e7b1b996991@eisentraut.org> <84adfb1b-826c-42b2-a907-b327d3760c7e@eisentraut.org> <831d7f99-0618-48e5-8557-f3d57137f339@eisentraut.org> <64c2468c-3b69-44d7-863a-165931a70c1d@eisentraut.org> <8be3512a-a23f-4088-a9ec-bf68650a2997@eisentraut.org> <75eb1a6f-d59f-42e6-8a78-124ee808cda7@gmail.com> <8d6a3d4c-f630-4cf9-aced-6cead95776e5@Spark> Subject: Re: Virtual generated columns X-Readdle-Message-ID: 12d5cce9-917f-4a99-86d3-715bb3b363bb@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="67a98b93_3823e1f5_1738b" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --67a98b93_3823e1f5_1738b Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On =46eb 10, 2025 at 12:53 +0800, jian he = , wrote: > > please check attached. > > > BTW, I was curious about what happens if the replacement expression i= s > > 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); > > > > =23 SELECT t2.a, t2.b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE; > > a =7C b > > ---+--- > > =7C 2 > > =7C 2 > > (2 rows) > > > > Is this the expected behavior=3F I was expecting that t2.b should be > > all NULLs. > > > SELECT t2.a, t2.b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE; > should be same as > SELECT t2.a, 2 as b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE; > 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 adhe= re to the same rules of join semantics. I agree with Richard, the result seems incorrect. The right outcome shoul= d be: gpadmin=3D=23 SELECT t2.a, t2.b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE; =C2=A0a =7C b ------+------ =C2=A0NULL =7C NULL =C2=A0NULL =7C NULL (2 rows) -- Zhang Mingli HashData --67a98b93_3823e1f5_1738b Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
On =46eb 10, 2025 at 12:53 +0800, jian he <jian.= universality=40gmail.com>, 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);

=23 SELECT t2.a, t2.b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE;
a =7C b
---+---
=7C 2
=7C 2
(2 rows)

Is this the expected behavior=3F I was expecting that t2.b should be
all NULLs.

SELECT t2.a, t2.b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE;
should be same as
SELECT t2.a, 2 as b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE;
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 adhe= re to the same rules of join semantics.
I agree with Richard, the result seems incorrect. The right outcome shoul= d be:&=23160;
gpadmin=3D=23 SELECT t2.a, t2.b =46ROM t t1 LE=46T JOIN t t2 ON =46ALSE;<= br /> &=23160;a =7C b
------+------
&=23160;NULL =7C NULL
&=23160;NULL =7C NULL
(2 rows)


--
Zhang Mingli
HashData




--67a98b93_3823e1f5_1738b--