Skip to content

CREATE EXTERNAL TABLE with a non-existent EXECUTE command returns 0 rows instead of an error #1385

@robertmu

Description

@robertmu

When creating an external table using CREATE EXTERNAL TABLE ... EXECUTE '...', if the specified command in the EXECUTE clause does not exist, Cloudberry returns 0 rows when the table is queried, without reporting any error. This behavior is inconsistent with Greenplum Database 7, which reports a clear error in the same scenario.

The silent failure in Cloudberry can be misleading for users, as it's impossible to distinguish between a command that successfully executed with no output and a command that failed to execute. The expected behavior is to propagate the error from the OS, informing the user that the command was not found.

cbdb@robertmu-VirtualBox:~$ psql
psql (14.4, server 14.4)
Type "help" for help.

cbdb=# CREATE EXTERNAL WEB TEMP TABLE test_program_exist(content text) EXECUTE 'seq 1 5' ON MASTER FORMAT 'TEXT';
CREATE EXTERNAL TABLE
cbdb=# select * from test_program_exist;
 content
---------
 1
 2
 3
 4
 5
(5 rows)

cbdb=# CREATE EXTERNAL WEB TEMP TABLE test_program_not_exist(content text) EXECUTE '/xx/seq 1 5' ON MASTER FORMAT 'TEXT';
CREATE EXTERNAL TABLE
cbdb=# select * from test_program_not_exist;
 content
---------
(0 rows)

cbdb=# select version();
                                                                                          version
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 14.4 (Apache Cloudberry 2.0.0-incubating-rc3 build dev) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, 64-bit compiled on Aug 26 2025 10:53:40
(1 row)

cbdb=#
gpdb7@robertmu-VirtualBox:~$ psql
psql (12.12)
Type "help" for help.

gpdb7=# CREATE EXTERNAL WEB TEMP TABLE test_program_exist(content text) EXECUTE 'seq 1 5' ON MASTER FORMAT 'TEXT';
CREATE EXTERNAL TABLE
gpdb7=# select * from test_program_exist;
 content
---------
 1
 2
 3
 4
 5
(5 rows)

gpdb7=# CREATE EXTERNAL WEB TEMP TABLE test_program_not_exist(content text) EXECUTE '/xx/seq 1 5' ON MASTER FORMAT 'TEXT';
CREATE EXTERNAL TABLE
gpdb7=# select * from test_program_not_exist;
ERROR:  external table test_program_not_exist command ended with error. sh: /xx/seq: No such file or directory
DETAIL:  Command: execute:/xx/seq 1 5
gpdb7=#
gpdb7=# select version();
                                                                                                  version
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 12.12 (Greenplum Database 7.0.0-beta.0+482967c1b4 build dev) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0, 64-bit compiled on Nov  8 2024 23:43:47 Bhuvnesh C.
(1 row)

gpdb7=#

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions