This is an automated email from the ASF dual-hosted git repository. avamingli pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/cloudberry.git
commit 24bc2526c6d12c350e844db6886e4784bf8fb5d5 Author: Jingwen Yang <[email protected]> AuthorDate: Wed Mar 27 15:49:13 2024 +0800 Add a test case about special location URI for CREATE FOREIGN TABLE syntax (#17252) Add a test case that external table location URI contains special character '|' for CREATE FOREIGN TABLE syntax. --- "gpcontrib/gp_exttable_fdw/data/spe\\cial1|" | 2 ++ "gpcontrib/gp_exttable_fdw/data/|special2\\" | 1 + .../gp_exttable_fdw/input/gp_exttable_fdw.source | 10 ++++++++ .../gp_exttable_fdw/output/gp_exttable_fdw.source | 27 ++++++++++++++++++++++ 4 files changed, 40 insertions(+) diff --git "a/gpcontrib/gp_exttable_fdw/data/spe\\cial1|" "b/gpcontrib/gp_exttable_fdw/data/spe\\cial1|" new file mode 100644 index 0000000000..3bf58f2519 --- /dev/null +++ "b/gpcontrib/gp_exttable_fdw/data/spe\\cial1|" @@ -0,0 +1,2 @@ +1,1 +2,2 diff --git "a/gpcontrib/gp_exttable_fdw/data/|special2\\" "b/gpcontrib/gp_exttable_fdw/data/|special2\\" new file mode 100644 index 0000000000..3176ff229c --- /dev/null +++ "b/gpcontrib/gp_exttable_fdw/data/|special2\\" @@ -0,0 +1 @@ +3,3 diff --git a/gpcontrib/gp_exttable_fdw/input/gp_exttable_fdw.source b/gpcontrib/gp_exttable_fdw/input/gp_exttable_fdw.source index a3704704a7..d2ffe47e4f 100644 --- a/gpcontrib/gp_exttable_fdw/input/gp_exttable_fdw.source +++ b/gpcontrib/gp_exttable_fdw/input/gp_exttable_fdw.source @@ -67,3 +67,13 @@ OPTIONS (format_type 'c', delimiter ',', SELECT * FROM tableless_ext_fdw; +-- OK, location URI contains special characters '|' and '\' +-- Single character '|' is used as delimiter for multiple location URIs. +-- When using CREATE FOREIGN TABLE syntax, '|' and '\' need to be escaped as '|' --> '\|' and '|' --> '\\'. +CREATE FOREIGN TABLE ext_special_uri(a int, b int) +SERVER gp_exttable_server +OPTIONS (format 'csv', delimiter ',', + location_uris 'file://@hostname@@abs_srcdir@/data/spe\\cial1\||file://@hostname@@abs_srcdir@/data/\|special2\\'); +SELECT urilocation FROM pg_exttable WHERE reloid = 'public.ext_special_uri'::regclass; +SELECT ftoptions FROM pg_foreign_table WHERE ftrelid='public.ext_special_uri'::regclass; +SELECT * FROM ext_special_uri ORDER BY a; diff --git a/gpcontrib/gp_exttable_fdw/output/gp_exttable_fdw.source b/gpcontrib/gp_exttable_fdw/output/gp_exttable_fdw.source index a5952d197e..4efc7ef29e 100644 --- a/gpcontrib/gp_exttable_fdw/output/gp_exttable_fdw.source +++ b/gpcontrib/gp_exttable_fdw/output/gp_exttable_fdw.source @@ -71,3 +71,30 @@ SELECT * FROM tableless_ext_fdw; 3 | 32 (3 rows) +-- OK, location URI contains special characters '|' and '\' +-- Single character '|' is used as delimiter for multiple location URIs. +-- When using CREATE FOREIGN TABLE syntax, '|' and '\' need to be escaped as '|' --> '\|' and '|' --> '\\'. +CREATE FOREIGN TABLE ext_special_uri(a int, b int) +SERVER gp_exttable_server +OPTIONS (format 'csv', delimiter ',', + location_uris 'file://@hostname@@abs_srcdir@/data/spe\\cial1\||file://@hostname@@abs_srcdir@/data/\|special2\\'); +SELECT urilocation FROM pg_exttable WHERE reloid = 'public.ext_special_uri'::regclass; + urilocation +----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {"file://@hostname@@abs_srcdir@/data/spe\\cial1|","file://@hostname@@abs_srcdir@/data/|special2\\"} +(1 row) + +SELECT ftoptions FROM pg_foreign_table WHERE ftrelid='public.ext_special_uri'::regclass; + ftoptions +-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + {format=csv,"delimiter=,","location_uris=file://@hostname@@abs_srcdir@/data/spe\\\\cial1\\||file://@hostname@@abs_srcdir@/data/\\|special2\\\\"} +(1 row) + +SELECT * FROM ext_special_uri ORDER BY a; + a | b +---+--- + 1 | 1 + 2 | 2 + 3 | 3 +(3 rows) + --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
