pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Alanoly Andrews <alanolya@invera.com>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Using a different column name in a foreign table
Date: Fri, 21 Jan 2022 08:33:06 -0800
Message-ID: <e50df4be-e952-886f-8f48-472314708d51@aklaver.com> (raw)
In-Reply-To: <YQXPR01MB3000CA608DF76835A6881B01AB5B9@YQXPR01MB3000.CANPRD01.PROD.OUTLOOK.COM>
References: <YQXPR01MB3000CA608DF76835A6881B01AB5B9@YQXPR01MB3000.CANPRD01.PROD.OUTLOOK.COM>

On 1/21/22 08:24, Alanoly Andrews wrote:
> Hello,
> I see that the syntax for the creation of a foreign table allows you to 
> use a column name in the FT that is different from the one in the base 
> table. Such a "create foreign table" statement executes successfully and 
> creates the FT. But when I query the FT, I get an error wrt to the 
> column that had been renamed. See example below:
> create foreign table tab1_ft (
>    id int,
>      name char(10) options(column_name 'newname'))
> server xxxxxx
> options(schema_name 'public', table_name 'tab1');

What is the definition of the table tab1?

> select * from tab1_ft;
> ERROR:  column "newname" does not exist
> HINT:  Perhaps you meant to reference the column "tab1.name".
> CONTEXT:  Remote SQL command: SELECT id, newname FROM public.tab1
> So, it seems that the when the remote SQL command is composed, the 
> mapping of 'newname' to the 'name' in the base table does not take effect.
> Is there a resolution to this issue?
> Awaiting some input.
> Alanoly Andrews.
> 



-- 
Adrian Klaver
adrian.klaver@aklaver.com





view thread (11+ messages)  latest in thread

Message-ID: <e50df4be-e952-886f-8f48-472314708d51@aklaver.com>
Permalink:  ../e50df4be-e952-886f-8f48-472314708d51@aklaver.com/
Also on:    postgresql.org/message-id/e50df4be-e952-886f-8f48-472314708d51@aklaver.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, alanolya@invera.com
  Subject: Re: Using a different column name in a foreign table
  In-Reply-To: <e50df4be-e952-886f-8f48-472314708d51@aklaver.com>
  References: <YQXPR01MB3000CA608DF76835A6881B01AB5B9@YQXPR01MB3000.CANPRD01.PROD.OUTLOOK.COM> <e50df4be-e952-886f-8f48-472314708d51@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox