提交 8bd1dfb0 编写于 作者: T Todd Sedano 提交者: Todd Sedano

Removes unused tinc tests

Authored-by: NTodd Sedano <tsedano@pivotal.io>
上级 78566ff8
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import time
from mpp.models import MPPTestCase
from mpp.lib.PSQL import PSQL
import pygresql.pg
from struct import *
import os
class CursorTests(MPPTestCase):
def test_mpp24119(self):
"""
@description postgres process crashed when running cursor with hold
@product_version gpdb: [4.2.8.1-4.2.99.99], [4.3.3.0-]
"""
start_time = time.time()
conn = pygresql.pg.connect()
conn.query("drop table if exists mpp24119")
conn.query("create table mpp24119(i int, j int)")
conn.query("insert into mpp24119 select i , i from generate_series(1, 10) i")
conn.query("begin; declare c cursor with hold for select * from mpp24119;")
conn.query("commit")
# The crash happens when exec_execute_message is triggered after a tx with cursor
# with hold is committed. Since there was no way to trigger this, we send a protocol
# message directly to the socket on which the connection is established
sockno = conn.fileno()
msg = pack('!sbi', 'c', 0, 0)
l = len(msg) + 4
res = os.write(sockno, pack('!c', 'E'))
res = os.write(sockno, pack('!i', l))
res = os.write(sockno, msg)
format_start_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(start_time))
output = PSQL.run_sql_command("SELECT logmessage FROM gp_toolkit.gp_log_system WHERE " + \
"logtime >= '%s' and logdatabase is null and logseverity = 'PANIC'" %(format_start_time), flags= '-q -t')
self.assertFalse(output.strip())
conn.close()
-- start_ignore
SET work_mem="256kB";
psql:/path/sql_file:1: WARNING: "work_mem": setting is deprecated, and may be removed in a future release.
SET
SET optimizer=off;
SET
-- end_ignore
create index idx_i_ao on ao_tab (i);
CREATE INDEX
select count(*) from ao_tab where i >= 0;
count
---------
4063232
(1 row)
drop index idx_i_ao;
DROP INDEX
-- Edge case: without lossy pages
truncate table ao_tab;
TRUNCATE TABLE
insert into ao_tab select generate_series(1, 65536);
INSERT 0 65536
create index idx_i_ao on ao_tab (i);
CREATE INDEX
select count(*) from ao_tab where i >= 0;
count
-------
65536
(1 row)
drop index idx_i_ao;
DROP INDEX
-- start_ignore
SET work_mem="256kB";
psql:/path/sql_file:1: WARNING: "work_mem": setting is deprecated, and may be removed in a future release.
SET
SET optimizer=off;
SET
-- end_ignore
create index idx_i_aoco on aoco_tab (i);
CREATE INDEX
select count(*) from aoco_tab where i >= 0;
count
---------
4063232
(1 row)
drop index idx_i_aoco;
DROP INDEX
-- Edge case: without lossy pages
truncate table aoco_tab;
TRUNCATE TABLE
insert into aoco_tab select generate_series(1, 65536);
INSERT 0 65536
create index idx_i_aoco on aoco_tab (i);
CREATE INDEX
select count(*) from aoco_tab where i >= 0;
count
-------
65536
(1 row)
drop index idx_i_aoco;
DROP INDEX
-- start_ignore
SET work_mem="256kB";
psql:/path/sql_file:1: WARNING: "work_mem": setting is deprecated, and may be removed in a future release.
SET
SET optimizer=off;
SET
-- end_ignore
create index idx_i_aocopart on aoco_part (i);
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_other"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_1"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_2"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_3"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_4"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_5"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_6"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_7"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_8"
CREATE INDEX
select count(*) from aoco_part where i >= 0;
count
---------
4063232
(1 row)
drop index idx_i_aocopart;
psql:/path/sql_file:1: WARNING: Only dropped the index "idx_i_aocopart"
HINT: To drop other indexes on child partitions, drop each one explicitly.
DROP INDEX
-- Edge case: without lossy pages
truncate table aoco_part;
TRUNCATE TABLE
insert into aoco_part select generate_series(1, 65536);
INSERT 0 65536
create index idx_i_aocopart on aoco_part (i);
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_other"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_1"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_2"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_3"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_4"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_5"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_6"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_7"
psql:/path/sql_file:1: NOTICE: building index for child partition "aoco_part_1_prt_p1_8"
CREATE INDEX
select count(*) from aoco_part where i >= 0;
count
-------
65536
(1 row)
drop index idx_i_aocopart;
psql:/path/sql_file:1: WARNING: Only dropped the index "idx_i_aocopart"
HINT: To drop other indexes on child partitions, drop each one explicitly.
DROP INDEX
-- start_ignore
SET work_mem="256kB";
psql:/path/sql_file:1: WARNING: "work_mem": setting is deprecated, and may be removed in a future release.
SET
SET optimizer=off;
SET
-- end_ignore
create index idx_i_heap on heap_tab (i);
CREATE INDEX
select count(*) from heap_tab where i >= 0;
count
---------
4063232
(1 row)
drop index idx_i_heap;
DROP INDEX
-- Edge case: without lossy pages
truncate table heap_tab;
TRUNCATE TABLE
insert into heap_tab select generate_series(1, 65536);
INSERT 0 65536
create index idx_i_heap on heap_tab (i);
CREATE INDEX
select count(*) from heap_tab where i >= 0;
count
-------
65536
(1 row)
drop index idx_i_heap;
DROP INDEX
-- start_ignore
SET work_mem="256kB";
psql:/path/sql_file:1: WARNING: "work_mem": setting is deprecated, and may be removed in a future release.
SET
SET optimizer=off;
SET
-- end_ignore
create index idx_i_heapaoco on heapaoco_part (i);
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p1"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p2"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p3"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p4"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p5"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p7"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_other"
CREATE INDEX
select count(*) from heapaoco_part where i >= 0;
count
---------
4063232
(1 row)
drop index idx_i_heapaoco;
psql:/path/sql_file:1: WARNING: Only dropped the index "idx_i_heapaoco"
HINT: To drop other indexes on child partitions, drop each one explicitly.
DROP INDEX
-- Edge case: without lossy pages
truncate table heapaoco_part;
TRUNCATE TABLE
insert into heapaoco_part select generate_series(1, 65536);
INSERT 0 65536
create index idx_i_heapaoco on heapaoco_part (i);
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p1"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p2"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p3"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p4"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p5"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_p7"
psql:/path/sql_file:1: NOTICE: building index for child partition "heapaoco_part_1_prt_other"
CREATE INDEX
select count(*) from heapaoco_part where i >= 0;
count
-------
65536
(1 row)
drop index idx_i_heapaoco;
psql:/path/sql_file:1: WARNING: Only dropped the index "idx_i_heapaoco"
HINT: To drop other indexes on child partitions, drop each one explicitly.
DROP INDEX
create index idx_i_ao on ao_tab (i);
select count(*) from ao_tab where i >= 0;
drop index idx_i_ao;
-- Edge case: without lossy pages
truncate table ao_tab;
insert into ao_tab select generate_series(1, 65536);
create index idx_i_ao on ao_tab (i);
select count(*) from ao_tab where i >= 0;
drop index idx_i_ao;
create index idx_i_aoco on aoco_tab (i);
select count(*) from aoco_tab where i >= 0;
drop index idx_i_aoco;
-- Edge case: without lossy pages
truncate table aoco_tab;
insert into aoco_tab select generate_series(1, 65536);
create index idx_i_aoco on aoco_tab (i);
select count(*) from aoco_tab where i >= 0;
drop index idx_i_aoco;
create index idx_i_aocopart on aoco_part (i);
select count(*) from aoco_part where i >= 0;
drop index idx_i_aocopart;
-- Edge case: without lossy pages
truncate table aoco_part;
insert into aoco_part select generate_series(1, 65536);
create index idx_i_aocopart on aoco_part (i);
select count(*) from aoco_part where i >= 0;
drop index idx_i_aocopart;
create index idx_i_heap on heap_tab (i);
select count(*) from heap_tab where i >= 0;
drop index idx_i_heap;
-- Edge case: without lossy pages
truncate table heap_tab;
insert into heap_tab select generate_series(1, 65536);
create index idx_i_heap on heap_tab (i);
select count(*) from heap_tab where i >= 0;
drop index idx_i_heap;
create index idx_i_heapaoco on heapaoco_part (i);
select count(*) from heapaoco_part where i >= 0;
drop index idx_i_heapaoco;
-- Edge case: without lossy pages
truncate table heapaoco_part;
insert into heapaoco_part select generate_series(1, 65536);
create index idx_i_heapaoco on heapaoco_part (i);
select count(*) from heapaoco_part where i >= 0;
drop index idx_i_heapaoco;
create language plpythonu;
drop table heap_tab;
drop table ao_tab;
drop table aoco_tab;
drop table heapaoco_part;
drop table aoco_part;
create or replace function insert_rows(work_mem int, table_name text) returns text as
$$
query = "select count(*) from gp_segment_configuration where preferred_role = 'p' and content != -1"
rv = plpy.execute(query)
num_seg = int(rv[0]['count'])
num_rows = (work_mem / 8216) * 32768 * num_seg
query = "insert into %s select generate_series(1, %d)" % (table_name, int(num_rows) * 2)
rv = plpy.execute(query)
return num_rows * 2
$$
language plpythonu;
create table heap_tab (i int);
create table ao_tab (i int) with (appendonly = true);
create table aoco_tab (i int) with (appendonly = true, orientation=column);
create table heapaoco_part (i int) partition by list(i)
(partition p1 values(1,3,5), partition p2 values(2,4,6) with (appendonly=true), partition p3 values(7,9,11), partition p4 values(8,10,12) with (appendonly=true),
partition p5 values(13,15,17) with (appendonly=true, orientation=column), partition p7 values(14,16,18), default partition other with (appendonly=true));
create table aoco_part (i int) with(appendonly=true) partition by range(i)
(partition p1 start (0) end (50000000) every (7000000), default partition other with (appendonly=true, orientation=column));
select insert_rows(256000, 'heap_tab');
insert into ao_tab select * from heap_tab;
insert into aoco_tab select * from heap_tab;
insert into heapaoco_part select * from heap_tab;
insert into aoco_part select * from heap_tab;
drop table heap_tab;
drop table ao_tab;
drop table aoco_tab;
drop table heapaoco_part;
drop table aoco_part;
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from mpp.models import SQLTestCase
class IndexTestCaseOptimizer(SQLTestCase):
"""
@product_version gpdb:[4.3.3-]
@optimizer_mode on
@gucs work_mem="256kB"; enable_seqscan=off; enable_indexscan=on; optimizer_enable_bitmapscan=on
@tags bfv
"""
sql_dir = 'sql/'
ans_dir = 'expected/'
out_dir = 'output_opt/'
class IndexTestCasePlanner(SQLTestCase):
"""
@product_version gpdb:[4.2.8.1-4.2.99.99], [4.3.3-]
@optimizer_mode off
@gucs work_mem="256kB"; enable_seqscan=off; enable_indexscan=on; optimizer_enable_bitmapscan=on
@tags bfv
"""
sql_dir = 'sql/'
ans_dir = 'expected/'
out_dir = 'output_plan/'
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for table constraints
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://localhost/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext add constraint mycon check (col1>0);
psql:/path/sql_file:1: ERROR: Cannot add a constraint to "pt_ext"; it has external partition(s)
alter table pt_ext add constraint mycon primary key(col1, col2);
psql:/path/sql_file:1: ERROR: Cannot add index or primary/unique key to "pt_ext"; it has external partition(s)
alter table pt_ext add constraint mycon unique(col1, col2);
psql:/path/sql_file:1: ERROR: Cannot add index or primary/unique key to "pt_ext"; it has external partition(s)
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for add/drop type
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext add column col5 int;
psql:/path/sql_file:1: ERROR: Cannot add a column to "pt_ext"; it has external partition(s)
alter table pt_ext drop column col4;
psql:/path/sql_file:1: ERROR: Cannot drop a column from "pt_ext"; it has external partition(s)
alter table pt_ext alter column col4 type int;
psql:/path/sql_file:1: ERROR: Cannot alter a column datatype of "pt_ext"; it has external partition(s)
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for alter default
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext alter column col2 set default 5;
ALTER TABLE
alter table pt_ext alter column col3 set default 'default value';
ALTER TABLE
insert into pt_ext(col1) values (11);
psql:/path/sql_file:1: ERROR: Insert into external partitions not supported. (seg0 mdw:35000 pid=27120)
alter table pt_ext alter column col2 set default 20;
ALTER TABLE
insert into pt_ext(col1) values (11);
INSERT 0 1
select * from pt_ext where col1=11;
col1 | col2 | col3 | col4
------+------+---------------+------
11 | 11 | test | t
11 | 20 | default value |
(2 rows)
alter table pt_ext alter column col2 drop default;
ALTER TABLE
alter table pt_ext alter column col3 drop default;
ALTER TABLE
insert into pt_ext(col1, col2) values (12, 12);
INSERT 0 1
select * from pt_ext where col1=12;
col1 | col2 | col3 | col4
------+------+------+------
12 | 12 | test | t
12 | 12 | |
(2 rows)
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for set not null
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://localhost/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext alter column col3 set not null;
psql:/path/sql_file:1: ERROR: Cannot alter a column null setting of "pt_ext"; it has external partition(s)
alter table pt_ext alter column col2 set not null;
psql:/path/sql_file:1: ERROR: Cannot alter a column null setting of "pt_ext"; it has external partition(s)
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for set statistics
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext alter column col3 set statistics 100;
ALTER TABLE
select attstattarget from pg_attribute where attname='col3' and attrelid='pt_ext_1_prt_part1'::regclass;
attstattarget
---------------
100
(1 row)
select attstattarget from pg_attribute where attname='col3' and attrelid='pt_ext'::regclass;
attstattarget
---------------
100
(1 row)
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for cluster
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
create index pt_ext_idx on pt_ext(col1,col2);
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part2"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part3"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part4"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part5"
psql:/path/sql_file:1: NOTICE: skip building index for external partition "pt_ext_1_prt_part1"
CREATE INDEX
--end_ignore
alter table pt_ext cluster on pt_ext_idx;
ALTER TABLE
alter table pt_ext set without cluster;
ALTER TABLE
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for drop partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://g182/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
create readable external table ret1(like pt_ext) location('file://g182/tmp/exttab_list') format 'csv';
psql:/path/sql_file:1: ERROR: relation "ret1" already exists
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
alter table pt_ext exchange partition part2 with table ret1 without validation;
ALTER TABLE
drop table ret;
DROP TABLE
drop table ret1;
DROP TABLE
--end_ignore
alter table pt_ext drop partition if exists for (5);
psql:/path/sql_file:1: NOTICE: dropped partition "part1" for relation "pt_ext"
ALTER TABLE
alter table pt_ext drop partition if exists part2;
ALTER TABLE
\d+ pt_ext
Table "public.pt_ext"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+----------+-------------
col1 | integer | | plain |
col2 | numeric | | main |
col3 | text | | extended |
col4 | boolean | | plain |
Child tables: pt_ext_1_prt_part3,
pt_ext_1_prt_part4,
pt_ext_1_prt_part5
Has OIDs: no
Distributed by: (col1)
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for exchange partition
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
rm: cannot remove `/tmp/exttab_list': No such file or directory
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
create table pt_ext_heap(like pt_ext);
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause, defaulting to distribution columns from LIKE table
CREATE TABLE
alter table pt_ext exchange partition part1 with table pt_ext_heap;
ALTER TABLE
\d pt_ext_1_prt_part1
Table "public.pt_ext_1_prt_part1"
Column | Type | Modifiers
--------+---------+-----------
col1 | integer |
col2 | numeric |
col3 | text |
col4 | boolean |
Check constraints:
"pt_ext_1_prt_part1_check" CHECK (col2 = 1::numeric OR col2 = 2::numeric OR col2 = 3::numeric OR col2 = 4::numeric OR col2 = 5::numeric OR col2 = 6::numeric OR col2 = 7::numeric OR col2 = 8::numeric OR col2 = 9::numeric OR col2 = 10::numeric)
Inherits: pt_ext
Distributed by: (col1)
drop external table pt_ext_heap;
DROP EXTERNAL TABLE
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for fillfactor
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext set (fillfactor=50);
ALTER TABLE
alter table pt_ext reset (fillfactor);
ALTER TABLE
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for rename column
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext rename column col2 to col2_new;
ALTER TABLE
\d pt_ext
Table "public.pt_ext"
Column | Type | Modifiers
----------+---------+-----------
col1 | integer |
col2_new | numeric |
col3 | text |
col4 | boolean |
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (col1)
alter table pt_ext_1_prt_part1 rename column col1 to col1_new;
psql:/path/sql_file:1: ERROR: cannot rename inherited column "col1"
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for rename partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext rename partition part1 to part1_rename;
ALTER TABLE
\d+ pt_ext
Table "public.pt_ext"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+----------+-------------
col1 | integer | | plain |
col2 | numeric | | main |
col3 | text | | extended |
col4 | boolean | | plain |
Child tables: pt_ext_1_prt_part1_rename,
pt_ext_1_prt_part2,
pt_ext_1_prt_part3,
pt_ext_1_prt_part4,
pt_ext_1_prt_part5
Has OIDs: no
Distributed by: (col1)
alter table pt_ext rename partition for (5) to part1_rename_rename;
psql:/path/sql_file:1: NOTICE: renamed partition "part1_rename" to "part1_rename_rename" for relation "pt_ext"
ALTER TABLE
\d+ pt_ext
Table "public.pt_ext"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+----------+-------------
col1 | integer | | plain |
col2 | numeric | | main |
col3 | text | | extended |
col4 | boolean | | plain |
Child tables: pt_ext_1_prt_part1_rename_rename,
pt_ext_1_prt_part2,
pt_ext_1_prt_part3,
pt_ext_1_prt_part4,
pt_ext_1_prt_part5
Has OIDs: no
Distributed by: (col1)
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for rename table
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext rename to pt_ext_new;
ALTER TABLE
alter table pt_ext_new_1_prt_part1 rename to pt_ext_new_1_prt_part1_new;
psql:/path/sql_file:1: ERROR: cannot rename partition "pt_ext_new_1_prt_part1" directly
HINT: Table "pt_ext_new_1_prt_part1" is a child partition of table "pt_ext_new". To rename it, use ALTER TABLE "pt_ext_new" RENAME PARTITION "part1"...
alter table pt_ext_new RENAME PARTITION part1 to part1_new;
ALTER TABLE
\d+ pt_ext_new
Table "public.pt_ext_new"
Column | Type | Modifiers | Storage | Description
--------+---------+-----------+----------+-------------
col1 | integer | | plain |
col2 | numeric | | main |
col3 | text | | extended |
col4 | boolean | | plain |
Child tables: pt_ext_new_1_prt_part1_new,
pt_ext_new_1_prt_part2,
pt_ext_new_1_prt_part3,
pt_ext_new_1_prt_part4,
pt_ext_new_1_prt_part5
Has OIDs: no
Distributed by: (col1)
alter table pt_ext_new rename to pt_ext;
ALTER TABLE
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
create user u_pt_ext;
psql:/path/sql_file:1: NOTICE: resource queue required -- using default resource queue "pg_default"
CREATE ROLE
alter table pt_ext owner to u_pt_ext;
ALTER TABLE
select pg_user.usename from pg_class join pg_user on pg_class.relowner=pg_user.usesysid where relname='pt_ext';
usename
----------
u_pt_ext
(1 row)
select pg_user.usename from pg_class join pg_user on pg_class.relowner=pg_user.usesysid where relname='pt_ext_1_prt_part1';
usename
----------
u_pt_ext
(1 row)
drop table pt_ext;
DROP TABLE
drop user u_pt_ext;
DROP ROLE
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for set distributed by
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext set distributed randomly;
psql:/path/sql_file:1: ERROR: Cannot set distributed on "pt_ext"; it has external partition(s)
alter table pt_ext set WITH (REORGANIZE=true) distributed by (col1);
psql:/path/sql_file:1: ERROR: Cannot set distributed on "pt_ext"; it has external partition(s)
alter table only pt_ext set WITH (REORGANIZE=true) distributed by (col1);
psql:/path/sql_file:1: ERROR: Cannot set distributed on "pt_ext"; it has external partition(s)
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
create schema pt_ext_schema;
CREATE SCHEMA
alter table pt_ext set schema pt_ext_schema;
ALTER TABLE
alter table pt_ext_1_prt_part1 set schema pt_ext_schema;
ALTER TABLE
\d pt_ext_schema.pt_ext;
Table "pt_ext_schema.pt_ext"
Column | Type | Modifiers
--------+---------+-----------
col1 | integer |
col2 | numeric |
col3 | text |
col4 | boolean |
Number of child tables: 5 (Use \d+ to list them.)
Distributed by: (col1)
alter table pt_ext_schema.pt_ext set schema public;
ALTER TABLE
alter table pt_ext_schema.pt_ext_1_prt_part1 set schema public;
ALTER TABLE
drop schema pt_ext_schema;
DROP SCHEMA
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for split partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext split partition part1 at(5) into (partition part11, partition part12);
psql:/path/sql_file:1: ERROR: Cannot split external partition (tablecmds.c:16417)
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for truncate partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
alter table pt_ext truncate partition for (5);
psql:/path/sql_file:1: ERROR: cannot truncate external partition
alter table pt_ext truncate partition part1;
psql:/path/sql_file:1: ERROR: cannot truncate external partition
select count(*) from pt_ext;
count
-------
50
(1 row)
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for analyze table
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
rm: cannot remove `/tmp/exttab_list': No such file or directory
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
analyze pt_ext_1_prt_part1;
ANALYZE
analyze verbose pt_ext_1_prt_part1;
psql:/path/analyze_replaced.sql:37: INFO: ANALYZE skipping external table pt_ext_1_prt_part1.
ANALYZE
analyze pt_ext;
ANALYZE
select reltuples from pg_class where relname='pt_ext_1_prt_part1';
reltuples
-----------
1e+06
(1 row)
select reltuples from pg_class where relname='pt_ext_1_prt_part2';
reltuples
-----------
10
(1 row)
select reltuples from pg_class where relname='pt_ext';
reltuples
-----------
40
(1 row)
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for analyze table
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
rm: cannot remove `/tmp/exttab_list': No such file or directory
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
analyze pt_ext_1_prt_part1;
ANALYZE
analyze pt_ext;
ANALYZE
select reltuples from pg_class where relname='pt_ext_1_prt_part1';
reltuples
-----------
0
(1 row)
select reltuples from pg_class where relname='pt_ext_1_prt_part2';
reltuples
-----------
10
(1 row)
select reltuples from pg_class where relname='pt_ext';
reltuples
-----------
40
(1 row)
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for analyze table
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
start ('1') end('100000') every ('20000')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,99999) i;
INSERT 0 99999
\! rm /tmp/exttab_range1
rm: cannot remove `/tmp/exttab_range1': No such file or directory
\! rm /tmp/exttab_range2
rm: cannot remove `/tmp/exttab_range2': No such file or directory
\! rm /tmp/exttab_range3
rm: cannot remove `/tmp/exttab_range3': No such file or directory
copy (select * from pt_ext where col2 >= 1 and col2 <= 20000) to '/tmp/exttab_range1' csv;
COPY 20000
copy (select * from pt_ext where col2 >= 40001 and col2 <= 60000) to '/tmp/exttab_range2' csv;
COPY 20000
copy (select * from pt_ext where col2 >= 80001 and col2 <= 99999) to '/tmp/exttab_range3' csv;
COPY 19999
create readable external table ret1(like pt_ext) location('file://mdw/tmp/exttab_range1') format 'csv';
CREATE EXTERNAL TABLE
create readable external table ret2(like pt_ext) location('file://mdw/tmp/exttab_range2') format 'csv';
CREATE EXTERNAL TABLE
create readable external table ret3(like pt_ext) location('file://mdw/tmp/exttab_range3') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition for(1) with table ret1 without validation;
ALTER TABLE
alter table pt_ext exchange partition for(40001) with table ret2 without validation;
ALTER TABLE
alter table pt_ext exchange partition for(80001) with table ret3 without validation;
ALTER TABLE
drop table ret1;
DROP TABLE
drop table ret2;
DROP TABLE
drop table ret3;
DROP TABLE
--end_ignore
analyze rootpartition pt_ext;
ANALYZE
select round(reltuples/10000.0) from pg_class where relname='pt_ext';
round
-------
4
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_range1
\! rm /tmp/exttab_range2
\! rm /tmp/exttab_range3
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external constraint
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
INSERT 0 49
copy(select col1,20,col3,col4 from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
COPY 9
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_range') format 'csv' LOG ERRORS SEGMENT REJECT LIMIT 20;
CREATE EXTERNAL TABLE
select count(*) from pt_ext;
count
-------
49
(1 row)
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
select count(*) from pt_ext;
count
-------
40
(1 row)
select count(*) from pt_ext_1_prt_part1;
count
-------
0
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_range
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description check copy's behavior regarding external partition.
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
copy pt_ext to stdout;
psql:/path/sql_file:1: ERROR: cannot copy from relation "pt_ext" which has external partition(s)
HINT: Try the COPY (SELECT ...) TO variant.
copy (select * from pt_ext order by col1) to stdout;
1 1 test t
2 2 test t
3 3 test t
4 4 test t
5 5 test t
6 6 test t
7 7 test t
8 8 test t
9 9 test t
10 10 test t
11 11 test t
12 12 test t
13 13 test t
14 14 test t
15 15 test t
16 16 test t
17 17 test t
18 18 test t
19 19 test t
20 20 test t
21 21 test t
22 22 test t
23 23 test t
24 24 test t
25 25 test t
26 26 test t
27 27 test t
28 28 test t
29 29 test t
30 30 test t
31 31 test t
32 32 test t
33 33 test t
34 34 test t
35 35 test t
36 36 test t
37 37 test t
38 38 test t
39 39 test t
40 40 test t
41 41 test t
42 42 test t
43 43 test t
44 44 test t
45 45 test t
46 46 test t
47 47 test t
48 48 test t
49 49 test t
50 50 test t
copy pt_ext to '/tmp/exttab_list' ignore external partitions;
psql:/path/sql_file:1: NOTICE: COPY ignores external partition(s)
COPY 40
copy pt_ext from '/tmp/exttab_list' csv;
psql:/path/sql_file:1: ERROR: missing data for column "col2"
CONTEXT: COPY pt_ext, line 1: "11 11 test t"
\! rm /tmp/exttab_list
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for default partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition dpart
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_dpart" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
--end_ignore
alter table pt_ext exchange partition dpart with table ret without validation;
psql:/path/sql_file:1: ERROR: cannot exchange DEFAULT partition with external table
--start_ignore
drop external table ret;
DROP EXTERNAL TABLE
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for delete
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
INSERT 0 49
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
COPY 9
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_range') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
delete from pt_ext where col2=15;
DELETE 1
delete from pt_ext where col2=5;
psql:/path/sql_file:1: ERROR: Delete from external partitions not supported. (seg0 mdw:35000 pid=28685)
DETAIL: External table pt_ext_1_prt_part1, line 5 of file://mdw/tmp/exttab_range: ""
delete from pt_ext where col2<15;
psql:/path/sql_file:1: ERROR: Delete from external partitions not supported. (seg0 mdw:35000 pid=28685)
DETAIL: External table pt_ext_1_prt_part1, line 1 of file://mdw/tmp/exttab_range: ""
delete from pt_ext where col1=5;
psql:/path/sql_file:1: ERROR: Delete from external partitions not supported. (seg0 mdw:35000 pid=28685)
DETAIL: External table pt_ext_1_prt_part1, line 5 of file://mdw/tmp/exttab_range: ""
delete from pt_ext where col1<15;
psql:/path/sql_file:1: ERROR: Delete from external partitions not supported. (seg0 mdw:35000 pid=28685)
DETAIL: External table pt_ext_1_prt_part1, line 1 of file://mdw/tmp/exttab_range: ""
select count(*) from pt_ext;
count
-------
48
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_range
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for distributed randomly
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
\! rm /tmp/exttab_list
rm: cannot remove `/tmp/exttab_list': No such file or directory
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
create table pt_ext_t(col1 int);
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE
explain select * from pt_ext join pt_ext_t on pt_ext.col1 = pt_ext_t.col1;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------
Gather Motion 1:1 (slice2; segments: 1) (cost=0.03..13533.05 rows=1002 width=73)
-> Hash Join (cost=0.03..13533.05 rows=1002 width=73)
Hash Cond: public.pt_ext.col1 = pt_ext_t.col1
-> Append (cost=0.00..11017.20 rows=1001320 width=69)
-> Seq Scan on pt_ext_1_prt_part2 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> Seq Scan on pt_ext_1_prt_part3 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> Seq Scan on pt_ext_1_prt_part4 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> Seq Scan on pt_ext_1_prt_part5 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> External Scan on pt_ext_1_prt_part1 pt_ext (cost=0.00..11000.00 rows=1000000 width=69)
-> Hash (cost=0.02..0.02 rows=1 width=4)
-> Broadcast Motion 1:1 (slice1; segments: 1) (cost=0.00..0.02 rows=1 width=4)
-> Seq Scan on pt_ext_t (cost=0.00..0.00 rows=1 width=4)
(12 rows)
alter table pt_ext drop partition part1;
ALTER TABLE
explain select * from pt_ext join pt_ext_t on pt_ext.col1 = pt_ext_t.col1;
QUERY PLAN
----------------------------------------------------------------------------------------------
Gather Motion 1:1 (slice1; segments: 1) (cost=0.01..20.62 rows=11 width=73)
-> Hash Join (cost=0.01..20.62 rows=11 width=73)
Hash Cond: public.pt_ext.col1 = pt_ext_t.col1
-> Append (cost=0.00..17.20 rows=1320 width=69)
-> Seq Scan on pt_ext_1_prt_part2 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> Seq Scan on pt_ext_1_prt_part3 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> Seq Scan on pt_ext_1_prt_part4 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> Seq Scan on pt_ext_1_prt_part5 pt_ext (cost=0.00..4.30 rows=330 width=69)
-> Hash (cost=0.00..0.00 rows=1 width=4)
-> Seq Scan on pt_ext_t (cost=0.00..0.00 rows=1 width=4)
(10 rows)
drop table pt_ext_t;
DROP TABLE
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for distributed randomly
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause. Creating a NULL policy entry.
SELECT 10
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://vraghavan.local/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
create table pt_ext_t(col1 int);
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
CREATE TABLE
explain select * from pt_ext join pt_ext_t on pt_ext.col1 = pt_ext_t.col1;
QUERY PLAN
----------------------------------------------------------------------------------------------------------
Gather Motion 2:1 (slice2; segments: 2) (cost=0.06..13535.57 rows=1002 width=73)
-> Hash Join (cost=0.06..13535.57 rows=501 width=73)
Hash Cond: public.pt_ext.col1 = pt_ext_t.col1
-> Append (cost=0.00..11017.20 rows=500660 width=69)
-> Seq Scan on pt_ext_1_prt_part2 pt_ext (cost=0.00..4.30 rows=165 width=69)
-> Seq Scan on pt_ext_1_prt_part3 pt_ext (cost=0.00..4.30 rows=165 width=69)
-> Seq Scan on pt_ext_1_prt_part4 pt_ext (cost=0.00..4.30 rows=165 width=69)
-> Seq Scan on pt_ext_1_prt_part5 pt_ext (cost=0.00..4.30 rows=165 width=69)
-> External Scan on pt_ext_1_prt_part1 pt_ext (cost=0.00..11000.00 rows=500000 width=69)
-> Hash (cost=0.03..0.03 rows=1 width=4)
-> Broadcast Motion 2:2 (slice1; segments: 2) (cost=0.00..0.03 rows=1 width=4)
-> Seq Scan on pt_ext_t (cost=0.00..0.00 rows=1 width=4)
Settings: optimizer=on
Optimizer status: legacy query optimizer
(14 rows)
alter table pt_ext drop partition part1;
ALTER TABLE
explain select * from pt_ext join pt_ext_t on pt_ext.col1 = pt_ext_t.col1;
QUERY PLAN
------------------------------------------------------------------------------------------------------------
Gather Motion 2:1 (slice1; segments: 2) (cost=0.00..862.00 rows=1 width=25)
-> Hash Join (cost=0.00..862.00 rows=1 width=25)
Hash Cond: pt_ext.col1 = pt_ext_t.col1
-> Sequence (cost=0.00..431.00 rows=1 width=21)
-> Partition Selector for pt_ext (dynamic scan id: 1) (cost=10.00..100.00 rows=50 width=4)
Partitions selected: 4 (out of 4)
-> Dynamic Table Scan on pt_ext (dynamic scan id: 1) (cost=0.00..431.00 rows=1 width=21)
-> Hash (cost=431.00..431.00 rows=1 width=4)
-> Table Scan on pt_ext_t (cost=0.00..431.00 rows=1 width=4)
Settings: optimizer=on
Optimizer status: PQO version 1.597
(11 rows)
drop table pt_ext_t;
DROP TABLE
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for error table
--start_ignore
\! rm /tmp/exttab_range
rm: cannot remove `/tmp/exttab_range': No such file or directory
\! rm /tmp/exttab_range1
rm: cannot remove `/tmp/exttab_range1': No such file or directory
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
INSERT 0 49
copy(select col1,col2,col3,'abc' from pt_ext where col2 < 10) to '/tmp/exttab_range' csv;
COPY 9
copy(select col1,col2,col3,'abc' from pt_ext where col2 < 20 and col2 > 10) to '/tmp/exttab_range1' csv;
COPY 9
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_range') format 'csv' LOG ERRORS SEGMENT REJECT LIMIT 20;
CREATE EXTERNAL TABLE
create readable external table ret1(like pt_ext) location('file://mdw/tmp/exttab_range1') format 'csv' LOG ERRORS SEGMENT REJECT LIMIT 20;
psql:/path/sql_file:1: NOTICE: Error table "pt_ext_errtable" does not exist. Auto generating an error table with the same name
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
alter table pt_ext exchange partition part2 with table ret1 without validation;
ALTER TABLE
drop table ret;
DROP TABLE
drop table ret1;
DROP TABLE
--end_ignore
select gp_truncate_error_log('pt_ext_1_prt_part1');
gp_truncate_error_log
-----------------------
t
(1 row)
select count(*) from pt_ext;
psql:/path/sql_file:1: NOTICE: Found 18 data formatting errors (18 or more input rows). Rejected related input data.
count
-------
30
(1 row)
select count(*) from gp_read_error_log('pt_ext_1_prt_part1');
count
-------
9
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
drop table pt_ext_errtable;
DROP TABLE
\! rm /tmp/exttab_range
\! rm /tmp/exttab_range1
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create index pt_ext_idx on pt_ext(col1);
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part1"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part2"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part3"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part4"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part5"
CREATE INDEX
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
copy tmp to '/tmp/exttab_list' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
SET enable_indexscan=on;
SET
SET enable_seqscan=off;
SET
SET enable_hashjoin=off;
SET
SET enable_nestloop=on;
SET
SET gp_segments_for_planner=2;
SET
SET enable_bitmapscan=off;
SET
--end_ignore
explain select * from pt_ext where col1=3;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------
Gather Motion 1:1 (slice1; segments: 1) (cost=0.00..14301.08 rows=1004 width=69)
-> Append (cost=0.00..14301.08 rows=1004 width=69)
-> Index Scan using pt_ext_idx_1_prt_part2 on pt_ext_1_prt_part2 pt_ext (cost=0.00..200.27 rows=1 width=69)
Index Cond: col1 = 3
-> Index Scan using pt_ext_idx_1_prt_part3 on pt_ext_1_prt_part3 pt_ext (cost=0.00..200.27 rows=1 width=69)
Index Cond: col1 = 3
-> Index Scan using pt_ext_idx_1_prt_part4 on pt_ext_1_prt_part4 pt_ext (cost=0.00..200.27 rows=1 width=69)
Index Cond: col1 = 3
-> Index Scan using pt_ext_idx_1_prt_part5 on pt_ext_1_prt_part5 pt_ext (cost=0.00..200.27 rows=1 width=69)
Index Cond: col1 = 3
-> External Scan on pt_ext_1_prt_part1 pt_ext (cost=0.00..13500.00 rows=1000 width=69)
Filter: col1 = 3
Settings: enable_bitmapscan=off; enable_hashjoin=off; enable_indexscan=on; enable_nestloop=on; enable_seqscan=off; gp_segments_for_planner=2
(13 rows)
create index pt_ext_idx2 on pt_ext(col2);
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part2"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part3"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part4"
psql:/path/sql_file:1: NOTICE: building index for child partition "pt_ext_1_prt_part5"
psql:/path/sql_file:1: NOTICE: skip building index for external partition "pt_ext_1_prt_part1"
CREATE INDEX
drop index pt_ext_idx2;
psql:/path/sql_file:1: WARNING: Only dropped the index "pt_ext_idx2"
HINT: To drop other indexes on child partitions, drop each one explicitly.
DROP INDEX
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_list
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for insert
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
INSERT 0 49
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
COPY 9
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_range') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
select count(*) from pt_ext;
count
-------
49
(1 row)
insert into pt_ext values(11,11,'test',true);
INSERT 0 1
insert into pt_ext values(1,1,'test',true);
psql:/path/sql_file:1: ERROR: Insert into external partitions not supported. (seg0 mdw:35000 pid=28899)
insert into pt_ext select i, i, 'test', true from generate_series(1,20) i;
psql:/path/sql_file:1: ERROR: Insert into external partitions not supported. (seg0 mdw:35000 pid=28899)
select count(*) from pt_ext;
count
-------
50
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_range
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-23 12:00:00
-- @modified 2015-07-23 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @check ORCA would fallback when query has external partition
--start_ignore
drop table if exists pt_ext_opt;
psql:/path/sql_file:1: NOTICE: table "pt_ext_opt" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext_opt
(
col1 int,
col2 decimal
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3),
partition part2 values(4,5,6)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_opt_1_prt_part1" for table "pt_ext_opt"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_opt_1_prt_part2" for table "pt_ext_opt"
CREATE TABLE
insert into pt_ext_opt select i,i from generate_series(1,6) i;
INSERT 0 6
create temp table tmp as select * from pt_ext_opt where col1 < 4 distributed by (col1);
SELECT 3
copy tmp to '/tmp/exttab_text';
COPY 3
create readable external table ret(like pt_ext_opt) location('file://mdw/tmp/exttab_text') format 'text';
CREATE EXTERNAL TABLE
alter table pt_ext_opt exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
set optimizer = on;
SET
select * from pt_ext_opt;
col1 | col2
------+------
4 | 4
5 | 5
6 | 6
1 | 1
2 | 2
3 | 3
(6 rows)
select * from (select * from pt_ext_opt) foo;
col1 | col2
------+------
4 | 4
5 | 5
6 | 6
1 | 1
2 | 2
3 | 3
(6 rows)
with foo as (select * from pt_ext_opt) select * from foo;
col1 | col2
------+------
4 | 4
5 | 5
6 | 6
1 | 1
2 | 2
3 | 3
(6 rows)
set optimizer = off;
SET
--start_ignore
drop table pt_ext_opt;
DROP TABLE
\! rm /tmp/exttab_text
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for range partition
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
INSERT 0 49
create temp table tmp as select * from pt_ext where col1 < 10;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 9
copy tmp to '/tmp/exttab_range' csv;
COPY 9
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_range') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
select count(*) from pt_ext;
count
-------
49
(1 row)
select count(*) from pt_ext_1_prt_part1;
count
-------
9
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_range
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for sub partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 int,
col4 bool
)
distributed by (col1)
partition by range(col2)
SUBPARTITION BY RANGE (col3)
SUBPARTITION TEMPLATE (
SUBPARTITION sub1 START (2001),
SUBPARTITION sub2 START (2002),
SUBPARTITION sub3 START (2006) END (2007) )
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1_2_prt_sub1" for table "pt_ext_1_prt_part1"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1_2_prt_sub2" for table "pt_ext_1_prt_part1"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1_2_prt_sub3" for table "pt_ext_1_prt_part1"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2_2_prt_sub1" for table "pt_ext_1_prt_part2"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2_2_prt_sub2" for table "pt_ext_1_prt_part2"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2_2_prt_sub3" for table "pt_ext_1_prt_part2"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3_2_prt_sub1" for table "pt_ext_1_prt_part3"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3_2_prt_sub2" for table "pt_ext_1_prt_part3"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3_2_prt_sub3" for table "pt_ext_1_prt_part3"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4_2_prt_sub1" for table "pt_ext_1_prt_part4"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4_2_prt_sub2" for table "pt_ext_1_prt_part4"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4_2_prt_sub3" for table "pt_ext_1_prt_part4"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5_2_prt_sub1" for table "pt_ext_1_prt_part5"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5_2_prt_sub2" for table "pt_ext_1_prt_part5"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5_2_prt_sub3" for table "pt_ext_1_prt_part5"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
--end_ignore
alter table pt_ext alter partition part1 exchange partition sub1 with table ret without validation;
psql:/path/sql_file:1: ERROR: cannot exchange sub partition with external table
drop external table ret;
DROP EXTERNAL TABLE
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for text format
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
copy tmp to '/tmp/exttab_list';
COPY 10
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'text';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
select * from pt_ext where col2 < 10;
col1 | col2 | col3 | col4
------+------+------+------
1 | 1 | test | t
2 | 2 | test | t
3 | 3 | test | t
4 | 4 | test | t
5 | 5 | test | t
6 | 6 | test | t
7 | 7 | test | t
8 | 8 | test | t
9 | 9 | test | t
(9 rows)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_list
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for truncate
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
INSERT 0 49
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
COPY 9
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_range') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
truncate pt_ext_1_prt_part1;
psql:/path/sql_file:1: ERROR: "pt_ext_1_prt_part1" is an external relation and can't be truncated
truncate pt_ext_1_prt_part2;
TRUNCATE TABLE
truncate pt_ext;
psql:/path/sql_file:1: ERROR: cannot truncate table having external partition: "pt_ext_1_prt_part1"
select count(*) from pt_ext;
count
-------
39
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_range
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for update
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
INSERT 0 49
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
COPY 9
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_range') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret without validation;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
update pt_ext set col3='updated' where col2=15;
UPDATE 1
update pt_ext set col3='updated' where col2=5;
psql:/path/sql_file:1: ERROR: Update external partitions not supported. (seg0 mdw:35000 pid=29295)
DETAIL: External table pt_ext_1_prt_part1, line 5 of file://mdw/tmp/exttab_range: ""
update pt_ext set col3='updated' where col2<15;
psql:/path/sql_file:1: ERROR: Update external partitions not supported. (seg0 mdw:35000 pid=29295)
DETAIL: External table pt_ext_1_prt_part1, line 1 of file://mdw/tmp/exttab_range: ""
update pt_ext set col3='updated' where col1=5;
psql:/path/sql_file:1: ERROR: Update external partitions not supported. (seg0 mdw:35000 pid=29295)
DETAIL: External table pt_ext_1_prt_part1, line 5 of file://mdw/tmp/exttab_range: ""
update pt_ext set col3='updated' where col1<5;
psql:/path/sql_file:1: ERROR: Update external partitions not supported. (seg0 mdw:35000 pid=29295)
DETAIL: External table pt_ext_1_prt_part1, line 1 of file://mdw/tmp/exttab_range: ""
select count(*) from pt_ext where col3='updated';
count
-------
1
(1 row)
--start_ignore
drop table pt_ext;
DROP TABLE
\! rm /tmp/exttab_range
--end_ignore
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external partition
--start_ignore
drop table if exists pt_ext;
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
INSERT 0 50
create temp table tmp as select * from pt_ext where col1 < 11;
psql:/path/sql_file:1: NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'col1' as the Greenplum Database data distribution key for this table.
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
SELECT 10
copy tmp to '/tmp/exttab_vacuum' csv;
COPY 10
create readable external table ret(like pt_ext) location('file://localhost/tmp/exttab_vacuum') format 'csv';
CREATE EXTERNAL TABLE
alter table pt_ext exchange partition part1 with table ret;
ALTER TABLE
drop table ret;
DROP TABLE
--end_ignore
select count(*) from pt_ext;
count
-------
50
(1 row)
vacuum pt_ext;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum full pt_ext;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum freeze pt_ext;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum analyze pt_ext;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum full analyze pt_ext;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum freeze analyze pt_ext;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum pt_ext_1_prt_part1;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum full pt_ext_1_prt_part1;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum freeze pt_ext_1_prt_part1;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum analyze pt_ext_1_prt_part1;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum full analyze pt_ext_1_prt_part1;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
vacuum freeze analyze pt_ext_1_prt_part1;
psql:/path/sql_file:1: WARNING: skipping "pt_ext_1_prt_part1" --- cannot vacuum indexes, views, external tables, or special system tables
VACUUM
-- start_ignore
-- end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for validation
--start_ignore
drop table if exists pt_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part1" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part2" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part3" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part4" for table "pt_ext"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_1_prt_part5" for table "pt_ext"
CREATE TABLE
create readable external table ret(like pt_ext) location('file://mdw/tmp/exttab_list') format 'csv';
CREATE EXTERNAL TABLE
--end_ignore
alter table pt_ext exchange partition part1 with table ret;
psql:/path/sql_file:1: ERROR: validation of external tables not supported
HINT: Use WITHOUT VALIDATION.
drop external table ret;
DROP EXTERNAL TABLE
--
-- @created 2015-07-23 12:00:00
-- @modified 2015-07-23 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @check whether external partition works on gphdfs
drop table if exists pt_ext_web;
psql:/path/sql_file:1: NOTICE: table "pt_ext_web" does not exist, skipping
DROP TABLE
CREATE TABLE pt_ext_web
(
col1 int,
col2 decimal
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3),
partition part2 values(4,5,6)
);
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_web_1_prt_part1" for table "pt_ext_web"
psql:/path/sql_file:1: NOTICE: CREATE TABLE will create partition "pt_ext_web_1_prt_part2" for table "pt_ext_web"
CREATE TABLE
insert into pt_ext_web select i,i from generate_series(1,6) i;
INSERT 0 6
create temp table tmp as select * from pt_ext_web where col1 < 4 distributed by (col1);
SELECT 3
copy tmp to '/tmp/pt_ext_web_out';
COPY 3
drop external table if exists pt_ext_web_ext;
psql:/path/sql_file:1: NOTICE: table "pt_ext_web_ext" does not exist, skipping
DROP EXTERNAL TABLE
create external web table pt_ext_web_ext(like pt_ext_web) execute 'cat /tmp/pt_ext_web_out' on master format 'text';
CREATE EXTERNAL TABLE
select * from pt_ext_web_ext;
col1 | col2
------+------
1 | 1
2 | 2
3 | 3
(3 rows)
alter table pt_ext_web exchange partition part1 with table pt_ext_web_ext without validation;
ALTER TABLE
drop table if exists pt_ext_web_ext;
DROP TABLE
select * from pt_ext_web;
col1 | col2
------+------
4 | 4
5 | 5
6 | 6
1 | 1
2 | 2
3 | 3
(6 rows)
drop table pt_ext_web;
DROP TABLE
\! rm '/tmp/pt_ext_web_out'
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external partition
alter table pt_ext set without oids;
ALTER TABLE
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for table constraints
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://localhost/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext add constraint mycon check (col1>0);
alter table pt_ext add constraint mycon primary key(col1, col2);
alter table pt_ext add constraint mycon unique(col1, col2);
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for add/drop type
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext add column col5 int;
alter table pt_ext drop column col4;
alter table pt_ext alter column col4 type int;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for alter default
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext alter column col2 set default 5;
alter table pt_ext alter column col3 set default 'default value';
insert into pt_ext(col1) values (11);
alter table pt_ext alter column col2 set default 20;
insert into pt_ext(col1) values (11);
select * from pt_ext where col1=11;
alter table pt_ext alter column col2 drop default;
alter table pt_ext alter column col3 drop default;
insert into pt_ext(col1, col2) values (12, 12);
select * from pt_ext where col1=12;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for set not null
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://localhost/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext alter column col3 set not null;
alter table pt_ext alter column col2 set not null;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for set statistics
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext alter column col3 set statistics 100;
select attstattarget from pg_attribute where attname='col3' and attrelid='pt_ext_1_prt_part1'::regclass;
select attstattarget from pg_attribute where attname='col3' and attrelid='pt_ext'::regclass;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for cluster
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
create index pt_ext_idx on pt_ext(col1,col2);
--end_ignore
alter table pt_ext cluster on pt_ext_idx;
alter table pt_ext set without cluster;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for drop partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
create readable external table ret1(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
alter table pt_ext exchange partition part2 with table ret1 without validation;
drop table ret;
drop table ret1;
--end_ignore
alter table pt_ext drop partition if exists for (5);
alter table pt_ext drop partition if exists part2;
\d+ pt_ext
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for exchange partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
create table pt_ext_heap(like pt_ext);
alter table pt_ext exchange partition part1 with table pt_ext_heap;
\d pt_ext_1_prt_part1
drop external table pt_ext_heap;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for fillfactor
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext set (fillfactor=50);
alter table pt_ext reset (fillfactor);
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for rename column
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext rename column col2 to col2_new;
\d pt_ext
alter table pt_ext_1_prt_part1 rename column col1 to col1_new;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for rename partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext rename partition part1 to part1_rename;
\d+ pt_ext
alter table pt_ext rename partition for (5) to part1_rename_rename;
\d+ pt_ext
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for rename table
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext rename to pt_ext_new;
alter table pt_ext_new_1_prt_part1 rename to pt_ext_new_1_prt_part1_new;
alter table pt_ext_new RENAME PARTITION part1 to part1_new;
\d+ pt_ext_new
alter table pt_ext_new rename to pt_ext;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
create user u_pt_ext;
alter table pt_ext owner to u_pt_ext;
select pg_user.usename from pg_class join pg_user on pg_class.relowner=pg_user.usesysid where relname='pt_ext';
select pg_user.usename from pg_class join pg_user on pg_class.relowner=pg_user.usesysid where relname='pt_ext_1_prt_part1';
drop table pt_ext;
drop user u_pt_ext;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for set distributed by
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext set distributed randomly;
alter table pt_ext set WITH (REORGANIZE=true) distributed by (col1);
alter table only pt_ext set WITH (REORGANIZE=true) distributed by (col1);
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
create schema pt_ext_schema;
alter table pt_ext set schema pt_ext_schema;
alter table pt_ext_1_prt_part1 set schema pt_ext_schema;
\d pt_ext_schema.pt_ext;
alter table pt_ext_schema.pt_ext set schema public;
alter table pt_ext_schema.pt_ext_1_prt_part1 set schema public;
drop schema pt_ext_schema;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for split partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext split partition part1 at(5) into (partition part11, partition part12);
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for truncate partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext truncate partition for (5);
alter table pt_ext truncate partition part1;
select count(*) from pt_ext;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for analyze table
-- @product_version gpdb: [-4.3.98]
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
analyze pt_ext_1_prt_part1;
analyze verbose pt_ext_1_prt_part1;
analyze pt_ext;
select reltuples from pg_class where relname='pt_ext_1_prt_part1';
select reltuples from pg_class where relname='pt_ext_1_prt_part2';
select reltuples from pg_class where relname='pt_ext';
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for analyze table
-- @product_version gpdb: [4.3.99-]
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
analyze pt_ext_1_prt_part1;
analyze pt_ext;
-- This returns 0 because of this issue: https://github.com/greenplum-db/gpdb/issues/395
-- It should be 1e+06.
select reltuples from pg_class where relname='pt_ext_1_prt_part1';
select reltuples from pg_class where relname='pt_ext_1_prt_part2';
select reltuples from pg_class where relname='pt_ext';
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for analyze table
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
start ('1') end('100000') every ('20000')
);
insert into pt_ext select i,i,'test',true from generate_series(1,99999) i;
\! rm /tmp/exttab_range1
\! rm /tmp/exttab_range2
\! rm /tmp/exttab_range3
copy (select * from pt_ext where col2 >= 1 and col2 <= 20000) to '/tmp/exttab_range1' csv;
copy (select * from pt_ext where col2 >= 40001 and col2 <= 60000) to '/tmp/exttab_range2' csv;
copy (select * from pt_ext where col2 >= 80001 and col2 <= 99999) to '/tmp/exttab_range3' csv;
create readable external table ret1(like pt_ext) location('file://HOST/tmp/exttab_range1') format 'csv';
create readable external table ret2(like pt_ext) location('file://HOST/tmp/exttab_range2') format 'csv';
create readable external table ret3(like pt_ext) location('file://HOST/tmp/exttab_range3') format 'csv';
alter table pt_ext exchange partition for(1) with table ret1 without validation;
alter table pt_ext exchange partition for(40001) with table ret2 without validation;
alter table pt_ext exchange partition for(80001) with table ret3 without validation;
drop table ret1;
drop table ret2;
drop table ret3;
--end_ignore
analyze rootpartition pt_ext;
select round(reltuples/10000.0) from pg_class where relname='pt_ext';
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_range1
\! rm /tmp/exttab_range2
\! rm /tmp/exttab_range3
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for external constraint
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
copy(select col1,20,col3,col4 from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_range') format 'csv' LOG ERRORS SEGMENT REJECT LIMIT 20;
select count(*) from pt_ext;
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
select count(*) from pt_ext;
select count(*) from pt_ext_1_prt_part1;
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_range
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description check copy's behavior regarding external partition.
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
copy pt_ext to stdout;
copy (select * from pt_ext order by col1) to stdout;
copy pt_ext to '/tmp/exttab_list' ignore external partitions;
copy pt_ext from '/tmp/exttab_list' csv;
\! rm /tmp/exttab_list
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for default partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50),
default partition dpart
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
--end_ignore
alter table pt_ext exchange partition dpart with table ret without validation;
--start_ignore
drop external table ret;
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for delete
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_range') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
delete from pt_ext where col2=15;
delete from pt_ext where col2=5;
delete from pt_ext where col2<15;
delete from pt_ext where col1=5;
delete from pt_ext where col1<15;
select count(*) from pt_ext;
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_range
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for distributed randomly
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
create table pt_ext_t(col1 int);
explain select * from pt_ext join pt_ext_t on pt_ext.col1 = pt_ext_t.col1;
alter table pt_ext drop partition part1;
explain select * from pt_ext join pt_ext_t on pt_ext.col1 = pt_ext_t.col1;
drop table pt_ext_t;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for error table
--start_ignore
\! rm /tmp/exttab_range
\! rm /tmp/exttab_range1
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
copy(select col1,col2,col3,'abc' from pt_ext where col2 < 10) to '/tmp/exttab_range' csv;
copy(select col1,col2,col3,'abc' from pt_ext where col2 < 20 and col2 > 10) to '/tmp/exttab_range1' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_range') format 'csv' LOG ERRORS SEGMENT REJECT LIMIT 20;
create readable external table ret1(like pt_ext) location('file://HOST/tmp/exttab_range1') format 'csv' LOG ERRORS SEGMENT REJECT LIMIT 20;
alter table pt_ext exchange partition part1 with table ret without validation;
alter table pt_ext exchange partition part2 with table ret1 without validation;
drop table ret;
drop table ret1;
--end_ignore
select gp_truncate_error_log('pt_ext_1_prt_part1');
select count(*) from pt_ext;
select count(*) from gp_read_error_log('pt_ext_1_prt_part1');
--start_ignore
drop table pt_ext;
drop table pt_ext_errtable;
\! rm /tmp/exttab_range
\! rm /tmp/exttab_range1
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for index
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create index pt_ext_idx on pt_ext(col1);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
SET enable_indexscan=on;
SET enable_seqscan=off;
SET enable_hashjoin=off;
SET enable_nestloop=on;
SET gp_segments_for_planner=2;
SET enable_bitmapscan=off;
--end_ignore
explain select * from pt_ext where col1=3;
create index pt_ext_idx2 on pt_ext(col2);
drop index pt_ext_idx2;
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_list
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for insert
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_range') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
select count(*) from pt_ext;
insert into pt_ext values(11,11,'test',true);
insert into pt_ext values(1,1,'test',true);
insert into pt_ext select i, i, 'test', true from generate_series(1,20) i;
select count(*) from pt_ext;
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_range
--end_ignore
--
-- @created 2015-07-23 12:00:00
-- @modified 2015-07-23 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @check ORCA would fallback when query has external partition
--start_ignore
drop table if exists pt_ext_opt;
CREATE TABLE pt_ext_opt
(
col1 int,
col2 decimal
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3),
partition part2 values(4,5,6)
);
insert into pt_ext_opt select i,i from generate_series(1,6) i;
create temp table tmp as select * from pt_ext_opt where col1 < 4 distributed by (col1);
copy tmp to '/tmp/exttab_text';
create readable external table ret(like pt_ext_opt) location('file://HOST/tmp/exttab_text') format 'text';
alter table pt_ext_opt exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
set optimizer = on;
select * from pt_ext_opt;
select * from (select * from pt_ext_opt) foo;
with foo as (select * from pt_ext_opt) select * from foo;
set optimizer = off;
--start_ignore
drop table pt_ext_opt;
\! rm /tmp/exttab_text
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for range partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
create temp table tmp as select * from pt_ext where col1 < 10;
copy tmp to '/tmp/exttab_range' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_range') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
select count(*) from pt_ext;
select count(*) from pt_ext_1_prt_part1;
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_range
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for sub partition
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 int,
col4 bool
)
distributed by (col1)
partition by range(col2)
SUBPARTITION BY RANGE (col3)
SUBPARTITION TEMPLATE (
SUBPARTITION sub1 START (2001),
SUBPARTITION sub2 START (2002),
SUBPARTITION sub3 START (2006) END (2007) )
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
--end_ignore
alter table pt_ext alter partition part1 exchange partition sub1 with table ret without validation;
drop external table ret;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for text format
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
copy tmp to '/tmp/exttab_list';
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'text';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
select * from pt_ext where col2 < 10;
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_list
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for truncate
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_range') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
truncate pt_ext_1_prt_part1;
truncate pt_ext_1_prt_part2;
truncate pt_ext;
select count(*) from pt_ext;
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_range
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for update
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by range(col2)
(
partition part1 start ('1') end ('10'),
partition part2 start ('10') end ('20'),
partition part3 start ('20') end ('30'),
partition part4 start ('30') end ('40'),
partition part5 start ('40') end ('50')
);
insert into pt_ext select i,i,'test',true from generate_series(1,49) i;
copy(select * from pt_ext where col1 < 10) to '/tmp/exttab_range' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_range') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
update pt_ext set col3='updated' where col2=15;
update pt_ext set col3='updated' where col2=5;
update pt_ext set col3='updated' where col2<15;
update pt_ext set col3='updated' where col1=5;
update pt_ext set col3='updated' where col1<5;
select count(*) from pt_ext where col3='updated';
--start_ignore
drop table pt_ext;
\! rm /tmp/exttab_range
--end_ignore
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for vacuum
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
insert into pt_ext select i,i,'test',true from generate_series(1,50) i;
create temp table tmp as select * from pt_ext where col1 < 11;
\! rm /tmp/exttab_list
copy tmp to '/tmp/exttab_list' csv;
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
select count(*) from pt_ext;
vacuum pt_ext;
vacuum full pt_ext;
vacuum freeze pt_ext;
vacuum analyze pt_ext;
vacuum full analyze pt_ext;
vacuum freeze analyze pt_ext;
vacuum pt_ext_1_prt_part1;
vacuum full pt_ext_1_prt_part1;
vacuum freeze pt_ext_1_prt_part1;
vacuum analyze pt_ext_1_prt_part1;
vacuum full analyze pt_ext_1_prt_part1;
vacuum freeze analyze pt_ext_1_prt_part1;
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for validation
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
--end_ignore
alter table pt_ext exchange partition part1 with table ret;
drop external table ret;
--
-- @created 2015-07-23 12:00:00
-- @modified 2015-07-23 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @check whether external partition works on gphdfs
drop table if exists pt_ext_web;
CREATE TABLE pt_ext_web
(
col1 int,
col2 decimal
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3),
partition part2 values(4,5,6)
);
insert into pt_ext_web select i,i from generate_series(1,6) i;
create temp table tmp as select * from pt_ext_web where col1 < 4 distributed by (col1);
copy tmp to '/tmp/pt_ext_web_out';
drop external table if exists pt_ext_web_ext;
create external web table pt_ext_web_ext(like pt_ext_web) execute 'cat /tmp/pt_ext_web_out' on master format 'text';
select * from pt_ext_web_ext;
alter table pt_ext_web exchange partition part1 with table pt_ext_web_ext without validation;
drop table if exists pt_ext_web_ext;
select * from pt_ext_web;
drop table pt_ext_web;
\! rm '/tmp/pt_ext_web_out'
--
-- @created 2015-07-11 12:00:00
-- @modified 2015-07-11 12:00:00
-- @tags external_partition
-- @gpdiff true
-- @description Tests for set withoid
--start_ignore
drop table if exists pt_ext;
CREATE TABLE pt_ext
(
col1 int,
col2 decimal,
col3 text,
col4 bool
)
distributed by (col1)
partition by list(col2)
(
partition part1 values(1,2,3,4,5,6,7,8,9,10),
partition part2 values(11,12,13,14,15,16,17,18,19,20),
partition part3 values(21,22,23,24,25,26,27,28,29,30),
partition part4 values(31,32,33,34,35,36,37,38,39,40),
partition part5 values(41,42,43,44,45,46,47,48,49,50)
);
create readable external table ret(like pt_ext) location('file://HOST/tmp/exttab_list') format 'csv';
alter table pt_ext exchange partition part1 with table ret without validation;
drop table ret;
--end_ignore
alter table pt_ext set without oids;
--start_ignore
drop table pt_ext;
--end_ignore
"""
Copyright (c) 2004-Present Pivotal Software, Inc.
This program and the accompanying materials are made available under
the terms of the under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
from mpp.lib.config import GPDBConfig
from mpp.models import SQLTestCase
class ExternalPartitionTests(SQLTestCase):
'''
@product_version gpdb: [4.3.6.0-9.9.99.99]
'''
sql_dir = 'sql/'
ans_dir = 'expected/'
out_dir = 'output/'
def get_substitutions(self):
"""
Returns sustitution variables.
"""
config = GPDBConfig()
host, _ = config.get_hostandport_of_segment(0)
variables = {
'HOST': host,
}
return variables
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册