Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-19 Thread Michael Paquier
On Wed, Feb 19, 2025 at 03:40:56PM +0800, Zhang Mingli wrote: > Thanks for the correction. No problem. If you see anything else that you think is misleading, please feel free to ping me on this thread. -- Michael signature.asc Description: PGP signature

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-18 Thread Zhang Mingli
On Feb 19, 2025 at 14:53 +0800, Michael Paquier , wrote: > There was a hole in the tests for the option LIKE_STORAGE. Removing > the check for it in transformTableLikeClause() did now show a diff in > the tests. In the case of foreign tables, extended for storage is a > correct choice when using a

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-18 Thread Michael Paquier
On Tue, Feb 18, 2025 at 08:43:02PM +0800, Zhang Mingli wrote: > On Feb 18, 2025 at 09:54 +0800, Zhang Mingli , wrote: > > > > Will address the comments later,  thanks for review! > > Done in patch v6. There was a hole in the tests for the option LIKE_STORAGE. Removing the check for it in transfo

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-18 Thread Zhang Mingli
On Feb 18, 2025 at 09:54 +0800, Zhang Mingli , wrote: > > Will address the comments later,  thanks for review! Done in patch v6. -- Zhang Mingli HashData v6-0001-CREATE-FOREIGN-TABLE-LIKE.patch Description: Binary data

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-18 Thread Zhang Mingli
On Feb 18, 2025 at 09:54 +0800, Zhang Mingli , wrote: > > Will address the comments later,  thanks for review! Done in patch v6. -- Zhang Mingli HashData v6-0001-CREATE-FOREIGN-TABLE-LIKE.patch Description: Binary data

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-17 Thread Zhang Mingli
On Feb 18, 2025 at 08:49 +0800, Michael Paquier , wrote: > On Mon, Feb 17, 2025 at 07:14:59PM +0800, Zhang Mingli wrote: > > On Feb 17, 2025 at 15:24 +0800, Michael Paquier , > > wrote: > > > + * For foreign tables, they have no storage in Postgres. > > > + * Inapplicable options are ignored. > >

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-17 Thread Michael Paquier
On Mon, Feb 17, 2025 at 07:14:59PM +0800, Zhang Mingli wrote: > On Feb 17, 2025 at 15:24 +0800, Michael Paquier , wrote: >> + * For foreign tables, they have no storage in Postgres. >> + * Inapplicable options are ignored. >> >> Wording is a bit strange here. > >  * Foreign tables do not store dat

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-17 Thread Zhang Mingli
On Feb 17, 2025 at 15:24 +0800, Michael Paquier , wrote: > > + * For foreign tables, they have no storage in Postgres. > + * Inapplicable options are ignored. > > Wording is a bit strange here. Hi, is this better?  * Foreign tables do not store data in Postgres.  * Any options that are not applic

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-16 Thread Michael Paquier
On Tue, Feb 11, 2025 at 10:07:48AM -0600, Sami Imseih wrote: > I agree. I was just saying the test cases you provided are > enough. No changes needed for the tests. > > I have no further comments. The checks you are adding in the parse analysis of the LIKE clauses is surprisingly light. + * For

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-11 Thread Sami Imseih
> + Foreign tables have no real storage in PostgreSQL. > + Inapplicable options: INCLUDING INDEXES, > INCLUDING STORAGE, > > Oh, I corrected another one in the code comments, but I forgot about this one. > Done in patch v3. I attached v4 with some slight modifications to the wording, otherwise thi

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-11 Thread Zhang Mingli
On Feb 11, 2025 at 08:14 +0800, Sami Imseih , wrote: > > Patch V2 addressed the comments. > > > > Overall this LGTM. > > > > I still see a "no real storage" in v2 that should be removed > > from the documentation. > > > > + Foreign tables have no real storage in PostgreSQL. > > + Inapplicable optio

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-10 Thread Sami Imseih
> Patch V2 addressed the comments. Overall this LGTM. I still see a "no real storage" in v2 that should be removed from the documentation. + Foreign tables have no real storage in PostgreSQL. + Inapplicable options: INCLUDING INDEXES, INCLUDING STORAGE, I think the test coverage to check for th

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-09 Thread Zhang Mingli
On Feb 8, 2025 at 12:55 +0800, Sami Imseih , wrote: > > Fix CI failure of doc build in v1 patch. > > > > Thanks for the patch! I am +1 for this, but I have a few comments: Hi, tanks for review. > > > > 1/ In the IDENTITY case, the remote side may not be > > able to handle the DEFAULT value. Yes, an

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-07 Thread Sami Imseih
> Fix CI failure of doc build in v1 patch. Thanks for the patch! I am +1 for this, but I have a few comments: 1/ In the IDENTITY case, the remote side may not be able to handle the DEFAULT value. See the example below: -- on the foreign server postgres=# CREATE TABLE t2 (id int, c1 text); CREATE

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-07 Thread Zhang Mingli
On Feb 7, 2025 at 22:24 +0800, Zhang Mingli , wrote: > On Feb 6, 2025 at 18:09 +0800, Zhang Mingli , wrote: > > On Feb 3, 2025 at 08:29 +0800, Michael Paquier , wrote: > > > On Mon, Feb 03, 2025 at 06:22:13AM +0800, Mingli Zhang wrote: > > > > Yes, I would like to provide a patch. > > > > > > > > G

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-07 Thread Zhang Mingli
On Feb 6, 2025 at 18:09 +0800, Zhang Mingli , wrote: > On Feb 3, 2025 at 08:29 +0800, Michael Paquier , wrote: > > On Mon, Feb 03, 2025 at 06:22:13AM +0800, Mingli Zhang wrote: > > > Yes, I would like to provide a patch. > > > > > > Glad to see we have come to an agreement on this. > > > > Just add

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-06 Thread Zhang Mingli
On Feb 6, 2025 at 18:31 +0800, Álvaro Herrera , wrote: > > Ah, but our fine manual already says > > The LIKE clause can also be used to copy column definitions from views, > foreign tables, or composite types. Inapplicable options (e.g., > INCLUDING INDEXES from a view) are ignored. > > so what you

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-06 Thread Álvaro Herrera
On 2025-Feb-06, Álvaro Herrera wrote: > On 2025-Feb-06, Zhang Mingli wrote: > > > Added support for CREATE FOREIGN TABLE LIKE to enable the creation of > > foreign tables based on the column definitions, constraints of > > existing source tables. > > This feature mirrors the behavior of CREATE TA

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-06 Thread Álvaro Herrera
On 2025-Feb-06, Zhang Mingli wrote: > Added support for CREATE FOREIGN TABLE LIKE to enable the creation of > foreign tables based on the column definitions, constraints of > existing source tables. > This feature mirrors the behavior of CREATE TABLE LIKE, but ignores > inapplicable options such a

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-06 Thread Zhang Mingli
On Feb 3, 2025 at 08:29 +0800, Michael Paquier , wrote: > On Mon, Feb 03, 2025 at 06:22:13AM +0800, Mingli Zhang wrote: > > Yes, I would like to provide a patch. > > > > Glad to see we have come to an agreement on this. > > Just adding my +1 here. FWIW. Hi, Patch added. Added support for CREATE F

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-02 Thread Michael Paquier
On Mon, Feb 03, 2025 at 06:22:13AM +0800, Mingli Zhang wrote: > Yes, I would like to provide a patch. > > Glad to see we have come to an agreement on this. Just adding my +1 here. FWIW. -- Michael signature.asc Description: PGP signature

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-02 Thread Mingli Zhang
Zhang Mingli www.hashdata.xyz On Feb 2, 2025 at 21:24 +0800, Álvaro Herrera , wrote: Eh yeah, I guess for this use case it makes sense to allow a LIKE clause on CREATE FOREIGN TABLE. Were you going to submit a patch? Hi, Yes, I would like to provide a patch. Glad to see we have come to an agre

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-02 Thread Álvaro Herrera
On 2025-Feb-01, Zhang Mingli wrote: > For example, we use kafka_fdw to produce and consume data from a Kafka > server. In our scenario, we sometimes need to write records from a > local table into Kafka. Here’s a brief outline of our process: > > 1. We already have a wide table, local_wide_table

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-01 Thread Zhang Mingli
Zhang Mingli www.hashdata.xyz On Feb 1, 2025 at 20:20 +0800, Álvaro Herrera , wrote: > > Sure. Did you consider IMPORT FOREIGN SCHEMA? Hi, Álvaro Thank you very much for your suggestion. I've looked into it, and it certainly can be beneficial, especially for  postgres_fdw. However, I believe th

Re: Proposal to CREATE FOREIGN TABLE LIKE

2025-02-01 Thread Álvaro Herrera
On 2025-Feb-01, Zhang Mingli wrote: > Our DBA team uses foreign tables for ETL processes in Greenplum and > Cloudberry, > and we often need to create foreign tables that match the column definitions > of local tables. > > When dealing with wide tables and lots of those foreign tables, it can ge

Proposal to CREATE FOREIGN TABLE LIKE

2025-01-31 Thread Zhang Mingli
Hi, all I wanted to bring up an idea that could really help out. Our DBA team uses foreign tables for ETL processes in Greenplum and Cloudberry, and we often need to create foreign tables that match the column definitions of local tables. When dealing with wide tables and lots of those foreign