mirror of https://github.com/citusdata/citus.git
Merge remote-tracking branch 'origin/remove_source_files' into pg15_support_tmp_onder
commit
cab41c4fc9
|
@ -17,12 +17,6 @@ trim_trailing_whitespace = true
|
|||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
# Don't change test/regress/output directory, this needs to be a separate rule
|
||||
# for some reason
|
||||
[/src/test/regress/output/**]
|
||||
insert_final_newline = unset
|
||||
trim_trailing_whitespace = unset
|
||||
|
||||
[*.{sql,sh,py}]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
|
|
@ -16,7 +16,6 @@ README.* conflict-marker-size=32
|
|||
|
||||
# Test output files that contain extra whitespace
|
||||
*.out -whitespace
|
||||
src/test/regress/output/*.source -whitespace
|
||||
|
||||
# These files are maintained or generated elsewhere. We take them as is.
|
||||
configure -whitespace
|
||||
|
|
|
@ -363,11 +363,8 @@ This was deemed to be error prone and not worth the effort.
|
|||
|
||||
This script checks and fixes issues with `.gitignore` rules:
|
||||
|
||||
1. Makes sure git ignores the `.sql` files and expected output files that are generated
|
||||
from `.source` template files. If you created or deleted a `.source` file in a commit,
|
||||
git ignore rules should be updated to reflect this change.
|
||||
|
||||
2. Makes sure we do not commit any generated files that should be ignored. If there is an
|
||||
1. Makes sure we do not commit any generated files that should be ignored. If there is an
|
||||
ignored file in the git tree, the user is expected to review the files that are removed
|
||||
from the git tree and commit them.
|
||||
|
||||
|
|
|
@ -7,13 +7,12 @@ source ci/ci_helpers.sh
|
|||
|
||||
cd src/test/regress
|
||||
|
||||
# 1. Find all *.sql *.spec and *.source files in the sql, spec and input
|
||||
# directories
|
||||
# 1. Find all *.sql and *.spec files in the sql, and spec directories
|
||||
# 2. Strip the extension and the directory
|
||||
# 3. Ignore names that end with .include, those files are meant to be in an C
|
||||
# preprocessor #include statement. They should not be in schedules.
|
||||
test_names=$(
|
||||
find sql spec input -iname "*.sql" -o -iname "*.spec" -o -iname "*.source" |
|
||||
find sql spec -iname "*.sql" -o -iname "*.spec" |
|
||||
sed -E 's#^\w+/([^/]+)\.[^.]+$#\1#g' |
|
||||
grep -v '.include$'
|
||||
)
|
||||
|
|
|
@ -1,24 +1,8 @@
|
|||
#! /bin/bash
|
||||
# shellcheck disable=SC2012
|
||||
|
||||
set -euo pipefail
|
||||
# shellcheck disable=SC1091
|
||||
source ci/ci_helpers.sh
|
||||
|
||||
# We list all the .source files in alphabetical order, and do a substitution
|
||||
# before writing the resulting file names that are created by those templates in
|
||||
# relevant .gitignore files
|
||||
#
|
||||
# 1. Capture the file name without the .source extension
|
||||
# 2. Add the desired extension at the end
|
||||
# 3. Add a / character at the beginning of each line to conform to .gitignore file format
|
||||
#
|
||||
# e.g. multi_copy.source -> /multi_copy.sql
|
||||
ls -1 src/test/regress/input | sed -E "s#(.*)\.source#/\1.sql#" > src/test/regress/sql/.gitignore
|
||||
|
||||
# e.g. multi_copy.source -> /multi_copy.out
|
||||
ls -1 src/test/regress/output | sed -E "s#(.*)\.source#/\1.out#" > src/test/regress/expected/.gitignore
|
||||
|
||||
# Remove all the ignored files from git tree, and error out
|
||||
# find all ignored files in git tree, and use quotation marks to prevent word splitting on filenames with spaces in them
|
||||
ignored_lines_in_git_tree=$(git ls-files --ignored --exclude-standard | sed 's/.*/"&"/')
|
||||
|
|
|
@ -16,7 +16,6 @@ README.* conflict-marker-size=32
|
|||
|
||||
# Test output files that contain extra whitespace
|
||||
*.out -whitespace
|
||||
src/test/regress/output/*.source -whitespace
|
||||
|
||||
# These files are maintained or generated elsewhere. We take them as is.
|
||||
configure -whitespace
|
||||
|
|
|
@ -38,7 +38,6 @@ create_function_2.sql
|
|||
largeobject.sql
|
||||
misc.sql
|
||||
security_label.sql
|
||||
tablespace.sql
|
||||
constraints.out
|
||||
copy.out
|
||||
create_function_0.out
|
||||
|
@ -48,4 +47,3 @@ largeobject.out
|
|||
largeobject_1.out
|
||||
misc.out
|
||||
security_label.out
|
||||
tablespace.out
|
||||
|
|
|
@ -24,7 +24,7 @@ export PGISOLATIONTIMEOUT = 20
|
|||
## Citus regression support
|
||||
##
|
||||
MULTI_INSTALLDIR=$(CURDIR)/tmp_check/install
|
||||
pg_regress_multi_check = $(PERL) $(citus_abs_srcdir)/pg_regress_multi.pl --pgxsdir="$(pgxsdir)" --bindir="$(bindir)" --libdir="$(libdir)" --majorversion="$(MAJORVERSION)" --postgres-builddir="$(postgres_abs_builddir)" --postgres-srcdir="$(postgres_abs_srcdir)"
|
||||
pg_regress_multi_check = $(PERL) $(citus_abs_srcdir)/pg_regress_multi.pl --pgxsdir="$(pgxsdir)" --bindir="$(bindir)" --libdir="$(libdir)" --majorversion="$(MAJORVERSION)" --postgres-builddir="$(postgres_abs_builddir)" --postgres-srcdir="$(postgres_abs_srcdir)" --citus_abs_srcdir="$(citus_abs_srcdir)"
|
||||
MULTI_REGRESS_OPTS = --inputdir=$(citus_abs_srcdir) $(pg_regress_locale_flags) --launcher="$(citus_abs_srcdir)/log_test_times"
|
||||
|
||||
pg_upgrade_check = $(citus_abs_srcdir)/citus_tests/upgrade/pg_upgrade_test.py
|
||||
|
@ -34,11 +34,6 @@ arbitrary_config_check = $(citus_abs_srcdir)/citus_tests/arbitrary_configs/citus
|
|||
template_isolation_files = $(shell find $(citus_abs_srcdir)/spec/ -name '*.spec')
|
||||
generated_isolation_files = $(patsubst $(citus_abs_srcdir)/spec/%,$(citus_abs_srcdir)/build/specs/%,$(template_isolation_files))
|
||||
|
||||
# Test input and expected files. These are created by pg_regress itself, so we
|
||||
# don't have a rule to create them. We do need rules to clean them however.
|
||||
input_files := $(patsubst $(citus_abs_srcdir)/input/%.source,sql/%.sql, $(wildcard $(citus_abs_srcdir)/input/*.source))
|
||||
output_files := $(patsubst $(citus_abs_srcdir)/output/%.source,expected/%.out, $(wildcard $(citus_abs_srcdir)/output/*.source))
|
||||
|
||||
# have make check actually run all tests, but keep check-full as an
|
||||
# intermediate, for muscle memory backward compatibility.
|
||||
check: check-full check-enterprise-full
|
||||
|
@ -268,7 +263,7 @@ clean-upgrade-artifacts:
|
|||
rm -rf $(citus_abs_srcdir)/tmp_citus_tarballs/ $(citus_abs_srcdir)/tmp_citus_upgrade/ /tmp/citus_copy/
|
||||
|
||||
clean distclean maintainer-clean:
|
||||
rm -f $(output_files) $(input_files)
|
||||
rm -rf input/ output/
|
||||
rm -rf tmp_check/
|
||||
rm -rf tmp_citus_test/
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/columnar_copyto.out
|
||||
/columnar_data_types.out
|
||||
/columnar_load.out
|
||||
/hyperscale_tutorial.out
|
||||
/multi_agg_distinct.out
|
||||
/multi_agg_type_conversion.out
|
||||
/multi_alter_table_statements.out
|
||||
/multi_behavioral_analytics_create_table.out
|
||||
/multi_behavioral_analytics_create_table_superuser.out
|
||||
/multi_complex_count_distinct.out
|
||||
/multi_copy.out
|
||||
/multi_load_data.out
|
||||
/multi_load_data_superuser.out
|
||||
/multi_load_more_data.out
|
||||
/multi_multiuser_load_data.out
|
||||
/multi_mx_copy_data.out
|
||||
/multi_outer_join.out
|
||||
/multi_outer_join_reference.out
|
||||
/tablespace.out
|
|
@ -5,7 +5,8 @@ CREATE TABLE test_contestant(handle TEXT, birthdate DATE, rating INT,
|
|||
percentile FLOAT, country CHAR(3), achievements TEXT[])
|
||||
USING columnar;
|
||||
-- load table data from file
|
||||
COPY test_contestant FROM '@abs_srcdir@/data/contestants.1.csv' WITH CSV;
|
||||
\set contestants_1_csv_file :abs_srcdir '/data/contestants.1.csv'
|
||||
COPY test_contestant FROM :'contestants_1_csv_file' WITH CSV;
|
||||
-- export using COPY table TO ...
|
||||
COPY test_contestant TO STDOUT;
|
||||
a 01-10-1990 2090 97.1 XA {a}
|
|
@ -8,10 +8,11 @@ SET intervalstyle TO 'POSTGRES_VERBOSE';
|
|||
-- Test array types
|
||||
CREATE TABLE test_array_types (int_array int[], bigint_array bigint[],
|
||||
text_array text[]) USING columnar;
|
||||
COPY test_array_types FROM '@abs_srcdir@/data/array_types.csv' WITH CSV;
|
||||
\set array_types_csv_file :abs_srcdir '/data/array_types.csv'
|
||||
COPY test_array_types FROM :'array_types_csv_file' WITH CSV;
|
||||
SELECT * FROM test_array_types;
|
||||
int_array | bigint_array | text_array
|
||||
--------------------------+--------------------------------------------+------------
|
||||
---------------------------------------------------------------------
|
||||
{1,2,3} | {1,2,3} | {a,b,c}
|
||||
{} | {} | {}
|
||||
{-2147483648,2147483647} | {-9223372036854775808,9223372036854775807} | {""}
|
||||
|
@ -21,10 +22,11 @@ SELECT * FROM test_array_types;
|
|||
CREATE TABLE test_datetime_types (timestamp timestamp,
|
||||
timestamp_with_timezone timestamp with time zone, date date, time time,
|
||||
interval interval) USING columnar;
|
||||
COPY test_datetime_types FROM '@abs_srcdir@/data/datetime_types.csv' WITH CSV;
|
||||
\set datetime_types_csv_file :abs_srcdir '/data/datetime_types.csv'
|
||||
COPY test_datetime_types FROM :'datetime_types_csv_file' WITH CSV;
|
||||
SELECT * FROM test_datetime_types;
|
||||
timestamp | timestamp_with_timezone | date | time | interval
|
||||
---------------------+-------------------------+------------+----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
2000-01-02 04:05:06 | 1999-01-08 12:05:06+00 | 2000-01-02 | 04:05:06 | @ 4 hours
|
||||
1970-01-01 00:00:00 | infinity | -infinity | 00:00:00 | @ 0
|
||||
(2 rows)
|
||||
|
@ -34,11 +36,12 @@ CREATE TYPE enum_type AS ENUM ('a', 'b', 'c');
|
|||
CREATE TYPE composite_type AS (a int, b text);
|
||||
CREATE TABLE test_enum_and_composite_types (enum enum_type,
|
||||
composite composite_type) USING columnar;
|
||||
\set enum_and_composite_types_csv_file :abs_srcdir '/data/enum_and_composite_types.csv'
|
||||
COPY test_enum_and_composite_types FROM
|
||||
'@abs_srcdir@/data/enum_and_composite_types.csv' WITH CSV;
|
||||
:'enum_and_composite_types_csv_file' WITH CSV;
|
||||
SELECT * FROM test_enum_and_composite_types;
|
||||
enum | composite
|
||||
------+-----------
|
||||
---------------------------------------------------------------------
|
||||
a | (2,b)
|
||||
b | (3,c)
|
||||
(2 rows)
|
||||
|
@ -46,10 +49,11 @@ SELECT * FROM test_enum_and_composite_types;
|
|||
-- Test range types
|
||||
CREATE TABLE test_range_types (int4range int4range, int8range int8range,
|
||||
numrange numrange, tsrange tsrange) USING columnar;
|
||||
COPY test_range_types FROM '@abs_srcdir@/data/range_types.csv' WITH CSV;
|
||||
\set range_types_csv_file :abs_srcdir '/data/range_types.csv'
|
||||
COPY test_range_types FROM :'range_types_csv_file' WITH CSV;
|
||||
SELECT * FROM test_range_types;
|
||||
int4range | int8range | numrange | tsrange
|
||||
-----------+-----------+----------+-----------------------------------------------
|
||||
---------------------------------------------------------------------
|
||||
[1,3) | [1,3) | [1,3) | ["2000-01-02 00:30:00","2010-02-03 12:30:00")
|
||||
empty | [1,) | (,) | empty
|
||||
(2 rows)
|
||||
|
@ -57,10 +61,11 @@ SELECT * FROM test_range_types;
|
|||
-- Test other types
|
||||
CREATE TABLE test_other_types (bool boolean, bytea bytea, money money,
|
||||
inet inet, bitstring bit varying(5), uuid uuid, json json) USING columnar;
|
||||
COPY test_other_types FROM '@abs_srcdir@/data/other_types.csv' WITH CSV;
|
||||
\set other_types_csv_file :abs_srcdir '/data/other_types.csv'
|
||||
COPY test_other_types FROM :'other_types_csv_file' WITH CSV;
|
||||
SELECT * FROM test_other_types;
|
||||
bool | bytea | money | inet | bitstring | uuid | json
|
||||
------+------------+-------+-------------+-----------+--------------------------------------+------------------
|
||||
---------------------------------------------------------------------
|
||||
f | \xdeadbeef | $1.00 | 192.168.1.2 | 10101 | a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 | {"key": "value"}
|
||||
t | \xcdb0 | $1.50 | 127.0.0.1 | | a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11 | []
|
||||
(2 rows)
|
||||
|
@ -68,10 +73,11 @@ SELECT * FROM test_other_types;
|
|||
-- Test null values
|
||||
CREATE TABLE test_null_values (a int, b int[], c composite_type)
|
||||
USING columnar;
|
||||
COPY test_null_values FROM '@abs_srcdir@/data/null_values.csv' WITH CSV;
|
||||
\set null_values_csv_file :abs_srcdir '/data/null_values.csv'
|
||||
COPY test_null_values FROM :'null_values_csv_file' WITH CSV;
|
||||
SELECT * FROM test_null_values;
|
||||
a | b | c
|
||||
---+--------+-----
|
||||
---------------------------------------------------------------------
|
||||
| {NULL} | (,)
|
||||
| |
|
||||
(2 rows)
|
|
@ -2,7 +2,8 @@
|
|||
-- Test loading data into columnar tables.
|
||||
--
|
||||
-- COPY with incorrect delimiter
|
||||
COPY contestant FROM '@abs_srcdir@/data/contestants.1.csv'
|
||||
\set contestants_1_csv_file :abs_srcdir '/data/contestants.1.csv'
|
||||
COPY contestant FROM :'contestants_1_csv_file'
|
||||
WITH DELIMITER '|'; -- ERROR
|
||||
ERROR: missing data for column "birthdate"
|
||||
CONTEXT: COPY contestant, line 1: "a,1990-01-10,2090,97.1,XA ,{a}"
|
||||
|
@ -11,9 +12,10 @@ COPY contestant FROM PROGRAM 'invalid_program' WITH CSV; -- ERROR
|
|||
ERROR: program "invalid_program" failed
|
||||
DETAIL: command not found
|
||||
-- COPY into uncompressed table from file
|
||||
COPY contestant FROM '@abs_srcdir@/data/contestants.1.csv' WITH CSV;
|
||||
COPY contestant FROM :'contestants_1_csv_file' WITH CSV;
|
||||
-- COPY into uncompressed table from program
|
||||
COPY contestant FROM PROGRAM 'cat @abs_srcdir@/data/contestants.2.csv' WITH CSV;
|
||||
\set cat_contestants_2_csv_file 'cat ' :abs_srcdir '/data/contestants.2.csv'
|
||||
COPY contestant FROM PROGRAM :'cat_contestants_2_csv_file' WITH CSV;
|
||||
select
|
||||
version_major, version_minor, reserved_stripe_id, reserved_row_number
|
||||
from columnar_test_helpers.columnar_storage_info('contestant');
|
||||
|
@ -23,9 +25,9 @@ select
|
|||
(1 row)
|
||||
|
||||
-- COPY into compressed table
|
||||
COPY contestant_compressed FROM '@abs_srcdir@/data/contestants.1.csv' WITH CSV;
|
||||
COPY contestant_compressed FROM :'contestants_1_csv_file' WITH CSV;
|
||||
-- COPY into uncompressed table from program
|
||||
COPY contestant_compressed FROM PROGRAM 'cat @abs_srcdir@/data/contestants.2.csv'
|
||||
COPY contestant_compressed FROM PROGRAM :'cat_contestants_2_csv_file'
|
||||
WITH CSV;
|
||||
select
|
||||
version_major, version_minor, reserved_stripe_id, reserved_row_number
|
||||
|
@ -42,7 +44,7 @@ COPY famous_constants (value, name, id) FROM STDIN WITH CSV;
|
|||
COPY famous_constants (name, value) FROM STDIN WITH CSV;
|
||||
SELECT * FROM famous_constants ORDER BY id, name;
|
||||
id | name | value
|
||||
----+----------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 | pi | 3.141
|
||||
2 | e | 2.718
|
||||
3 | gamma | 0.577
|
|
@ -63,52 +63,57 @@ CREATE TABLE impressions (
|
|||
begin;
|
||||
SELECT create_distributed_table('companies', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_distributed_table('campaigns', 'company_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
rollback;
|
||||
SELECT create_distributed_table('companies', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_distributed_table('campaigns', 'company_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_distributed_table('ads', 'company_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_distributed_table('clicks', 'company_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT create_distributed_table('impressions', 'company_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\copy companies from '@abs_srcdir@/data/companies.csv' with csv
|
||||
\copy campaigns from '@abs_srcdir@/data/campaigns.csv' with csv
|
||||
\copy ads from '@abs_srcdir@/data/ads.csv' with csv
|
||||
\copy clicks from '@abs_srcdir@/data/clicks.csv' with csv
|
||||
\copy impressions from '@abs_srcdir@/data/impressions.csv' with csv
|
||||
\set companies_csv_file :abs_srcdir '/data/companies.csv'
|
||||
\set campaigns_csv_file :abs_srcdir '/data/campaigns.csv'
|
||||
\set ads_csv_file :abs_srcdir '/data/ads.csv'
|
||||
\set clicks_csv_file :abs_srcdir '/data/clicks.csv'
|
||||
\set impressions_csv_file :abs_srcdir '/data/impressions.csv'
|
||||
COPY companies from :'companies_csv_file' with csv;
|
||||
COPY campaigns from :'campaigns_csv_file' with csv;
|
||||
COPY ads from :'ads_csv_file' with csv;
|
||||
COPY clicks from :'clicks_csv_file' with csv;
|
||||
COPY impressions from :'impressions_csv_file' with csv;
|
||||
SELECT a.campaign_id,
|
||||
RANK() OVER (
|
||||
PARTITION BY a.campaign_id
|
||||
|
@ -123,7 +128,7 @@ GROUP BY a.campaign_id, a.id
|
|||
ORDER BY a.campaign_id, n_impressions desc, a.id
|
||||
LIMIT 10;
|
||||
campaign_id | rank | n_impressions | id
|
||||
-------------+------+---------------+-----
|
||||
---------------------------------------------------------------------
|
||||
34 | 1 | 68 | 264
|
||||
34 | 2 | 56 | 266
|
||||
34 | 3 | 41 | 267
|
||||
|
@ -198,18 +203,18 @@ CREATE TABLE impressions (
|
|||
FOREIGN KEY (company_id, ad_id)
|
||||
REFERENCES ads (company_id, id)
|
||||
);
|
||||
\copy companies from '@abs_srcdir@/data/companies.csv' with csv
|
||||
\copy campaigns from '@abs_srcdir@/data/campaigns.csv' with csv
|
||||
\copy ads from '@abs_srcdir@/data/ads.csv' with csv
|
||||
\copy clicks from '@abs_srcdir@/data/clicks.csv' with csv
|
||||
\copy impressions from '@abs_srcdir@/data/impressions.csv' with csv
|
||||
COPY companies from :'companies_csv_file' with csv;
|
||||
COPY campaigns from :'campaigns_csv_file' with csv;
|
||||
COPY ads from :'ads_csv_file' with csv;
|
||||
COPY clicks from :'clicks_csv_file' with csv;
|
||||
COPY impressions from :'impressions_csv_file' with csv;
|
||||
SELECT create_distributed_table('companies', 'id');
|
||||
NOTICE: Copying data from local table...
|
||||
NOTICE: copying the data has completed
|
||||
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.companies$$)
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -219,7 +224,7 @@ NOTICE: copying the data has completed
|
|||
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.campaigns$$)
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -229,7 +234,7 @@ NOTICE: copying the data has completed
|
|||
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.ads$$)
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -239,7 +244,7 @@ NOTICE: copying the data has completed
|
|||
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.clicks$$)
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -249,7 +254,7 @@ NOTICE: copying the data has completed
|
|||
DETAIL: The local data in the table is no longer visible, but is still on disk.
|
||||
HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.impressions$$)
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -267,7 +272,7 @@ GROUP BY a.campaign_id, a.id
|
|||
ORDER BY a.campaign_id, n_impressions desc, a.id
|
||||
LIMIT 10;
|
||||
campaign_id | rank | n_impressions | id
|
||||
-------------+------+---------------+-----
|
||||
---------------------------------------------------------------------
|
||||
59 | 1 | 70 | 477
|
||||
59 | 2 | 69 | 479
|
||||
59 | 3 | 63 | 475
|
|
@ -22,7 +22,7 @@ CREATE TABLE lineitem_range (
|
|||
l_comment varchar(44) not null );
|
||||
SELECT create_distributed_table('lineitem_range', 'l_orderkey', 'range');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -34,18 +34,20 @@ SELECT master_create_empty_shard('lineitem_range') AS new_shard_id
|
|||
\gset
|
||||
UPDATE pg_dist_shard SET shardminvalue = 8997, shardmaxvalue = 14947
|
||||
WHERE shardid = :new_shard_id;
|
||||
\copy lineitem_range FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_range FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_range FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_range FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
-- Run aggregate(distinct) on partition column for range partitioned table
|
||||
SELECT count(distinct l_orderkey) FROM lineitem_range;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
2985
|
||||
(1 row)
|
||||
|
||||
SELECT avg(distinct l_orderkey) FROM lineitem_range;
|
||||
avg
|
||||
-----------------------
|
||||
---------------------------------------------------------------------
|
||||
7463.9474036850921273
|
||||
(1 row)
|
||||
|
||||
|
@ -57,7 +59,7 @@ SELECT p_partkey, count(distinct l_orderkey) FROM lineitem_range, part
|
|||
GROUP BY p_partkey
|
||||
ORDER BY p_partkey LIMIT 10;
|
||||
p_partkey | count
|
||||
-----------+-------
|
||||
---------------------------------------------------------------------
|
||||
18 | 1
|
||||
79 | 1
|
||||
91 | 1
|
||||
|
@ -73,38 +75,38 @@ SELECT p_partkey, count(distinct l_orderkey) FROM lineitem_range, part
|
|||
-- Check that we support more complex expressions.
|
||||
SELECT count(distinct (l_orderkey)) FROM lineitem_range;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
2985
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_orderkey + 1)) FROM lineitem_range;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
2985
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_orderkey % 5)) FROM lineitem_range;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
-- count(distinct) on non-partition column is allowed
|
||||
SELECT count(distinct l_partkey) FROM lineitem_range;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
11661
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_partkey + 1)) FROM lineitem_range;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
11661
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_partkey % 5)) FROM lineitem_range;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
|
@ -112,13 +114,13 @@ SELECT count(distinct (l_partkey % 5)) FROM lineitem_range;
|
|||
-- sharded table.
|
||||
SELECT count(distinct p_mfgr) FROM part;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
SELECT p_mfgr, count(distinct p_partkey) FROM part GROUP BY p_mfgr ORDER BY p_mfgr;
|
||||
p_mfgr | count
|
||||
---------------------------+-------
|
||||
---------------------------------------------------------------------
|
||||
Manufacturer#1 | 193
|
||||
Manufacturer#2 | 190
|
||||
Manufacturer#3 | 228
|
||||
|
@ -130,7 +132,7 @@ SELECT p_mfgr, count(distinct p_partkey) FROM part GROUP BY p_mfgr ORDER BY p_mf
|
|||
-- both on partition column, and non-partition column.
|
||||
SELECT count(distinct o_orderkey), count(distinct o_custkey) FROM orders;
|
||||
count | count
|
||||
-------+-------
|
||||
---------------------------------------------------------------------
|
||||
2985 | 923
|
||||
(1 row)
|
||||
|
||||
|
@ -155,60 +157,60 @@ CREATE TABLE lineitem_hash (
|
|||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table('lineitem_hash', 'l_orderkey', 'hash');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
COPY lineitem_hash FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_hash FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
-- aggregate(distinct) on partition column is allowed
|
||||
SELECT count(distinct l_orderkey) FROM lineitem_hash;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
2985
|
||||
(1 row)
|
||||
|
||||
SELECT avg(distinct l_orderkey) FROM lineitem_hash;
|
||||
avg
|
||||
-----------------------
|
||||
---------------------------------------------------------------------
|
||||
7463.9474036850921273
|
||||
(1 row)
|
||||
|
||||
-- Check that we support more complex expressions.
|
||||
SELECT count(distinct (l_orderkey)) FROM lineitem_hash;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
2985
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_orderkey + 1)) FROM lineitem_hash;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
2985
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_orderkey % 5)) FROM lineitem_hash;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
-- count(distinct) on non-partition column is allowed
|
||||
SELECT count(distinct l_partkey) FROM lineitem_hash;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
11661
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_partkey + 1)) FROM lineitem_hash;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
11661
|
||||
(1 row)
|
||||
|
||||
SELECT count(distinct (l_partkey % 5)) FROM lineitem_hash;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
5
|
||||
(1 row)
|
||||
|
||||
|
@ -218,7 +220,7 @@ SELECT l_orderkey, count(distinct l_partkey) INTO range_results FROM lineitem_ra
|
|||
-- they should return the same results
|
||||
SELECT * FROM hash_results h, range_results r WHERE h.l_orderkey = r.l_orderkey AND h.count != r.count;
|
||||
l_orderkey | count | l_orderkey | count
|
||||
------------+-------+------------+-------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- count(distinct) is allowed if we group by non-partition column
|
||||
|
@ -227,7 +229,7 @@ SELECT l_partkey, count(distinct l_orderkey) INTO range_results_np FROM lineitem
|
|||
-- they should return the same results
|
||||
SELECT * FROM hash_results_np h, range_results_np r WHERE h.l_partkey = r.l_partkey AND h.count != r.count;
|
||||
l_partkey | count | l_partkey | count
|
||||
-----------+-------+-----------+-------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- other agg(distinct) are not allowed on non-partition columns even they are grouped
|
|
@ -4,25 +4,25 @@
|
|||
-- Test aggregate type conversions using sums of integers and division operator
|
||||
SELECT sum(l_suppkey) FROM lineitem;
|
||||
sum
|
||||
----------
|
||||
---------------------------------------------------------------------
|
||||
60617976
|
||||
(1 row)
|
||||
|
||||
SELECT sum(l_suppkey) / 2 FROM lineitem;
|
||||
?column?
|
||||
----------
|
||||
---------------------------------------------------------------------
|
||||
30308988
|
||||
(1 row)
|
||||
|
||||
SELECT sum(l_suppkey) / 2::numeric FROM lineitem;
|
||||
?column?
|
||||
-----------------------
|
||||
---------------------------------------------------------------------
|
||||
30308988.000000000000
|
||||
(1 row)
|
||||
|
||||
SELECT sum(l_suppkey)::int8 / 2 FROM lineitem;
|
||||
?column?
|
||||
----------
|
||||
---------------------------------------------------------------------
|
||||
30308988
|
||||
(1 row)
|
||||
|
||||
|
@ -35,18 +35,19 @@ CREATE TABLE aggregate_type (
|
|||
interval_value interval not null);
|
||||
SELECT create_distributed_table('aggregate_type', 'float_value', 'append');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT master_create_empty_shard('aggregate_type') AS shardid \gset
|
||||
copy aggregate_type FROM '@abs_srcdir@/data/agg_type.data' with (append_to_shard :shardid);
|
||||
\set agg_type_data_file :abs_srcdir '/data/agg_type.data'
|
||||
copy aggregate_type FROM :'agg_type_data_file' with (append_to_shard :shardid);
|
||||
-- Test conversions using aggregates on floats and division
|
||||
SELECT min(float_value), max(float_value),
|
||||
sum(float_value), count(float_value), avg(float_value)
|
||||
FROM aggregate_type;
|
||||
min | max | sum | count | avg
|
||||
-----+-----+------+-------+-------
|
||||
---------------------------------------------------------------------
|
||||
1 | 4.5 | 10.5 | 4 | 2.625
|
||||
(1 row)
|
||||
|
||||
|
@ -54,7 +55,7 @@ SELECT min(float_value) / 2, max(float_value) / 2,
|
|||
sum(float_value) / 2, count(float_value) / 2, avg(float_value) / 2
|
||||
FROM aggregate_type;
|
||||
?column? | ?column? | ?column? | ?column? | ?column?
|
||||
----------+----------+----------+----------+----------
|
||||
---------------------------------------------------------------------
|
||||
0.5 | 2.25 | 5.25 | 2 | 1.3125
|
||||
(1 row)
|
||||
|
||||
|
@ -63,7 +64,7 @@ SELECT min(double_value), max(double_value),
|
|||
sum(double_value), count(double_value), avg(double_value)
|
||||
FROM aggregate_type;
|
||||
min | max | sum | count | avg
|
||||
-------+---------+----------+-------+-----------
|
||||
---------------------------------------------------------------------
|
||||
2.343 | 6.34343 | 15.79703 | 4 | 3.9492575
|
||||
(1 row)
|
||||
|
||||
|
@ -71,7 +72,7 @@ SELECT min(double_value) * 2, max(double_value) * 2,
|
|||
sum(double_value) * 2, count(double_value) * 2, avg(double_value) * 2
|
||||
FROM aggregate_type;
|
||||
?column? | ?column? | ?column? | ?column? | ?column?
|
||||
----------+----------+----------+----------+----------
|
||||
---------------------------------------------------------------------
|
||||
4.686 | 12.68686 | 31.59406 | 8 | 7.898515
|
||||
(1 row)
|
||||
|
||||
|
@ -82,7 +83,7 @@ SELECT min(interval_value), max(interval_value),
|
|||
sum(interval_value), count(interval_value), avg(interval_value)
|
||||
FROM aggregate_type;
|
||||
min | max | sum | count | avg
|
||||
-------------+------------+-------------+-------+-------------
|
||||
---------------------------------------------------------------------
|
||||
00:00:23.44 | 00:38:52.9 | 01:23:33.64 | 4 | 00:20:53.41
|
||||
(1 row)
|
||||
|
||||
|
@ -90,7 +91,7 @@ SELECT min(interval_value) / 2, max(interval_value) / 2,
|
|||
sum(interval_value) / 2, count(interval_value) / 2, avg(interval_value) / 2
|
||||
FROM aggregate_type;
|
||||
?column? | ?column? | ?column? | ?column? | ?column?
|
||||
-------------+-------------+-------------+----------+--------------
|
||||
---------------------------------------------------------------------
|
||||
00:00:11.72 | 00:19:26.45 | 00:41:46.82 | 2 | 00:10:26.705
|
||||
(1 row)
|
||||
|
|
@ -26,23 +26,24 @@ CREATE TABLE lineitem_alter (
|
|||
WITH ( fillfactor = 80 );
|
||||
SELECT create_distributed_table('lineitem_alter', 'l_orderkey', 'append');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
SELECT master_create_empty_shard('lineitem_alter') AS shardid \gset
|
||||
copy lineitem_alter FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
copy lineitem_alter FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
-- verify that the storage options made it to the table definitions
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'lineitem_alter';
|
||||
relname | reloptions
|
||||
----------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter | {fillfactor=80}
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'lineitem_alter%' ORDER BY relname;
|
||||
relname | reloptions
|
||||
-----------------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter_220000 | {fillfactor=80}
|
||||
(1 row)
|
||||
|
||||
|
@ -61,7 +62,7 @@ FROM
|
|||
JOIN pg_attribute ON (pc.oid = pg_attribute.attrelid)
|
||||
ORDER BY attnum;
|
||||
attname | atttypid
|
||||
-----------------+-------------------
|
||||
---------------------------------------------------------------------
|
||||
tableoid | oid
|
||||
cmax | cid
|
||||
xmax | xid
|
||||
|
@ -94,7 +95,7 @@ ORDER BY attnum;
|
|||
\c - - - :master_port
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -120,32 +121,32 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineite
|
|||
|
||||
SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column;
|
||||
float_column | count
|
||||
--------------+-------
|
||||
---------------------------------------------------------------------
|
||||
| 6000
|
||||
(1 row)
|
||||
|
||||
SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
|
||||
int_column1 | count
|
||||
-------------+-------
|
||||
---------------------------------------------------------------------
|
||||
1 | 6000
|
||||
(1 row)
|
||||
|
||||
-- Verify that SET|DROP DEFAULT works
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN float_column SET DEFAULT 1;
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN int_column1 DROP DEFAULT;
|
||||
-- \copy to verify that default values take effect
|
||||
-- COPY to verify that default values take effect
|
||||
SELECT master_create_empty_shard('lineitem_alter') as shardid \gset
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column;
|
||||
float_column | count
|
||||
--------------+-------
|
||||
---------------------------------------------------------------------
|
||||
| 6000
|
||||
1 | 6000
|
||||
(2 rows)
|
||||
|
||||
SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
|
||||
int_column1 | count
|
||||
-------------+-------
|
||||
---------------------------------------------------------------------
|
||||
| 6000
|
||||
1 | 6000
|
||||
(2 rows)
|
||||
|
@ -154,7 +155,7 @@ SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
|
|||
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET NOT NULL;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+--------------------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -180,19 +181,19 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineite
|
|||
|
||||
-- Drop default so that NULLs will be inserted for this column
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP DEFAULT;
|
||||
-- \copy should fail because it will try to insert NULLs for a NOT NULL column
|
||||
-- COPY should fail because it will try to insert NULLs for a NOT NULL column
|
||||
-- Note, this operation will create a table on the workers but it won't be in the metadata
|
||||
BEGIN;
|
||||
SELECT master_create_empty_shard('lineitem_alter') as shardid \gset
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
ERROR: null value in column "int_column2" of relation "lineitem_alter_220002" violates not-null constraint
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
ERROR: null value in column "int_column2" violates not-null constraint
|
||||
DETAIL: Failing row contains (1, 155190, 7706, 1, 17.00, 21168.23, 0.04, 0.02, N, O, 1996-03-13, 1996-02-12, 1996-03-22, DELIVER IN PERSON , TRUCK , egular courts above the, 1, null, null, null, null).
|
||||
END;
|
||||
-- Verify that DROP NOT NULL works
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP NOT NULL;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -216,19 +217,19 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineite
|
|||
null_column | integer |
|
||||
(21 rows)
|
||||
|
||||
-- \copy should succeed now
|
||||
-- COPY should succeed now
|
||||
SELECT master_create_empty_shard('lineitem_alter') as shardid \gset
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
SELECT count(*) from lineitem_alter;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
18000
|
||||
(1 row)
|
||||
|
||||
-- Verify that SET DATA TYPE works
|
||||
SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP BY int_column2;
|
||||
int_column2 | pg_typeof | count
|
||||
-------------+-----------+-------
|
||||
---------------------------------------------------------------------
|
||||
| integer | 6000
|
||||
2 | integer | 12000
|
||||
(2 rows)
|
||||
|
@ -236,7 +237,7 @@ SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP B
|
|||
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 SET DATA TYPE FLOAT;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -262,7 +263,7 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineite
|
|||
|
||||
SELECT int_column2, pg_typeof(int_column2), count(*) from lineitem_alter GROUP BY int_column2;
|
||||
int_column2 | pg_typeof | count
|
||||
-------------+------------------+-------
|
||||
---------------------------------------------------------------------
|
||||
| double precision | 6000
|
||||
2 | double precision | 12000
|
||||
(2 rows)
|
||||
|
@ -275,7 +276,7 @@ ALTER TABLE lineitem_alter DROP COLUMN date_column;
|
|||
ALTER TABLE lineitem_alter RENAME COLUMN l_orderkey TO l_orderkey_renamed;
|
||||
SELECT SUM(l_orderkey_renamed) FROM lineitem_alter;
|
||||
sum
|
||||
----------
|
||||
---------------------------------------------------------------------
|
||||
53620791
|
||||
(1 row)
|
||||
|
||||
|
@ -294,13 +295,13 @@ ALTER TABLE lineitem_alter DROP COLUMN IF EXISTS int_column2;
|
|||
ALTER TABLE IF EXISTS lineitem_alter RENAME COLUMN l_orderkey_renamed TO l_orderkey;
|
||||
SELECT SUM(l_orderkey) FROM lineitem_alter;
|
||||
sum
|
||||
----------
|
||||
---------------------------------------------------------------------
|
||||
53620791
|
||||
(1 row)
|
||||
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -325,7 +326,7 @@ ALTER TABLE lineitem_alter ADD COLUMN int_column1 INTEGER,
|
|||
ADD COLUMN int_column2 INTEGER;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -354,7 +355,7 @@ DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP|VAL
|
|||
ALTER TABLE lineitem_alter DROP COLUMN int_column1, DROP COLUMN int_column2;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -392,11 +393,9 @@ DETAIL: Only ADD|DROP COLUMN, SET|DROP NOT NULL, SET|DROP DEFAULT, ADD|DROP|VAL
|
|||
-- types
|
||||
ALTER TABLE lineitem_alter ADD COLUMN new_column non_existent_type;
|
||||
ERROR: type "non_existent_type" does not exist
|
||||
LINE 1: ALTER TABLE lineitem_alter ADD COLUMN new_column non_existen...
|
||||
^
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN null_column SET NOT NULL;
|
||||
ERROR: column "null_column" of relation "lineitem_alter_220000" contains null values
|
||||
CONTEXT: while executing command on localhost:57637
|
||||
ERROR: column "null_column" contains null values
|
||||
CONTEXT: while executing command on localhost:xxxxx
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN l_partkey SET DEFAULT 'a';
|
||||
ERROR: invalid input syntax for type integer: "a"
|
||||
-- Verify that we error out on RENAME CONSTRAINT statement
|
||||
|
@ -413,7 +412,7 @@ NOTICE: relation "non_existent_table" does not exist, skipping
|
|||
-- node
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -440,7 +439,7 @@ CREATE INDEX temp_index_1 ON lineitem_alter(l_linenumber);
|
|||
COMMIT;
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
--------------+----------------
|
||||
---------------------------------------------------------------------
|
||||
temp_index_1 | lineitem_alter
|
||||
(1 row)
|
||||
|
||||
|
@ -452,7 +451,7 @@ CREATE INDEX temp_index_2 ON lineitem_alter(l_orderkey);
|
|||
COMMIT;
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
--------------+----------------
|
||||
---------------------------------------------------------------------
|
||||
temp_index_2 | lineitem_alter
|
||||
(1 row)
|
||||
|
||||
|
@ -464,7 +463,7 @@ ALTER TABLE lineitem_alter ADD COLUMN first integer;
|
|||
COMMIT;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
Column | Type | Modifiers
|
||||
-----------------+-----------------------+-----------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | not null
|
||||
l_partkey | integer | not null
|
||||
l_suppkey | integer | not null
|
||||
|
@ -488,7 +487,7 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineite
|
|||
SELECT "Column", "Type", "Definition" FROM index_attrs WHERE
|
||||
relid = 'temp_index_2'::regclass;
|
||||
Column | Type | Definition
|
||||
------------+--------+------------
|
||||
---------------------------------------------------------------------
|
||||
l_orderkey | bigint | l_orderkey
|
||||
(1 row)
|
||||
|
||||
|
@ -501,7 +500,7 @@ CREATE INDEX temp_index_3 ON lineitem_alter(l_partkey);
|
|||
ROLLBACK;
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- ensure that errors cause full rollback
|
||||
|
@ -512,7 +511,7 @@ ERROR: relation "temp_index_2" already exists
|
|||
ROLLBACK;
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- verify that SAVEPOINT is allowed...
|
||||
|
@ -530,7 +529,7 @@ ROLLBACK TO my_savepoint;
|
|||
COMMIT;
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
--------------+----------------
|
||||
---------------------------------------------------------------------
|
||||
temp_index_2 | lineitem_alter
|
||||
(1 row)
|
||||
|
||||
|
@ -544,12 +543,12 @@ BEGIN;
|
|||
CREATE INDEX temp_index_2 ON lineitem_alter(l_orderkey);
|
||||
ALTER TABLE lineitem_alter ADD COLUMN first integer;
|
||||
ERROR: column "first" of relation "lineitem_alter_220000" already exists
|
||||
CONTEXT: while executing command on localhost:57638
|
||||
CONTEXT: while executing command on localhost:xxxxx
|
||||
COMMIT;
|
||||
-- Nothing from the block should have committed
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- Create single-shard table (to avoid deadlocks in the upcoming test hackery)
|
||||
|
@ -558,7 +557,7 @@ SET citus.shard_count TO 1;
|
|||
SET citus.shard_replication_factor TO 2;
|
||||
SELECT create_distributed_table('single_shard_items', 'id', 'hash');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -566,13 +565,13 @@ SELECT create_distributed_table('single_shard_items', 'id', 'hash');
|
|||
CREATE UNIQUE INDEX replica_idx on single_shard_items(id);
|
||||
SELECT relreplident FROM pg_class WHERE relname = 'single_shard_items';
|
||||
relreplident
|
||||
--------------
|
||||
---------------------------------------------------------------------
|
||||
d
|
||||
(1 row)
|
||||
|
||||
SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname LIKE ''single_shard_items_%'' LIMIT 1;');
|
||||
run_command_on_workers
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
(localhost,57637,t,d)
|
||||
(localhost,57638,t,d)
|
||||
(2 rows)
|
||||
|
@ -580,13 +579,13 @@ SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname L
|
|||
ALTER TABLE single_shard_items REPLICA IDENTITY nothing;
|
||||
SELECT relreplident FROM pg_class WHERE relname = 'single_shard_items';
|
||||
relreplident
|
||||
--------------
|
||||
---------------------------------------------------------------------
|
||||
n
|
||||
(1 row)
|
||||
|
||||
SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname LIKE ''single_shard_items_%'' LIMIT 1;');
|
||||
run_command_on_workers
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
(localhost,57637,t,n)
|
||||
(localhost,57638,t,n)
|
||||
(2 rows)
|
||||
|
@ -594,13 +593,13 @@ SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname L
|
|||
ALTER TABLE single_shard_items REPLICA IDENTITY full;
|
||||
SELECT relreplident FROM pg_class WHERE relname = 'single_shard_items';
|
||||
relreplident
|
||||
--------------
|
||||
---------------------------------------------------------------------
|
||||
f
|
||||
(1 row)
|
||||
|
||||
SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname LIKE ''single_shard_items_%'' LIMIT 1;');
|
||||
run_command_on_workers
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
(localhost,57637,t,f)
|
||||
(localhost,57638,t,f)
|
||||
(2 rows)
|
||||
|
@ -608,13 +607,13 @@ SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname L
|
|||
ALTER TABLE single_shard_items REPLICA IDENTITY USING INDEX replica_idx;
|
||||
SELECT relreplident FROM pg_class WHERE relname = 'single_shard_items';
|
||||
relreplident
|
||||
--------------
|
||||
---------------------------------------------------------------------
|
||||
i
|
||||
(1 row)
|
||||
|
||||
SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname LIKE ''single_shard_items_%'' LIMIT 1;');
|
||||
run_command_on_workers
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
(localhost,57637,t,i)
|
||||
(localhost,57638,t,i)
|
||||
(2 rows)
|
||||
|
@ -622,13 +621,13 @@ SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname L
|
|||
ALTER TABLE single_shard_items REPLICA IDENTITY default, REPLICA IDENTITY USING INDEX replica_idx, REPLICA IDENTITY nothing;
|
||||
SELECT relreplident FROM pg_class WHERE relname = 'single_shard_items';
|
||||
relreplident
|
||||
--------------
|
||||
---------------------------------------------------------------------
|
||||
n
|
||||
(1 row)
|
||||
|
||||
SELECT run_command_on_workers('SELECT relreplident FROM pg_class WHERE relname LIKE ''single_shard_items_%'' LIMIT 1;');
|
||||
run_command_on_workers
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
(localhost,57637,t,n)
|
||||
(localhost,57638,t,n)
|
||||
(2 rows)
|
||||
|
@ -659,11 +658,11 @@ CREATE INDEX single_index_3 ON single_shard_items(name);
|
|||
COMMIT;
|
||||
ERROR: duplicate key value violates unique constraint "ddl_commands_command_key"
|
||||
DETAIL: Key (command)=(CREATE INDEX) already exists.
|
||||
CONTEXT: while executing command on localhost:57638
|
||||
CONTEXT: while executing command on localhost:xxxxx
|
||||
-- Nothing from the block should have committed
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'single_shard_items' ORDER BY 1;
|
||||
indexname | tablename
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
\c - - - :worker_2_port
|
||||
|
@ -676,7 +675,7 @@ BEGIN;
|
|||
CREATE INDEX temp_index_2 ON lineitem_alter(l_orderkey);
|
||||
SELECT count(*) FROM lineitem_alter;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
18000
|
||||
(1 row)
|
||||
|
||||
|
@ -685,7 +684,7 @@ ROLLBACK;
|
|||
BEGIN;
|
||||
SELECT count(*) FROM lineitem_alter;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
18000
|
||||
(1 row)
|
||||
|
||||
|
@ -693,7 +692,7 @@ CREATE INDEX temp_index_2 ON lineitem_alter(l_orderkey);
|
|||
COMMIT;
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
--------------+----------------
|
||||
---------------------------------------------------------------------
|
||||
temp_index_2 | lineitem_alter
|
||||
(1 row)
|
||||
|
||||
|
@ -703,14 +702,14 @@ DROP INDEX temp_index_2;
|
|||
CREATE INDEX temp_index_3 ON lineitem_alter(l_orderkey);
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
--------------+----------------
|
||||
---------------------------------------------------------------------
|
||||
temp_index_3 | lineitem_alter
|
||||
(1 row)
|
||||
|
||||
DROP INDEX temp_index_3;
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- verify that not any of shard placements are marked as failed when a query failure occurs
|
||||
|
@ -718,7 +717,7 @@ CREATE TABLE test_ab (a int, b int);
|
|||
SET citus.shard_count TO 8;
|
||||
SELECT create_distributed_table('test_ab', 'a', 'hash');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -727,11 +726,11 @@ INSERT INTO test_ab VALUES (2, 11);
|
|||
CREATE UNIQUE INDEX temp_unique_index_1 ON test_ab(a);
|
||||
ERROR: could not create unique index "temp_unique_index_1_220011"
|
||||
DETAIL: Key (a)=(2) is duplicated.
|
||||
CONTEXT: while executing command on localhost:57638
|
||||
CONTEXT: while executing command on localhost:xxxxx
|
||||
SELECT shardid FROM pg_dist_shard_placement NATURAL JOIN pg_dist_shard
|
||||
WHERE logicalrelid='test_ab'::regclass AND shardstate=3;
|
||||
shardid
|
||||
---------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- Check that the schema on the worker still looks reasonable
|
||||
|
@ -742,7 +741,7 @@ FROM
|
|||
JOIN pg_attribute ON (pc.oid = pg_attribute.attrelid)
|
||||
ORDER BY attnum;
|
||||
attname | atttypid
|
||||
-------------------------------+-------------------
|
||||
---------------------------------------------------------------------
|
||||
tableoid | oid
|
||||
cmax | cid
|
||||
xmax | xid
|
||||
|
@ -779,7 +778,7 @@ ORDER BY attnum;
|
|||
-- verify that we can rename distributed tables
|
||||
SHOW citus.enable_ddl_propagation;
|
||||
citus.enable_ddl_propagation
|
||||
------------------------------
|
||||
---------------------------------------------------------------------
|
||||
on
|
||||
(1 row)
|
||||
|
||||
|
@ -787,7 +786,7 @@ ALTER TABLE lineitem_alter RENAME TO lineitem_renamed;
|
|||
-- verify rename is performed
|
||||
SELECT relname FROM pg_class WHERE relname = 'lineitem_renamed';
|
||||
relname
|
||||
------------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_renamed
|
||||
(1 row)
|
||||
|
||||
|
@ -795,7 +794,7 @@ SELECT relname FROM pg_class WHERE relname = 'lineitem_renamed';
|
|||
\c - - - :worker_1_port
|
||||
SELECT relname FROM pg_class WHERE relname LIKE 'lineitem_renamed%' ORDER BY relname;
|
||||
relname
|
||||
-------------------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_renamed_220000
|
||||
lineitem_renamed_220001
|
||||
lineitem_renamed_220003
|
||||
|
@ -808,7 +807,7 @@ ALTER TABLE lineitem_renamed RENAME TO lineitem_alter;
|
|||
\c - - - :worker_1_port
|
||||
SELECT relname FROM pg_class WHERE relname LIKE 'lineitem_alter%' AND relname <> 'lineitem_alter_220002' /* failed copy trails */ ORDER BY relname;
|
||||
relname
|
||||
-----------------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter_220000
|
||||
lineitem_alter_220001
|
||||
lineitem_alter_220003
|
||||
|
@ -819,14 +818,14 @@ SELECT relname FROM pg_class WHERE relname LIKE 'lineitem_alter%' AND relname <>
|
|||
ALTER TABLE lineitem_alter SET(fillfactor=40);
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'lineitem_alter';
|
||||
relname | reloptions
|
||||
----------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter | {fillfactor=40}
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'lineitem_alter%' AND relname <> 'lineitem_alter_220002' /* failed copy trails */ ORDER BY relname;
|
||||
relname | reloptions
|
||||
-----------------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter_220000 | {fillfactor=40}
|
||||
lineitem_alter_220001 | {fillfactor=40}
|
||||
lineitem_alter_220003 | {fillfactor=40}
|
||||
|
@ -836,14 +835,14 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'lineitem_alter%' AN
|
|||
ALTER TABLE lineitem_alter RESET(fillfactor);
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'lineitem_alter';
|
||||
relname | reloptions
|
||||
----------------+------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter |
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'lineitem_alter%' AND relname <> 'lineitem_alter_220002' /* failed copy trails */ ORDER BY relname;
|
||||
relname | reloptions
|
||||
-----------------------+------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter_220000 |
|
||||
lineitem_alter_220001 |
|
||||
lineitem_alter_220003 |
|
||||
|
@ -856,7 +855,7 @@ ALTER INDEX temp_index_1 RENAME TO idx_lineitem_linenumber;
|
|||
-- verify rename is performed
|
||||
SELECT relname FROM pg_class WHERE relname = 'idx_lineitem_linenumber';
|
||||
relname
|
||||
-------------------------
|
||||
---------------------------------------------------------------------
|
||||
idx_lineitem_linenumber
|
||||
(1 row)
|
||||
|
||||
|
@ -864,7 +863,7 @@ SELECT relname FROM pg_class WHERE relname = 'idx_lineitem_linenumber';
|
|||
\c - - - :worker_1_port
|
||||
SELECT relname FROM pg_class WHERE relname LIKE 'idx_lineitem_linenumber%' ORDER BY relname;
|
||||
relname
|
||||
--------------------------------
|
||||
---------------------------------------------------------------------
|
||||
idx_lineitem_linenumber_220000
|
||||
idx_lineitem_linenumber_220001
|
||||
idx_lineitem_linenumber_220003
|
||||
|
@ -880,7 +879,7 @@ ALTER TABLE lineitem_alter RENAME TO lineitem_renamed;
|
|||
-- verify rename is performed
|
||||
SELECT relname FROM pg_class WHERE relname = 'lineitem_alter' or relname = 'lineitem_renamed';
|
||||
relname
|
||||
------------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_renamed
|
||||
(1 row)
|
||||
|
||||
|
@ -892,15 +891,13 @@ ALTER TABLE lineitem_alter ADD COLUMN column_only_added_to_master int;
|
|||
\c - - - :worker_1_port
|
||||
SELECT column_only_added_to_master FROM lineitem_alter_220000 LIMIT 0;
|
||||
ERROR: column "column_only_added_to_master" does not exist
|
||||
LINE 1: SELECT column_only_added_to_master FROM lineitem_alter_22000...
|
||||
^
|
||||
\c - - - :master_port
|
||||
-- ddl propagation flag is reset to default, disable it again
|
||||
SET citus.enable_ddl_propagation to false;
|
||||
-- following query succeeds since it accesses an previously existing column
|
||||
SELECT l_orderkey FROM lineitem_alter LIMIT 0;
|
||||
l_orderkey
|
||||
------------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- make master and workers have the same schema again
|
||||
|
@ -908,7 +905,7 @@ ALTER TABLE lineitem_alter DROP COLUMN column_only_added_to_master;
|
|||
-- now this should succeed
|
||||
SELECT * FROM lineitem_alter LIMIT 0;
|
||||
l_orderkey | l_partkey | l_suppkey | l_linenumber | l_quantity | l_extendedprice | l_discount | l_tax | l_returnflag | l_linestatus | l_shipdate | l_commitdate | l_receiptdate | l_shipinstruct | l_shipmode | l_comment | null_column
|
||||
------------+-----------+-----------+--------------+------------+-----------------+------------+-------+--------------+--------------+------------+--------------+---------------+----------------+------------+-----------+-------------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
-- previously unsupported statements are accepted by postgresql now
|
||||
|
@ -924,7 +921,7 @@ ERROR: cannot execute ALTER TABLE command dropping partition column
|
|||
CREATE UNIQUE INDEX unique_lineitem_partkey on lineitem_alter(l_partkey);
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
||||
indexname | tablename
|
||||
-------------------------+----------------
|
||||
---------------------------------------------------------------------
|
||||
unique_lineitem_partkey | lineitem_alter
|
||||
(1 row)
|
||||
|
||||
|
@ -932,7 +929,7 @@ SELECT indexname, tablename FROM pg_indexes WHERE tablename = 'lineitem_alter';
|
|||
\c - - - :worker_1_port
|
||||
SELECT indexname, tablename FROM pg_indexes WHERE tablename like 'lineitem_alter_%';
|
||||
indexname | tablename
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
\c - - - :master_port
|
||||
|
@ -942,7 +939,7 @@ SET citus.shard_replication_factor TO 2;
|
|||
CREATE TABLE sequence_deadlock_test (a serial, b serial);
|
||||
SELECT create_distributed_table('sequence_deadlock_test', 'a');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -963,7 +960,7 @@ CREATE TABLE trigger_table (
|
|||
);
|
||||
SELECT create_distributed_table('trigger_table', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -984,7 +981,7 @@ FOR EACH ROW EXECUTE PROCEDURE update_value();
|
|||
INSERT INTO trigger_table VALUES (1, 'trigger disabled');
|
||||
SELECT value, count(*) FROM trigger_table GROUP BY value ORDER BY value;
|
||||
value | count
|
||||
-----------------+-------
|
||||
---------------------------------------------------------------------
|
||||
trigger enabled | 1
|
||||
(1 row)
|
||||
|
||||
|
@ -993,7 +990,7 @@ ERROR: triggers are not supported on distributed tables when "citus.enable_unsa
|
|||
INSERT INTO trigger_table VALUES (1, 'trigger disabled');
|
||||
SELECT value, count(*) FROM trigger_table GROUP BY value ORDER BY value;
|
||||
value | count
|
||||
-----------------+-------
|
||||
---------------------------------------------------------------------
|
||||
trigger enabled | 2
|
||||
(1 row)
|
||||
|
||||
|
@ -1002,14 +999,15 @@ ERROR: triggers are not supported on distributed tables when "citus.enable_unsa
|
|||
INSERT INTO trigger_table VALUES (1, 'trigger disabled');
|
||||
SELECT value, count(*) FROM trigger_table GROUP BY value ORDER BY value;
|
||||
value | count
|
||||
-----------------+-------
|
||||
---------------------------------------------------------------------
|
||||
trigger enabled | 3
|
||||
(1 row)
|
||||
|
||||
DROP TABLE trigger_table;
|
||||
-- test ALTER TABLE ALL IN TABLESPACE
|
||||
-- we expect that it will warn out
|
||||
CREATE TABLESPACE super_fast_ssd LOCATION '@abs_srcdir@/data';
|
||||
\set tablespace_location :abs_srcdir '/data'
|
||||
CREATE TABLESPACE super_fast_ssd LOCATION :'tablespace_location';
|
||||
ALTER TABLE ALL IN TABLESPACE pg_default SET TABLESPACE super_fast_ssd;
|
||||
WARNING: not propagating ALTER TABLE ALL IN TABLESPACE commands to worker nodes
|
||||
HINT: Connect to worker nodes directly to manually move all tables.
|
||||
|
@ -1034,7 +1032,7 @@ ALTER TABLE lineitem_alter OWNER TO alter_table_owner;
|
|||
-- should be able to query the table as table owner
|
||||
SELECT count(*) FROM lineitem_alter;
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
18000
|
||||
(1 row)
|
||||
|
||||
|
@ -1045,7 +1043,7 @@ DROP TABLE lineitem_alter;
|
|||
\c - postgres - :worker_1_port
|
||||
SELECT relname FROM pg_class WHERE relname LIKE 'lineitem_alter%';
|
||||
relname
|
||||
-----------------------
|
||||
---------------------------------------------------------------------
|
||||
lineitem_alter_220002
|
||||
(1 row)
|
||||
|
||||
|
@ -1058,7 +1056,7 @@ BEGIN;
|
|||
CREATE TABLE test_table_1(id int);
|
||||
SELECT create_distributed_table('test_table_1','id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -1069,7 +1067,7 @@ END;
|
|||
\c - - - :worker_1_port
|
||||
SELECT relname FROM pg_class WHERE relname LIKE 'test_table_1%';
|
||||
relname
|
||||
---------
|
||||
---------------------------------------------------------------------
|
||||
(0 rows)
|
||||
|
||||
\c - - - :master_port
|
||||
|
@ -1078,14 +1076,14 @@ CREATE TABLE logged_test(id int);
|
|||
ALTER TABLE logged_test SET UNLOGGED;
|
||||
SELECT create_distributed_table('logged_test', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, CASE relpersistence WHEN 'u' THEN 'unlogged' WHEN 'p' then 'logged' ELSE 'unknown' END AS logged_info FROM pg_class WHERE relname ~ 'logged_test_' ORDER BY relname;
|
||||
relname | logged_info
|
||||
--------------------+-------------
|
||||
---------------------------------------------------------------------
|
||||
logged_test_220022 | unlogged
|
||||
logged_test_220023 | unlogged
|
||||
logged_test_220024 | unlogged
|
||||
|
@ -1097,14 +1095,14 @@ SELECT relname, CASE relpersistence WHEN 'u' THEN 'unlogged' WHEN 'p' then 'logg
|
|||
ALTER TABLE logged_test SET LOGGED;
|
||||
SELECT relname, CASE relpersistence WHEN 'u' THEN 'unlogged' WHEN 'p' then 'logged' ELSE 'unknown' END AS logged_info FROM pg_class WHERE relname ~ 'logged_test*' ORDER BY relname;
|
||||
relname | logged_info
|
||||
-------------+-------------
|
||||
---------------------------------------------------------------------
|
||||
logged_test | logged
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, CASE relpersistence WHEN 'u' THEN 'unlogged' WHEN 'p' then 'logged' ELSE 'unknown' END AS logged_info FROM pg_class WHERE relname ~ 'logged_test_' ORDER BY relname;
|
||||
relname | logged_info
|
||||
--------------------+-------------
|
||||
---------------------------------------------------------------------
|
||||
logged_test_220022 | logged
|
||||
logged_test_220023 | logged
|
||||
logged_test_220024 | logged
|
||||
|
@ -1115,14 +1113,14 @@ SELECT relname, CASE relpersistence WHEN 'u' THEN 'unlogged' WHEN 'p' then 'logg
|
|||
ALTER TABLE logged_test SET UNLOGGED;
|
||||
SELECT relname, CASE relpersistence WHEN 'u' THEN 'unlogged' WHEN 'p' then 'logged' ELSE 'unknown' END AS logged_info FROM pg_class WHERE relname ~ 'logged_test*' ORDER BY relname;
|
||||
relname | logged_info
|
||||
-------------+-------------
|
||||
---------------------------------------------------------------------
|
||||
logged_test | unlogged
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, CASE relpersistence WHEN 'u' THEN 'unlogged' WHEN 'p' then 'logged' ELSE 'unknown' END AS logged_info FROM pg_class WHERE relname ~ 'logged_test_' ORDER BY relname;
|
||||
relname | logged_info
|
||||
--------------------+-------------
|
||||
---------------------------------------------------------------------
|
||||
logged_test_220022 | unlogged
|
||||
logged_test_220023 | unlogged
|
||||
logged_test_220024 | unlogged
|
||||
|
@ -1135,21 +1133,21 @@ DROP TABLE logged_test;
|
|||
CREATE TABLE hash_dist(id bigint primary key, f1 text) WITH (fillfactor=40);
|
||||
SELECT create_distributed_table('hash_dist','id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
-- verify that the storage options made it to the table definitions
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'hash_dist';
|
||||
relname | reloptions
|
||||
-----------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
hash_dist | {fillfactor=40}
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, reloptions FROM pg_class WHERE relkind = 'r' AND relname LIKE 'hash_dist_%' ORDER BY relname;
|
||||
relname | reloptions
|
||||
------------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
hash_dist_220026 | {fillfactor=40}
|
||||
hash_dist_220027 | {fillfactor=40}
|
||||
hash_dist_220028 | {fillfactor=40}
|
||||
|
@ -1161,14 +1159,14 @@ SELECT relname, reloptions FROM pg_class WHERE relkind = 'r' AND relname LIKE 'h
|
|||
ALTER INDEX hash_dist_pkey SET(fillfactor=40);
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'hash_dist_pkey';
|
||||
relname | reloptions
|
||||
----------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
hash_dist_pkey | {fillfactor=40}
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'hash_dist_pkey_%' ORDER BY relname;
|
||||
relname | reloptions
|
||||
-----------------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
hash_dist_pkey_220026 | {fillfactor=40}
|
||||
hash_dist_pkey_220027 | {fillfactor=40}
|
||||
hash_dist_pkey_220028 | {fillfactor=40}
|
||||
|
@ -1179,14 +1177,14 @@ SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'hash_dist_pkey_%' O
|
|||
ALTER INDEX hash_dist_pkey RESET(fillfactor);
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'hash_dist_pkey';
|
||||
relname | reloptions
|
||||
----------------+------------
|
||||
---------------------------------------------------------------------
|
||||
hash_dist_pkey |
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'hash_dist_pkey_%' ORDER BY relname;
|
||||
relname | reloptions
|
||||
-----------------------+------------
|
||||
---------------------------------------------------------------------
|
||||
hash_dist_pkey_220026 |
|
||||
hash_dist_pkey_220027 |
|
||||
hash_dist_pkey_220028 |
|
||||
|
@ -1203,14 +1201,14 @@ CREATE UNIQUE INDEX another_index ON hash_dist(id) WITH (fillfactor=50);
|
|||
-- show the index and its storage options on coordinator, then workers
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'another_index';
|
||||
relname | reloptions
|
||||
---------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
another_index | {fillfactor=50}
|
||||
(1 row)
|
||||
|
||||
\c - - - :worker_1_port
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname LIKE 'another_index_%' ORDER BY relname;
|
||||
relname | reloptions
|
||||
----------------------+-----------------
|
||||
---------------------------------------------------------------------
|
||||
another_index_220026 | {fillfactor=50}
|
||||
another_index_220027 | {fillfactor=50}
|
||||
another_index_220028 | {fillfactor=50}
|
||||
|
@ -1227,7 +1225,7 @@ SET citus.shard_replication_factor TO 1;
|
|||
CREATE TABLE test_table_1(id int);
|
||||
SELECT create_distributed_table('test_table_1', 'id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -1244,7 +1242,7 @@ HINT: You can issue each command separately such as ALTER TABLE test_table_1 AD
|
|||
CREATE TABLE reference_table(i int UNIQUE);
|
||||
SELECT create_reference_table('reference_table');
|
||||
create_reference_table
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -1260,7 +1258,7 @@ DROP TABLE reference_table;
|
|||
CREATE TABLE referenced_table(i int UNIQUE);
|
||||
SELECT create_distributed_table('referenced_table', 'i');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -1272,7 +1270,7 @@ DROP TABLE referenced_table, test_table_1;
|
|||
CREATE TABLE table_without_sequence(a int);
|
||||
SELECT create_distributed_table('table_without_sequence', 'a');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -1282,13 +1280,13 @@ ALTER TABLE table_without_sequence ADD COLUMN x BIGINT DEFAULT nextval('test_sch
|
|||
-- Should be distributed along with the sequence
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation.seq_10'::regclass);
|
||||
pg_identify_object_as_address
|
||||
---------------------------------------------------------------
|
||||
---------------------------------------------------------------------
|
||||
(sequence,"{test_schema_for_sequence_propagation,seq_10}",{})
|
||||
(1 row)
|
||||
|
||||
SELECT pg_identify_object_as_address(classid, objid, objsubid) from pg_catalog.pg_dist_object WHERE objid IN ('test_schema_for_sequence_propagation'::regnamespace);
|
||||
pg_identify_object_as_address
|
||||
----------------------------------------------------
|
||||
---------------------------------------------------------------------
|
||||
(schema,{test_schema_for_sequence_propagation},{})
|
||||
(1 row)
|
||||
|
|
@ -10,58 +10,60 @@ SET search_path TO 'with_basics';
|
|||
CREATE TABLE users_table (user_id int, time timestamp, value_1 int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('users_table', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE events_table (user_id int, time timestamp, event_type int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('events_table', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\COPY users_table FROM '@abs_srcdir@/data/users_table.data' WITH CSV;
|
||||
\COPY events_table FROM '@abs_srcdir@/data/events_table.data' WITH CSV;
|
||||
\set users_table_data_file :abs_srcdir '/data/users_table.data'
|
||||
\set events_table_data_file :abs_srcdir '/data/events_table.data'
|
||||
COPY users_table FROM :'users_table_data_file' WITH CSV;
|
||||
COPY events_table FROM :'events_table_data_file' WITH CSV;
|
||||
SET citus.shard_count = 96;
|
||||
CREATE SCHEMA subquery_and_ctes;
|
||||
SET search_path TO subquery_and_ctes;
|
||||
CREATE TABLE users_table (user_id int, time timestamp, value_1 int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('users_table', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE events_table (user_id int, time timestamp, event_type int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('events_table', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
\COPY users_table FROM '@abs_srcdir@/data/users_table.data' WITH CSV;
|
||||
\COPY events_table FROM '@abs_srcdir@/data/events_table.data' WITH CSV;
|
||||
COPY users_table FROM :'users_table_data_file' WITH CSV;
|
||||
COPY events_table FROM :'events_table_data_file' WITH CSV;
|
||||
SET citus.shard_count TO DEFAULT;
|
||||
SET search_path TO DEFAULT;
|
||||
CREATE TABLE users_table (user_id int, time timestamp, value_1 int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('users_table', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE events_table (user_id int, time timestamp, event_type int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('events_table', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE agg_results (user_id int, value_1_agg int, value_2_agg int, value_3_agg float, value_4_agg bigint, agg_time timestamp);
|
||||
SELECT create_distributed_table('agg_results', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -69,7 +71,7 @@ SELECT create_distributed_table('agg_results', 'user_id');
|
|||
CREATE TABLE agg_results_second (user_id int, value_1_agg int, value_2_agg int, value_3_agg float, value_4_agg bigint, agg_time timestamp);
|
||||
SELECT create_distributed_table('agg_results_second', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -77,7 +79,7 @@ SELECT create_distributed_table('agg_results_second', 'user_id');
|
|||
CREATE TABLE agg_results_third (user_id int, value_1_agg int, value_2_agg int, value_3_agg float, value_4_agg bigint, agg_time timestamp);
|
||||
SELECT create_distributed_table('agg_results_third', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -85,7 +87,7 @@ SELECT create_distributed_table('agg_results_third', 'user_id');
|
|||
CREATE TABLE agg_results_fourth (user_id int, value_1_agg int, value_2_agg int, value_3_agg float, value_4_agg bigint, agg_time timestamp);
|
||||
SELECT create_distributed_table('agg_results_fourth', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -93,14 +95,14 @@ SELECT create_distributed_table('agg_results_fourth', 'user_id');
|
|||
CREATE TABLE agg_results_window (user_id int, value_1_agg int, value_2_agg int, value_3_agg float, value_4_agg bigint, agg_time timestamp);
|
||||
SELECT create_distributed_table('agg_results_window', 'user_id');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
CREATE TABLE users_ref_test_table(id int, it_name varchar(25), k_no int);
|
||||
SELECT create_reference_table('users_ref_test_table');
|
||||
create_reference_table
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -110,8 +112,8 @@ INSERT INTO users_ref_test_table VALUES(3,'User_3',47);
|
|||
INSERT INTO users_ref_test_table VALUES(4,'User_4',48);
|
||||
INSERT INTO users_ref_test_table VALUES(5,'User_5',49);
|
||||
INSERT INTO users_ref_test_table VALUES(6,'User_6',50);
|
||||
\COPY users_table FROM '@abs_srcdir@/data/users_table.data' WITH CSV;
|
||||
\COPY events_table FROM '@abs_srcdir@/data/events_table.data' WITH CSV;
|
||||
COPY users_table FROM :'users_table_data_file' WITH CSV;
|
||||
COPY events_table FROM :'events_table_data_file' WITH CSV;
|
||||
-- create indexes for
|
||||
CREATE INDEX is_index1 ON users_table(user_id);
|
||||
CREATE INDEX is_index2 ON events_table(user_id);
|
||||
|
@ -136,7 +138,7 @@ SELECT run_command_on_master_and_workers($f$
|
|||
RETURNS NULL ON NULL INPUT;
|
||||
$f$);
|
||||
run_command_on_master_and_workers
|
||||
-----------------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -144,7 +146,7 @@ SET citus.next_shard_id TO 1400297;
|
|||
CREATE TABLE events_reference_table (like events_table including all);
|
||||
SELECT create_reference_table('events_reference_table');
|
||||
create_reference_table
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -153,7 +155,7 @@ INSERT INTO events_reference_table SELECT * FROM events_table;
|
|||
CREATE TABLE users_reference_table (like users_table including all);
|
||||
SELECT create_reference_table('users_reference_table');
|
||||
create_reference_table
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
|
@ -217,7 +217,7 @@ SELECT master_create_empty_shard('events') AS new_shard_id
|
|||
\gset
|
||||
UPDATE pg_dist_shard SET shardminvalue = '(2,2000000001)', shardmaxvalue = '(2,4300000000)'
|
||||
WHERE shardid = :new_shard_id;
|
||||
\COPY events FROM STDIN WITH CSV
|
||||
COPY events FROM STDIN WITH CSV;
|
||||
CREATE TABLE users (
|
||||
composite_id user_composite_type,
|
||||
lastseen bigint
|
||||
|
@ -247,7 +247,7 @@ SELECT master_create_empty_shard('users') AS new_shard_id
|
|||
\gset
|
||||
UPDATE pg_dist_shard SET shardminvalue = '(2,2000000001)', shardmaxvalue = '(2,4300000000)'
|
||||
WHERE shardid = :new_shard_id;
|
||||
\COPY users FROM STDIN WITH CSV
|
||||
COPY users FROM STDIN WITH CSV;
|
||||
-- Create tables for subquery tests
|
||||
CREATE TABLE lineitem_subquery (
|
||||
l_orderkey bigint not null,
|
||||
|
@ -330,7 +330,11 @@ SELECT master_create_empty_shard('orders_subquery') AS new_shard_id
|
|||
\gset
|
||||
UPDATE pg_dist_shard SET shardminvalue = 8997, shardmaxvalue = 14947
|
||||
WHERE shardid = :new_shard_id;
|
||||
\copy lineitem_subquery FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_subquery FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\copy orders_subquery FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders_subquery FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
COPY lineitem_subquery FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_subquery FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
COPY orders_subquery FROM :'orders_1_data_file' with delimiter '|';
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY orders_subquery FROM :'orders_2_data_file' with delimiter '|';
|
|
@ -29,8 +29,10 @@ SELECT create_distributed_table('lineitem_hash', 'l_orderkey', 'hash');
|
|||
|
||||
(1 row)
|
||||
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_hash FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_hash FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
ANALYZE lineitem_hash;
|
||||
-- count(distinct) is supported on top level query if there
|
||||
-- is a grouping on the partition key
|
|
@ -1,6 +1,11 @@
|
|||
--
|
||||
-- MULTI_COPY
|
||||
--
|
||||
-- set file paths
|
||||
\set customer1datafile :abs_srcdir '/data/customer.1.data'
|
||||
\set customer2datafile :abs_srcdir '/data/customer.2.data'
|
||||
\set customer3datafile :abs_srcdir '/data/customer.3.data'
|
||||
\set lineitem1datafile :abs_srcdir '/data/lineitem.1.data'
|
||||
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 560000;
|
||||
-- Create a new hash-partitioned table into which to COPY
|
||||
CREATE TABLE customer_copy_hash (
|
||||
|
@ -101,7 +106,7 @@ SELECT count(*) FROM customer_copy_hash WHERE c_custkey = 9;
|
|||
(1 row)
|
||||
|
||||
-- Test server-side copy from file
|
||||
COPY customer_copy_hash FROM '@abs_srcdir@/data/customer.2.data' WITH (DELIMITER '|');
|
||||
COPY customer_copy_hash FROM :'customer2datafile' WITH (DELIMITER '|');
|
||||
-- Confirm that data was copied
|
||||
SELECT count(*) FROM customer_copy_hash;
|
||||
count
|
||||
|
@ -110,7 +115,11 @@ SELECT count(*) FROM customer_copy_hash;
|
|||
(1 row)
|
||||
|
||||
-- Test client-side copy from file
|
||||
\copy customer_copy_hash FROM '@abs_srcdir@/data/customer.3.data' WITH (DELIMITER '|');
|
||||
-- \copy does not support variable interpolation. Hence we store and execute
|
||||
-- the query in two steps for interpolation to kick in.
|
||||
-- See https://stackoverflow.com/a/67642094/4576416 for details.
|
||||
\set client_side_copy_command '\\copy customer_copy_hash FROM ' :'customer3datafile' ' WITH (DELIMITER '''|''');'
|
||||
:client_side_copy_command
|
||||
-- Confirm that data was copied
|
||||
SELECT count(*) FROM customer_copy_hash;
|
||||
count
|
||||
|
@ -199,7 +208,7 @@ SELECT master_create_distributed_table('customer_copy_range', 'c_custkey', 'rang
|
|||
(1 row)
|
||||
|
||||
-- Test COPY into empty range-partitioned table
|
||||
COPY customer_copy_range FROM '@abs_srcdir@/data/customer.1.data' WITH (DELIMITER '|');
|
||||
COPY customer_copy_range FROM :'customer1datafile' WITH (DELIMITER '|');
|
||||
ERROR: could not find any shards into which to copy
|
||||
DETAIL: No shards exist for distributed table "customer_copy_range".
|
||||
SELECT master_create_empty_shard('customer_copy_range') AS new_shard_id
|
||||
|
@ -211,7 +220,7 @@ SELECT master_create_empty_shard('customer_copy_range') AS new_shard_id
|
|||
UPDATE pg_dist_shard SET shardminvalue = 501, shardmaxvalue = 1000
|
||||
WHERE shardid = :new_shard_id;
|
||||
-- Test copy into range-partitioned table
|
||||
COPY customer_copy_range FROM '@abs_srcdir@/data/customer.1.data' WITH (DELIMITER '|');
|
||||
COPY customer_copy_range FROM :'customer1datafile' WITH (DELIMITER '|');
|
||||
-- Check whether data went into the right shard (maybe)
|
||||
SELECT min(c_custkey), max(c_custkey), avg(c_custkey), count(*)
|
||||
FROM customer_copy_range WHERE c_custkey <= 500;
|
||||
|
@ -351,7 +360,7 @@ SELECT create_distributed_table('lineitem_copy_append', 'l_orderkey', 'append');
|
|||
|
||||
BEGIN;
|
||||
SELECT master_create_empty_shard('lineitem_copy_append') AS shardid \gset
|
||||
COPY lineitem_copy_append FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
COPY lineitem_copy_append FROM :'lineitem1datafile' with (delimiter '|', append_to_shard :shardid);
|
||||
END;
|
||||
SELECT count(*) FROM pg_dist_shard WHERE logicalrelid = 'lineitem_copy_append'::regclass;
|
||||
count
|
||||
|
@ -360,9 +369,9 @@ SELECT count(*) FROM pg_dist_shard WHERE logicalrelid = 'lineitem_copy_append'::
|
|||
(1 row)
|
||||
|
||||
-- trigger some errors on the append_to_shard option
|
||||
COPY lineitem_copy_append FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard xxxxx);
|
||||
COPY lineitem_copy_append FROM :'lineitem1datafile' with (delimiter '|', append_to_shard xxxxx);
|
||||
ERROR: could not find valid entry for shard xxxxx
|
||||
COPY lineitem_copy_append FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard xxxxx);
|
||||
COPY lineitem_copy_append FROM :'lineitem1datafile' with (delimiter '|', append_to_shard xxxxx);
|
||||
ERROR: shard xxxxx does not belong to table lineitem_copy_append
|
||||
-- Test schema support on append partitioned tables
|
||||
CREATE SCHEMA append;
|
||||
|
@ -384,8 +393,8 @@ SELECT create_distributed_table('append.customer_copy', 'c_custkey', 'append');
|
|||
SELECT master_create_empty_shard('append.customer_copy') AS shardid1 \gset
|
||||
SELECT master_create_empty_shard('append.customer_copy') AS shardid2 \gset
|
||||
-- Test copy from the master node
|
||||
COPY append.customer_copy FROM '@abs_srcdir@/data/customer.1.data' with (delimiter '|', append_to_shard :shardid1);
|
||||
COPY append.customer_copy FROM '@abs_srcdir@/data/customer.2.data' with (delimiter '|', append_to_shard :shardid2);
|
||||
COPY append.customer_copy FROM :'customer1datafile' with (delimiter '|', append_to_shard :shardid1);
|
||||
COPY append.customer_copy FROM :'customer2datafile' with (delimiter '|', append_to_shard :shardid2);
|
||||
-- Test the content of the table
|
||||
SELECT min(c_custkey), max(c_custkey), avg(c_acctbal), count(*) FROM append.customer_copy;
|
||||
min | max | avg | count
|
|
@ -0,0 +1,24 @@
|
|||
--
|
||||
-- MULTI_LOAD_DATA
|
||||
--
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY orders FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders FROM :'orders_2_data_file' with delimiter '|';
|
||||
COPY orders_reference FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders_reference FROM :'orders_2_data_file' with delimiter '|';
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
\set part_data_file :abs_srcdir '/data/part.data'
|
||||
\set supplier_data_file :abs_srcdir '/data/supplier.data'
|
||||
COPY customer FROM :'customer_1_data_file' with delimiter '|';
|
||||
COPY customer_append FROM :'customer_1_data_file' with (delimiter '|', append_to_shard xxxxx);
|
||||
COPY nation FROM :'nation_data_file' with delimiter '|';
|
||||
COPY part FROM :'part_data_file' with delimiter '|';
|
||||
COPY part_append FROM :'part_data_file' with (delimiter '|', append_to_shard xxxxx);
|
||||
COPY supplier FROM :'supplier_data_file' with delimiter '|';
|
||||
COPY supplier_single_shard FROM :'supplier_data_file' with delimiter '|';
|
|
@ -0,0 +1,8 @@
|
|||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY lineitem_hash_part FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_hash_part FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
COPY orders_hash_part FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders_hash_part FROM :'orders_2_data_file' with delimiter '|';
|
|
@ -0,0 +1,19 @@
|
|||
--
|
||||
-- MULTI_STAGE_MORE_DATA
|
||||
--
|
||||
SET citus.next_shard_id TO 280000;
|
||||
-- We load more data to customer and part tables to test distributed joins. The
|
||||
-- loading causes the planner to consider customer and part tables as large, and
|
||||
-- evaluate plans where some of the underlying tables need to be repartitioned.
|
||||
\set customer_2_data_file :abs_srcdir '/data/customer.2.data'
|
||||
\set customer_3_data_file :abs_srcdir '/data/customer.3.data'
|
||||
\set part_more_data_file :abs_srcdir '/data/part.more.data'
|
||||
COPY customer FROM :'customer_2_data_file' with delimiter '|';
|
||||
COPY customer FROM :'customer_3_data_file' with delimiter '|';
|
||||
COPY part FROM :'part_more_data_file' with delimiter '|';
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid1 \gset
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid2 \gset
|
||||
copy customer_append FROM :'customer_2_data_file' with (delimiter '|', append_to_shard :shardid1);
|
||||
copy customer_append FROM :'customer_3_data_file' with (delimiter '|', append_to_shard :shardid2);
|
||||
SELECT master_create_empty_shard('part_append') AS shardid \gset
|
||||
copy part_append FROM :'part_more_data_file' with (delimiter '|', append_to_shard :shardid);
|
|
@ -0,0 +1,50 @@
|
|||
--
|
||||
-- MULTI_MULTIUSER_LOAD_DATA
|
||||
--
|
||||
-- Tests for loading data in a distributed cluster. Please note that the number
|
||||
-- of shards uploaded depends on two config values: citusdb.shard_replication_factor and
|
||||
-- citusdb.shard_max_size. These values are manually set in pg_regress.c. We also set
|
||||
-- the shard placement policy to the local-node-first policy as other regression
|
||||
-- tests expect the placements to be in that order.
|
||||
SET citusdb.shard_placement_policy TO 'local-node-first';
|
||||
-- load as superuser
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_1_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
-- as user with ALL access
|
||||
SET ROLE full_access;
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
RESET ROLE;
|
||||
-- as user with SELECT access, should fail
|
||||
SET ROLE read_access;
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
ERROR: permission denied for table lineitem
|
||||
RESET ROLE;
|
||||
-- as user with no access, should fail
|
||||
SET ROLE no_access;
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
ERROR: permission denied for table lineitem
|
||||
RESET ROLE;
|
||||
SET ROLE full_access;
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
\set copy_command '\\COPY orders FROM ' :'orders_1_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY orders FROM ' :'orders_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
\set part_data_file :abs_srcdir '/data/part.data'
|
||||
\set supplier_data_file :abs_srcdir '/data/supplier.data'
|
||||
\set copy_command '\\COPY customer FROM ' :'customer_1_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY nation FROM ' :'nation_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY part FROM ' :'part_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY supplier FROM ' :'supplier_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
|
@ -1,12 +1,13 @@
|
|||
--
|
||||
-- MULTI_MX_COPY_DATA
|
||||
--
|
||||
\COPY nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
SET search_path TO citus_mx_test_schema;
|
||||
\COPY nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\COPY citus_mx_test_schema_join_1.nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\COPY citus_mx_test_schema_join_1.nation_hash_2 FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\COPY citus_mx_test_schema_join_2.nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
COPY nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema_join_1.nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema_join_1.nation_hash_2 FROM :'nation_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema_join_2.nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
SET citus.shard_replication_factor TO 2;
|
||||
CREATE TABLE citus_mx_test_schema.nation_hash_replicated AS SELECT * FROM citus_mx_test_schema.nation_hash;
|
||||
SELECT create_distributed_table('citus_mx_test_schema.nation_hash_replicated', 'n_nationkey');
|
||||
|
@ -19,18 +20,24 @@ HINT: To remove the local data, run: SELECT truncate_local_data_after_distribut
|
|||
|
||||
(1 row)
|
||||
|
||||
\COPY nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
COPY nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
-- now try loading data from worker node
|
||||
\c - - - :worker_1_port
|
||||
SET search_path TO public;
|
||||
\COPY lineitem_mx FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\COPY lineitem_mx FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\COPY citus_mx_test_schema.nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_mx FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_mx FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY citus_mx_test_schema.nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
\c - - - :worker_2_port
|
||||
-- and use second worker as well
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
\COPY citus_mx_test_schema.nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY orders_mx FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders_mx FROM :'orders_2_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema.nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
-- get ready for the next test
|
||||
TRUNCATE orders_mx;
|
||||
\c - - - :worker_2_port
|
||||
|
@ -55,7 +62,9 @@ show citus.local_shared_pool_size;
|
|||
-1
|
||||
(1 row)
|
||||
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY orders_mx FROM :'orders_1_data_file' with delimiter '|';
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
CONTEXT: COPY orders_mx, line 3: "3|1234|F|205654.30|1993-10-14|5-LOW|Clerk#000000955|0|sly final accounts boost. carefully regular id..."
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
|
@ -72,7 +81,7 @@ NOTICE: executing the copy locally for shard xxxxx
|
|||
CONTEXT: COPY orders_mx, line 25: "97|211|F|100572.55|1993-01-29|3-MEDIUM|Clerk#000000547|0|hang blithely along the regular accounts. f..."
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
CONTEXT: COPY orders_mx, line 38: "134|62|F|208201.46|1992-05-01|4-NOT SPECIFIED|Clerk#000000711|0|lar theodolites boos"
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
COPY orders_mx FROM :'orders_2_data_file' with delimiter '|';
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
CONTEXT: COPY orders_mx, line 2: "8998|80|F|147264.16|1993-01-04|5-LOW|Clerk#000000733|0| fluffily pending sauternes cajo"
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
|
@ -89,7 +98,8 @@ NOTICE: executing the copy locally for shard xxxxx
|
|||
CONTEXT: COPY orders_mx, line 43: "9159|1135|O|99594.61|1995-07-26|1-URGENT|Clerk#000000892|0|xcuses. quickly ironic deposits wake alon..."
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
CONTEXT: COPY orders_mx, line 69: "9281|904|F|173278.28|1992-02-24|1-URGENT|Clerk#000000530|0|eep furiously according to the requests; ..."
|
||||
\COPY citus_mx_test_schema.nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY citus_mx_test_schema.nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
CONTEXT: COPY nation_hash_replicated, line 1: "0|ALGERIA|0| haggle. carefully final deposits detect slyly agai"
|
||||
NOTICE: executing the copy locally for shard xxxxx
|
||||
|
@ -124,7 +134,11 @@ show citus.local_shared_pool_size;
|
|||
-- when worker nodes gain capability to run dml commands on reference tables.
|
||||
\c - - - :master_port
|
||||
SET search_path TO public;
|
||||
\COPY customer_mx FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\COPY nation_mx FROM '@abs_srcdir@/data/nation.data' with delimiter '|'
|
||||
\COPY part_mx FROM '@abs_srcdir@/data/part.data' with delimiter '|'
|
||||
\COPY supplier_mx FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
\set part_data_file :abs_srcdir '/data/part.data'
|
||||
\set supplier_data_file :abs_srcdir '/data/supplier.data'
|
||||
COPY customer_mx FROM :'customer_1_data_file' with delimiter '|';
|
||||
COPY nation_mx FROM :'nation_data_file' with delimiter '|';
|
||||
COPY part_mx FROM :'part_data_file' with delimiter '|';
|
||||
COPY supplier_mx FROM :'supplier_data_file' with delimiter '|';
|
|
@ -86,10 +86,13 @@ SELECT create_reference_table('multi_outer_join_third_reference');
|
|||
|
||||
(1 row)
|
||||
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-1-10.data' with delimiter '|'
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\set customer_1_10_data :abs_srcdir '/data/customer-1-10.data'
|
||||
\set customer_11_20_data :abs_srcdir '/data/customer-11-20.data'
|
||||
\set customer_1_15_data :abs_srcdir '/data/customer-1-15.data'
|
||||
COPY multi_outer_join_left FROM :'customer_1_10_data' with delimiter '|';
|
||||
COPY multi_outer_join_left FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right FROM :'customer_1_15_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_reference FROM :'customer_1_15_data' with delimiter '|';
|
||||
-- Make sure we do not crash if one table has no shards
|
||||
SELECT
|
||||
min(l_custkey), max(l_custkey)
|
||||
|
@ -110,8 +113,9 @@ FROM
|
|||
(1 row)
|
||||
|
||||
-- Third table is a single shard table with all data
|
||||
\copy multi_outer_join_third FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\copy multi_outer_join_third_reference FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\set customer_1_30_data :abs_srcdir '/data/customer-1-30.data'
|
||||
COPY multi_outer_join_third FROM :'customer_1_30_data' with delimiter '|';
|
||||
COPY multi_outer_join_third_reference FROM :'customer_1_30_data' with delimiter '|';
|
||||
-- Regular outer join should return results for all rows
|
||||
SELECT
|
||||
min(l_custkey), max(l_custkey)
|
||||
|
@ -223,7 +227,8 @@ FROM
|
|||
(1 row)
|
||||
|
||||
-- Turn the right table into a large table
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\set customer_21_30_data :abs_srcdir '/data/customer-21-30.data'
|
||||
COPY multi_outer_join_right FROM :'customer_21_30_data' with delimiter '|';
|
||||
-- Shards do not have 1-1 matching. We should error here.
|
||||
SELECT
|
||||
min(l_custkey), max(l_custkey)
|
||||
|
@ -238,10 +243,12 @@ FROM
|
|||
TRUNCATE multi_outer_join_left;
|
||||
TRUNCATE multi_outer_join_right;
|
||||
-- reload shards with 1-1 matching
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-subset-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-subset-21-30.data' with delimiter '|'
|
||||
\set customer_subset_11_20_data :abs_srcdir '/data/customer-subset-11-20.data'
|
||||
COPY multi_outer_join_left FROM :'customer_subset_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_left FROM :'customer_21_30_data' with delimiter '|';
|
||||
\set customer_subset_21_30_data :abs_srcdir '/data/customer-subset-21-30.data'
|
||||
COPY multi_outer_join_right FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right FROM :'customer_subset_21_30_data' with delimiter '|';
|
||||
-- multi_outer_join_third is a single shard table
|
||||
-- Regular left join should work as expected
|
||||
SELECT
|
||||
|
@ -795,7 +802,8 @@ LIMIT 20;
|
|||
(16 rows)
|
||||
|
||||
-- Add a shard to the left table that overlaps with multiple shards in the right
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
COPY multi_outer_join_left FROM :'customer_1_data_file' with delimiter '|';
|
||||
-- All outer joins should error out
|
||||
SELECT
|
||||
min(l_custkey), max(l_custkey)
|
||||
|
@ -877,7 +885,7 @@ SELECT create_distributed_table('left_values', 'val');
|
|||
|
||||
(1 row)
|
||||
|
||||
\copy left_values from stdin
|
||||
COPY left_values from stdin;
|
||||
CREATE TABLE right_values(val int);
|
||||
SELECT create_distributed_table('right_values', 'val');
|
||||
create_distributed_table
|
||||
|
@ -885,7 +893,7 @@ SELECT create_distributed_table('right_values', 'val');
|
|||
|
||||
(1 row)
|
||||
|
||||
\copy right_values from stdin
|
||||
COPY right_values from stdin;
|
||||
SELECT
|
||||
*
|
||||
FROM
|
|
@ -15,7 +15,7 @@ CREATE TABLE multi_outer_join_left_hash
|
|||
);
|
||||
SELECT create_distributed_table('multi_outer_join_left_hash', 'l_custkey');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -32,7 +32,7 @@ CREATE TABLE multi_outer_join_right_reference
|
|||
);
|
||||
SELECT create_reference_table('multi_outer_join_right_reference');
|
||||
create_reference_table
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -49,7 +49,7 @@ CREATE TABLE multi_outer_join_third_reference
|
|||
);
|
||||
SELECT create_reference_table('multi_outer_join_third_reference');
|
||||
create_reference_table
|
||||
------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -66,7 +66,7 @@ CREATE TABLE multi_outer_join_right_hash
|
|||
);
|
||||
SELECT create_distributed_table('multi_outer_join_right_hash', 'r_custkey');
|
||||
create_distributed_table
|
||||
--------------------------
|
||||
---------------------------------------------------------------------
|
||||
|
||||
(1 row)
|
||||
|
||||
|
@ -76,23 +76,26 @@ SELECT
|
|||
FROM
|
||||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_third_reference b ON (l_custkey = t_custkey);
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
|
|
||||
(1 row)
|
||||
|
||||
-- Left table is a large table
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-1-10.data' with delimiter '|'
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\set customer_1_10_data :abs_srcdir '/data/customer-1-10.data'
|
||||
\set customer_11_20_data :abs_srcdir '/data/customer-11-20.data'
|
||||
COPY multi_outer_join_left_hash FROM :'customer_1_10_data' with delimiter '|';
|
||||
COPY multi_outer_join_left_hash FROM :'customer_11_20_data' with delimiter '|';
|
||||
-- Right table is a small table
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\set customer_1_15_data :abs_srcdir '/data/customer-1-15.data'
|
||||
COPY multi_outer_join_right_reference FROM :'customer_1_15_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_hash FROM :'customer_1_15_data' with delimiter '|';
|
||||
-- Make sure we do not crash if one table has data
|
||||
SELECT
|
||||
min(l_custkey), max(l_custkey)
|
||||
FROM
|
||||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_third_reference b ON (l_custkey = t_custkey);
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
1 | 20
|
||||
(1 row)
|
||||
|
||||
|
@ -101,20 +104,21 @@ SELECT
|
|||
FROM
|
||||
multi_outer_join_third_reference a LEFT JOIN multi_outer_join_right_reference b ON (r_custkey = t_custkey);
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
|
|
||||
(1 row)
|
||||
|
||||
-- Third table is a single shard table with all data
|
||||
\copy multi_outer_join_third_reference FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\set customer_1_30_data :abs_srcdir '/data/customer-1-30.data'
|
||||
COPY multi_outer_join_third_reference FROM :'customer_1_30_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_hash FROM :'customer_1_30_data' with delimiter '|';
|
||||
-- Regular outer join should return results for all rows
|
||||
SELECT
|
||||
min(l_custkey), max(l_custkey)
|
||||
FROM
|
||||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_right_reference b ON (l_custkey = r_custkey);
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
1 | 20
|
||||
(1 row)
|
||||
|
||||
|
@ -124,7 +128,7 @@ SELECT
|
|||
FROM
|
||||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_right_reference b ON (l_nationkey = r_nationkey);
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
28
|
||||
(1 row)
|
||||
|
||||
|
@ -136,7 +140,7 @@ FROM
|
|||
WHERE
|
||||
r_custkey IS NULL;
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
16 | 20
|
||||
(1 row)
|
||||
|
||||
|
@ -148,7 +152,7 @@ FROM
|
|||
WHERE
|
||||
r_custkey IS NULL OR r_custkey = 5;
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
5 | 20
|
||||
(1 row)
|
||||
|
||||
|
@ -161,7 +165,7 @@ FROM
|
|||
WHERE
|
||||
r_custkey = 5 or r_custkey > 15;
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
5 | 5
|
||||
(1 row)
|
||||
|
||||
|
@ -172,7 +176,7 @@ FROM
|
|||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_right_reference b
|
||||
ON (l_custkey = r_custkey AND r_custkey = 5);
|
||||
count | count
|
||||
-------+-------
|
||||
---------------------------------------------------------------------
|
||||
20 | 1
|
||||
(1 row)
|
||||
|
||||
|
@ -183,7 +187,7 @@ FROM
|
|||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_right_reference b
|
||||
ON (l_custkey = r_custkey AND r_custkey = -1 /* nonexistant */);
|
||||
count | count
|
||||
-------+-------
|
||||
---------------------------------------------------------------------
|
||||
20 | 0
|
||||
(1 row)
|
||||
|
||||
|
@ -194,7 +198,7 @@ FROM
|
|||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_right_reference b
|
||||
ON (l_custkey = r_custkey AND l_custkey = -1 /* nonexistant */);
|
||||
count | count
|
||||
-------+-------
|
||||
---------------------------------------------------------------------
|
||||
20 | 0
|
||||
(1 row)
|
||||
|
||||
|
@ -211,12 +215,13 @@ SELECT
|
|||
FROM
|
||||
multi_outer_join_right_reference a RIGHT JOIN multi_outer_join_left_hash b ON (l_custkey = r_custkey);
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
1 | 20
|
||||
(1 row)
|
||||
|
||||
-- load some more data
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\set customer_21_30_data :abs_srcdir '/data/customer-21-30.data'
|
||||
COPY multi_outer_join_right_reference FROM :'customer_21_30_data' with delimiter '|';
|
||||
-- Update shards so that they do not have 1-1 matching, triggering an error.
|
||||
UPDATE pg_dist_shard SET shardminvalue = '2147483646' WHERE shardid = 1260006;
|
||||
UPDATE pg_dist_shard SET shardmaxvalue = '2147483647' WHERE shardid = 1260006;
|
||||
|
@ -230,12 +235,12 @@ UPDATE pg_dist_shard SET shardmaxvalue = '-1073741825' WHERE shardid = 1260006;
|
|||
-- empty tables
|
||||
TRUNCATE multi_outer_join_left_hash, multi_outer_join_right_hash, multi_outer_join_right_reference;
|
||||
-- reload shards with 1-1 matching
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
COPY multi_outer_join_left_hash FROM :'customer_1_15_data' with delimiter '|';
|
||||
COPY multi_outer_join_left_hash FROM :'customer_21_30_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_reference FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_reference FROM :'customer_21_30_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_hash FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_hash FROM :'customer_21_30_data' with delimiter '|';
|
||||
-- multi_outer_join_third_reference is a single shard table
|
||||
-- Regular left join should work as expected
|
||||
SELECT
|
||||
|
@ -243,7 +248,7 @@ SELECT
|
|||
FROM
|
||||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_right_hash b ON (l_custkey = r_custkey);
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
1 | 30
|
||||
(1 row)
|
||||
|
||||
|
@ -261,7 +266,7 @@ FROM
|
|||
WHERE
|
||||
r_custkey IS NULL;
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
1 | 10
|
||||
(1 row)
|
||||
|
||||
|
@ -273,7 +278,7 @@ FROM
|
|||
WHERE
|
||||
r_custkey IS NULL OR r_custkey = 15;
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
1 | 15
|
||||
(1 row)
|
||||
|
||||
|
@ -286,7 +291,7 @@ FROM
|
|||
WHERE
|
||||
r_custkey = 21 or r_custkey < 10;
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
21 | 21
|
||||
(1 row)
|
||||
|
||||
|
@ -297,7 +302,7 @@ FROM
|
|||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_right_reference b
|
||||
ON (l_custkey = r_custkey AND r_custkey = 21);
|
||||
count | count
|
||||
-------+-------
|
||||
---------------------------------------------------------------------
|
||||
25 | 1
|
||||
(1 row)
|
||||
|
||||
|
@ -314,7 +319,7 @@ SELECT
|
|||
FROM
|
||||
multi_outer_join_right_reference a RIGHT JOIN multi_outer_join_left_hash b ON (l_custkey = r_custkey);
|
||||
min | max
|
||||
-----+-----
|
||||
---------------------------------------------------------------------
|
||||
1 | 30
|
||||
(1 row)
|
||||
|
||||
|
@ -347,7 +352,7 @@ FROM
|
|||
LEFT JOIN multi_outer_join_third_reference t1 ON (r1.r_custkey = t1.t_custkey)
|
||||
ORDER BY 1;
|
||||
l_custkey | r_custkey | t_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 | |
|
||||
2 | |
|
||||
3 | |
|
||||
|
@ -393,7 +398,7 @@ FROM
|
|||
LEFT JOIN multi_outer_join_left_hash l1 ON (r1.r_custkey = l1.l_custkey)
|
||||
ORDER BY 1,2,3;
|
||||
t_custkey | r_custkey | l_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
11 | 11 | 11
|
||||
12 | 12 | 12
|
||||
13 | 13 | 13
|
||||
|
@ -427,7 +432,7 @@ WHERE
|
|||
l_custkey is NULL
|
||||
ORDER BY 1;
|
||||
t_custkey | r_custkey | l_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
16 | 16 |
|
||||
17 | 17 |
|
||||
18 | 18 |
|
||||
|
@ -444,7 +449,7 @@ FROM
|
|||
RIGHT JOIN multi_outer_join_left_hash l1 ON (r1.r_custkey = l1.l_custkey)
|
||||
ORDER BY l_custkey;
|
||||
t_custkey | r_custkey | l_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
| | 1
|
||||
| | 2
|
||||
| | 3
|
||||
|
@ -480,7 +485,7 @@ FROM
|
|||
FULL JOIN multi_outer_join_right_hash r1 ON (l1.l_custkey = r1.r_custkey)
|
||||
ORDER BY 1,2;
|
||||
l_custkey | r_custkey
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 |
|
||||
2 |
|
||||
3 |
|
||||
|
@ -523,7 +528,7 @@ WHERE
|
|||
r_custkey is NULL
|
||||
ORDER BY 1;
|
||||
l_custkey | r_custkey
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 |
|
||||
2 |
|
||||
3 |
|
||||
|
@ -546,7 +551,7 @@ WHERE
|
|||
l_custkey is NULL
|
||||
ORDER BY 2;
|
||||
l_custkey | r_custkey
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
| 16
|
||||
| 17
|
||||
| 18
|
||||
|
@ -564,7 +569,7 @@ WHERE
|
|||
l_custkey is NULL or r_custkey is NULL
|
||||
ORDER BY 1,2 DESC;
|
||||
l_custkey | r_custkey
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 |
|
||||
2 |
|
||||
3 |
|
||||
|
@ -599,7 +604,7 @@ FROM
|
|||
LEFT JOIN multi_outer_join_third_reference t1 ON (r1.r_custkey = t1.t_custkey)
|
||||
ORDER BY 1;
|
||||
l_custkey | r_custkey | t_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
11 | 11 | 11
|
||||
12 | 12 | 12
|
||||
13 | 13 | 13
|
||||
|
@ -626,7 +631,7 @@ FROM
|
|||
LEFT JOIN multi_outer_join_right_hash r1 ON (l1.l_custkey = r1.r_custkey)
|
||||
ORDER BY 1,2,3;
|
||||
l_custkey | t_custkey | r_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 | 1 |
|
||||
2 | 2 |
|
||||
3 | 3 |
|
||||
|
@ -663,7 +668,7 @@ FROM
|
|||
LEFT JOIN multi_outer_join_right_reference r1 ON (l1.l_custkey = r1.r_custkey)
|
||||
ORDER BY 1,2,3;
|
||||
t_custkey | l_custkey | r_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 | 1 |
|
||||
2 | 2 |
|
||||
3 | 3 |
|
||||
|
@ -700,7 +705,7 @@ FROM
|
|||
LEFT JOIN multi_outer_join_right_hash r1 ON (l1.l_custkey = r1.r_custkey)
|
||||
ORDER BY 1,2,3;
|
||||
l_custkey | t_custkey | r_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 | 1 |
|
||||
2 | 2 |
|
||||
3 | 3 |
|
||||
|
@ -739,7 +744,7 @@ WHERE
|
|||
r_custkey is NULL
|
||||
ORDER BY 1;
|
||||
l_custkey | t_custkey | r_custkey
|
||||
-----------+-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 | 1 |
|
||||
2 | 2 |
|
||||
3 | 3 |
|
||||
|
@ -762,7 +767,7 @@ FROM
|
|||
INNER JOIN multi_outer_join_third_reference t1 ON (test.c_custkey = t1.t_custkey)
|
||||
ORDER BY 1;
|
||||
t_custkey
|
||||
-----------
|
||||
---------------------------------------------------------------------
|
||||
11
|
||||
12
|
||||
13
|
||||
|
@ -803,7 +808,7 @@ GROUP BY l1.l_custkey
|
|||
ORDER BY cnt DESC, l1.l_custkey DESC
|
||||
LIMIT 20;
|
||||
l_custkey | cnt
|
||||
-----------+-----
|
||||
---------------------------------------------------------------------
|
||||
30 | 1
|
||||
29 | 1
|
||||
28 | 1
|
||||
|
@ -834,7 +839,7 @@ FROM
|
|||
multi_outer_join_third_reference ON (t_custkey = r_custkey)
|
||||
ORDER BY 1;
|
||||
t_custkey | r_custkey
|
||||
-----------+-----------
|
||||
---------------------------------------------------------------------
|
||||
1 |
|
||||
2 |
|
||||
3 |
|
||||
|
@ -880,7 +885,7 @@ LEFT JOIN (
|
|||
) AS bar
|
||||
ON (l_name = r_name);
|
||||
count
|
||||
-------
|
||||
---------------------------------------------------------------------
|
||||
25
|
||||
(1 row)
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
\set test_tablespace :abs_srcdir '/tmp_check/ts0'
|
||||
CREATE TABLESPACE test_tablespace LOCATION XXXX
|
||||
\c - - - :worker_1_port
|
||||
\set test_tablespace :abs_srcdir '/tmp_check/ts1'
|
||||
CREATE TABLESPACE test_tablespace LOCATION XXXX
|
||||
\c - - - :worker_2_port
|
||||
\set test_tablespace :abs_srcdir '/tmp_check/ts2'
|
||||
CREATE TABLESPACE test_tablespace LOCATION XXXX
|
|
@ -1,20 +0,0 @@
|
|||
--
|
||||
-- MULTI_LOAD_DATA
|
||||
--
|
||||
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
|
||||
\copy orders_reference FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders_reference FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\copy customer_append FROM '@abs_srcdir@/data/customer.1.data' with (delimiter '|', append_to_shard 360006)
|
||||
\copy nation FROM '@abs_srcdir@/data/nation.data' with delimiter '|'
|
||||
\copy part FROM '@abs_srcdir@/data/part.data' with delimiter '|'
|
||||
\copy part_append FROM '@abs_srcdir@/data/part.data' with (delimiter '|', append_to_shard 360009)
|
||||
\copy supplier FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
||||
\copy supplier_single_shard FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
|
@ -1,4 +0,0 @@
|
|||
\copy lineitem_hash_part FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_hash_part FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\copy orders_hash_part FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders_hash_part FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
|
@ -1,25 +0,0 @@
|
|||
--
|
||||
-- MULTI_STAGE_MORE_DATA
|
||||
--
|
||||
|
||||
|
||||
SET citus.next_shard_id TO 280000;
|
||||
|
||||
|
||||
-- We load more data to customer and part tables to test distributed joins. The
|
||||
-- loading causes the planner to consider customer and part tables as large, and
|
||||
-- evaluate plans where some of the underlying tables need to be repartitioned.
|
||||
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.2.data' with delimiter '|'
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.3.data' with delimiter '|'
|
||||
\copy part FROM '@abs_srcdir@/data/part.more.data' with delimiter '|'
|
||||
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid1 \gset
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid2 \gset
|
||||
|
||||
copy customer_append FROM '@abs_srcdir@/data/customer.2.data' with (delimiter '|', append_to_shard :shardid1);
|
||||
copy customer_append FROM '@abs_srcdir@/data/customer.3.data' with (delimiter '|', append_to_shard :shardid2);
|
||||
|
||||
SELECT master_create_empty_shard('part_append') AS shardid \gset
|
||||
|
||||
copy part_append FROM '@abs_srcdir@/data/part.more.data' with (delimiter '|', append_to_shard :shardid);
|
|
@ -1,38 +0,0 @@
|
|||
--
|
||||
-- MULTI_MULTIUSER_LOAD_DATA
|
||||
--
|
||||
|
||||
-- Tests for loading data in a distributed cluster. Please note that the number
|
||||
-- of shards uploaded depends on two config values: citusdb.shard_replication_factor and
|
||||
-- citusdb.shard_max_size. These values are manually set in pg_regress.c. We also set
|
||||
-- the shard placement policy to the local-node-first policy as other regression
|
||||
-- tests expect the placements to be in that order.
|
||||
|
||||
SET citusdb.shard_placement_policy TO 'local-node-first';
|
||||
|
||||
-- load as superuser
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
|
||||
-- as user with ALL access
|
||||
SET ROLE full_access;
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
RESET ROLE;
|
||||
|
||||
-- as user with SELECT access, should fail
|
||||
SET ROLE read_access;
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
RESET ROLE;
|
||||
|
||||
-- as user with no access, should fail
|
||||
SET ROLE no_access;
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
RESET ROLE;
|
||||
|
||||
SET ROLE full_access;
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\copy nation FROM '@abs_srcdir@/data/nation.data' with delimiter '|'
|
||||
\copy part FROM '@abs_srcdir@/data/part.data' with delimiter '|'
|
||||
\copy supplier FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
|
@ -1,64 +0,0 @@
|
|||
--
|
||||
-- MULTI_MX_COPY_DATA
|
||||
--
|
||||
|
||||
\COPY nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
|
||||
SET search_path TO citus_mx_test_schema;
|
||||
\COPY nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\COPY citus_mx_test_schema_join_1.nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\COPY citus_mx_test_schema_join_1.nation_hash_2 FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
\COPY citus_mx_test_schema_join_2.nation_hash FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
|
||||
SET citus.shard_replication_factor TO 2;
|
||||
CREATE TABLE citus_mx_test_schema.nation_hash_replicated AS SELECT * FROM citus_mx_test_schema.nation_hash;
|
||||
SELECT create_distributed_table('citus_mx_test_schema.nation_hash_replicated', 'n_nationkey');
|
||||
\COPY nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
|
||||
-- now try loading data from worker node
|
||||
\c - - - :worker_1_port
|
||||
SET search_path TO public;
|
||||
|
||||
\COPY lineitem_mx FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\COPY lineitem_mx FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
|
||||
\COPY citus_mx_test_schema.nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
|
||||
\c - - - :worker_2_port
|
||||
-- and use second worker as well
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
\COPY citus_mx_test_schema.nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
|
||||
-- get ready for the next test
|
||||
TRUNCATE orders_mx;
|
||||
|
||||
\c - - - :worker_2_port
|
||||
SET citus.log_local_commands TO ON;
|
||||
-- simulate the case where there is no connection slots available
|
||||
ALTER SYSTEM SET citus.local_shared_pool_size TO -1;
|
||||
SELECT pg_reload_conf();
|
||||
SELECT pg_sleep(0.1);
|
||||
show citus.local_shared_pool_size;
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\COPY orders_mx FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
|
||||
\COPY citus_mx_test_schema.nation_hash_replicated FROM '@abs_srcdir@/data/nation.data' with delimiter '|';
|
||||
|
||||
-- set it back
|
||||
ALTER SYSTEM RESET citus.local_shared_pool_size;
|
||||
SELECT pg_reload_conf();
|
||||
SELECT pg_sleep(0.1);
|
||||
show citus.local_shared_pool_size;
|
||||
|
||||
-- These copies were intended to test copying data to single sharded table from
|
||||
-- worker nodes, yet in order to remove broadcast logic related codes we change
|
||||
-- the table to reference table and copy data from master. Should be updated
|
||||
-- when worker nodes gain capability to run dml commands on reference tables.
|
||||
\c - - - :master_port
|
||||
SET search_path TO public;
|
||||
|
||||
\COPY customer_mx FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\COPY nation_mx FROM '@abs_srcdir@/data/nation.data' with delimiter '|'
|
||||
\COPY part_mx FROM '@abs_srcdir@/data/part.data' with delimiter '|'
|
||||
\COPY supplier_mx FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
|
@ -1,5 +0,0 @@
|
|||
CREATE TABLESPACE test_tablespace LOCATION '@abs_srcdir@/tmp_check/ts0';
|
||||
\c - - - :worker_1_port
|
||||
CREATE TABLESPACE test_tablespace LOCATION '@abs_srcdir@/tmp_check/ts1';
|
||||
\c - - - :worker_2_port
|
||||
CREATE TABLESPACE test_tablespace LOCATION '@abs_srcdir@/tmp_check/ts2';
|
|
@ -1,16 +0,0 @@
|
|||
--
|
||||
-- MULTI_LOAD_DATA
|
||||
--
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
\copy orders_reference FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders_reference FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\copy customer_append FROM '@abs_srcdir@/data/customer.1.data' with (delimiter '|', append_to_shard 360006)
|
||||
\copy nation FROM '@abs_srcdir@/data/nation.data' with delimiter '|'
|
||||
\copy part FROM '@abs_srcdir@/data/part.data' with delimiter '|'
|
||||
\copy part_append FROM '@abs_srcdir@/data/part.data' with (delimiter '|', append_to_shard 360009)
|
||||
\copy supplier FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
||||
\copy supplier_single_shard FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
|
@ -1,4 +0,0 @@
|
|||
\copy lineitem_hash_part FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_hash_part FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\copy orders_hash_part FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders_hash_part FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
|
@ -1,16 +0,0 @@
|
|||
--
|
||||
-- MULTI_STAGE_MORE_DATA
|
||||
--
|
||||
SET citus.next_shard_id TO 280000;
|
||||
-- We load more data to customer and part tables to test distributed joins. The
|
||||
-- loading causes the planner to consider customer and part tables as large, and
|
||||
-- evaluate plans where some of the underlying tables need to be repartitioned.
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.2.data' with delimiter '|'
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.3.data' with delimiter '|'
|
||||
\copy part FROM '@abs_srcdir@/data/part.more.data' with delimiter '|'
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid1 \gset
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid2 \gset
|
||||
copy customer_append FROM '@abs_srcdir@/data/customer.2.data' with (delimiter '|', append_to_shard :shardid1);
|
||||
copy customer_append FROM '@abs_srcdir@/data/customer.3.data' with (delimiter '|', append_to_shard :shardid2);
|
||||
SELECT master_create_empty_shard('part_append') AS shardid \gset
|
||||
copy part_append FROM '@abs_srcdir@/data/part.more.data' with (delimiter '|', append_to_shard :shardid);
|
|
@ -1,32 +0,0 @@
|
|||
--
|
||||
-- MULTI_MULTIUSER_LOAD_DATA
|
||||
--
|
||||
-- Tests for loading data in a distributed cluster. Please note that the number
|
||||
-- of shards uploaded depends on two config values: citusdb.shard_replication_factor and
|
||||
-- citusdb.shard_max_size. These values are manually set in pg_regress.c. We also set
|
||||
-- the shard placement policy to the local-node-first policy as other regression
|
||||
-- tests expect the placements to be in that order.
|
||||
SET citusdb.shard_placement_policy TO 'local-node-first';
|
||||
-- load as superuser
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
-- as user with ALL access
|
||||
SET ROLE full_access;
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
RESET ROLE;
|
||||
-- as user with SELECT access, should fail
|
||||
SET ROLE read_access;
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
ERROR: permission denied for table lineitem
|
||||
RESET ROLE;
|
||||
-- as user with no access, should fail
|
||||
SET ROLE no_access;
|
||||
\copy lineitem FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
ERROR: permission denied for table lineitem
|
||||
RESET ROLE;
|
||||
SET ROLE full_access;
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
\copy customer FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\copy nation FROM '@abs_srcdir@/data/nation.data' with delimiter '|'
|
||||
\copy part FROM '@abs_srcdir@/data/part.data' with delimiter '|'
|
||||
\copy supplier FROM '@abs_srcdir@/data/supplier.data' with delimiter '|'
|
|
@ -1,5 +0,0 @@
|
|||
CREATE TABLESPACE test_tablespace LOCATION '@abs_srcdir@/tmp_check/ts0';
|
||||
\c - - - :worker_1_port
|
||||
CREATE TABLESPACE test_tablespace LOCATION '@abs_srcdir@/tmp_check/ts1';
|
||||
\c - - - :worker_2_port
|
||||
CREATE TABLESPACE test_tablespace LOCATION '@abs_srcdir@/tmp_check/ts2';
|
|
@ -66,6 +66,7 @@ my $bindir = "";
|
|||
my $libdir = undef;
|
||||
my $pgxsdir = "";
|
||||
my $postgresBuilddir = "";
|
||||
my $citusAbsSrcdir = "";
|
||||
my $postgresSrcdir = "";
|
||||
my $majorversion = "";
|
||||
my $synchronousReplication = "";
|
||||
|
@ -104,6 +105,7 @@ GetOptions(
|
|||
'pgxsdir=s' => \$pgxsdir,
|
||||
'postgres-builddir=s' => \$postgresBuilddir,
|
||||
'postgres-srcdir=s' => \$postgresSrcdir,
|
||||
'citus_abs_srcdir=s' => \$citusAbsSrcdir,
|
||||
'majorversion=s' => \$majorversion,
|
||||
'load-extension=s' => \@extensions,
|
||||
'server-option=s' => \@userPgOptions,
|
||||
|
@ -640,6 +642,7 @@ print $fh "--variable=worker_2_proxy_port=$mitmPort ";
|
|||
print $fh "--variable=follower_master_port=$followerCoordPort ";
|
||||
print $fh "--variable=default_user=$user ";
|
||||
print $fh "--variable=SHOW_CONTEXT=always ";
|
||||
print $fh "--variable=abs_srcdir=$citusAbsSrcdir ";
|
||||
for my $workeroff (0 .. $#workerPorts)
|
||||
{
|
||||
my $port = $workerPorts[$workeroff];
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
/columnar_copyto.sql
|
||||
/columnar_data_types.sql
|
||||
/columnar_load.sql
|
||||
/hyperscale_tutorial.sql
|
||||
/multi_agg_distinct.sql
|
||||
/multi_agg_type_conversion.sql
|
||||
/multi_alter_table_statements.sql
|
||||
/multi_behavioral_analytics_create_table.sql
|
||||
/multi_behavioral_analytics_create_table_superuser.sql
|
||||
/multi_complex_count_distinct.sql
|
||||
/multi_copy.sql
|
||||
/multi_load_data.sql
|
||||
/multi_load_data_superuser.sql
|
||||
/multi_load_more_data.sql
|
||||
/multi_multiuser_load_data.sql
|
||||
/multi_mx_copy_data.sql
|
||||
/multi_outer_join.sql
|
||||
/multi_outer_join_reference.sql
|
||||
/tablespace.sql
|
|
@ -6,7 +6,8 @@ CREATE TABLE test_contestant(handle TEXT, birthdate DATE, rating INT,
|
|||
USING columnar;
|
||||
|
||||
-- load table data from file
|
||||
COPY test_contestant FROM '@abs_srcdir@/data/contestants.1.csv' WITH CSV;
|
||||
\set contestants_1_csv_file :abs_srcdir '/data/contestants.1.csv'
|
||||
COPY test_contestant FROM :'contestants_1_csv_file' WITH CSV;
|
||||
|
||||
-- export using COPY table TO ...
|
||||
COPY test_contestant TO STDOUT;
|
|
@ -13,7 +13,8 @@ SET intervalstyle TO 'POSTGRES_VERBOSE';
|
|||
CREATE TABLE test_array_types (int_array int[], bigint_array bigint[],
|
||||
text_array text[]) USING columnar;
|
||||
|
||||
COPY test_array_types FROM '@abs_srcdir@/data/array_types.csv' WITH CSV;
|
||||
\set array_types_csv_file :abs_srcdir '/data/array_types.csv'
|
||||
COPY test_array_types FROM :'array_types_csv_file' WITH CSV;
|
||||
|
||||
SELECT * FROM test_array_types;
|
||||
|
||||
|
@ -23,7 +24,8 @@ CREATE TABLE test_datetime_types (timestamp timestamp,
|
|||
timestamp_with_timezone timestamp with time zone, date date, time time,
|
||||
interval interval) USING columnar;
|
||||
|
||||
COPY test_datetime_types FROM '@abs_srcdir@/data/datetime_types.csv' WITH CSV;
|
||||
\set datetime_types_csv_file :abs_srcdir '/data/datetime_types.csv'
|
||||
COPY test_datetime_types FROM :'datetime_types_csv_file' WITH CSV;
|
||||
|
||||
SELECT * FROM test_datetime_types;
|
||||
|
||||
|
@ -35,8 +37,9 @@ CREATE TYPE composite_type AS (a int, b text);
|
|||
CREATE TABLE test_enum_and_composite_types (enum enum_type,
|
||||
composite composite_type) USING columnar;
|
||||
|
||||
\set enum_and_composite_types_csv_file :abs_srcdir '/data/enum_and_composite_types.csv'
|
||||
COPY test_enum_and_composite_types FROM
|
||||
'@abs_srcdir@/data/enum_and_composite_types.csv' WITH CSV;
|
||||
:'enum_and_composite_types_csv_file' WITH CSV;
|
||||
|
||||
SELECT * FROM test_enum_and_composite_types;
|
||||
|
||||
|
@ -45,7 +48,8 @@ SELECT * FROM test_enum_and_composite_types;
|
|||
CREATE TABLE test_range_types (int4range int4range, int8range int8range,
|
||||
numrange numrange, tsrange tsrange) USING columnar;
|
||||
|
||||
COPY test_range_types FROM '@abs_srcdir@/data/range_types.csv' WITH CSV;
|
||||
\set range_types_csv_file :abs_srcdir '/data/range_types.csv'
|
||||
COPY test_range_types FROM :'range_types_csv_file' WITH CSV;
|
||||
|
||||
SELECT * FROM test_range_types;
|
||||
|
||||
|
@ -54,7 +58,8 @@ SELECT * FROM test_range_types;
|
|||
CREATE TABLE test_other_types (bool boolean, bytea bytea, money money,
|
||||
inet inet, bitstring bit varying(5), uuid uuid, json json) USING columnar;
|
||||
|
||||
COPY test_other_types FROM '@abs_srcdir@/data/other_types.csv' WITH CSV;
|
||||
\set other_types_csv_file :abs_srcdir '/data/other_types.csv'
|
||||
COPY test_other_types FROM :'other_types_csv_file' WITH CSV;
|
||||
|
||||
SELECT * FROM test_other_types;
|
||||
|
||||
|
@ -63,7 +68,8 @@ SELECT * FROM test_other_types;
|
|||
CREATE TABLE test_null_values (a int, b int[], c composite_type)
|
||||
USING columnar;
|
||||
|
||||
COPY test_null_values FROM '@abs_srcdir@/data/null_values.csv' WITH CSV;
|
||||
\set null_values_csv_file :abs_srcdir '/data/null_values.csv'
|
||||
COPY test_null_values FROM :'null_values_csv_file' WITH CSV;
|
||||
|
||||
SELECT * FROM test_null_values;
|
||||
|
|
@ -3,27 +3,29 @@
|
|||
--
|
||||
|
||||
-- COPY with incorrect delimiter
|
||||
COPY contestant FROM '@abs_srcdir@/data/contestants.1.csv'
|
||||
\set contestants_1_csv_file :abs_srcdir '/data/contestants.1.csv'
|
||||
COPY contestant FROM :'contestants_1_csv_file'
|
||||
WITH DELIMITER '|'; -- ERROR
|
||||
|
||||
-- COPY with invalid program
|
||||
COPY contestant FROM PROGRAM 'invalid_program' WITH CSV; -- ERROR
|
||||
|
||||
-- COPY into uncompressed table from file
|
||||
COPY contestant FROM '@abs_srcdir@/data/contestants.1.csv' WITH CSV;
|
||||
COPY contestant FROM :'contestants_1_csv_file' WITH CSV;
|
||||
|
||||
-- COPY into uncompressed table from program
|
||||
COPY contestant FROM PROGRAM 'cat @abs_srcdir@/data/contestants.2.csv' WITH CSV;
|
||||
\set cat_contestants_2_csv_file 'cat ' :abs_srcdir '/data/contestants.2.csv'
|
||||
COPY contestant FROM PROGRAM :'cat_contestants_2_csv_file' WITH CSV;
|
||||
|
||||
select
|
||||
version_major, version_minor, reserved_stripe_id, reserved_row_number
|
||||
from columnar_test_helpers.columnar_storage_info('contestant');
|
||||
|
||||
-- COPY into compressed table
|
||||
COPY contestant_compressed FROM '@abs_srcdir@/data/contestants.1.csv' WITH CSV;
|
||||
COPY contestant_compressed FROM :'contestants_1_csv_file' WITH CSV;
|
||||
|
||||
-- COPY into uncompressed table from program
|
||||
COPY contestant_compressed FROM PROGRAM 'cat @abs_srcdir@/data/contestants.2.csv'
|
||||
COPY contestant_compressed FROM PROGRAM :'cat_contestants_2_csv_file'
|
||||
WITH CSV;
|
||||
|
||||
select
|
|
@ -82,11 +82,16 @@ SELECT create_distributed_table('ads', 'company_id');
|
|||
SELECT create_distributed_table('clicks', 'company_id');
|
||||
SELECT create_distributed_table('impressions', 'company_id');
|
||||
|
||||
\copy companies from '@abs_srcdir@/data/companies.csv' with csv
|
||||
\copy campaigns from '@abs_srcdir@/data/campaigns.csv' with csv
|
||||
\copy ads from '@abs_srcdir@/data/ads.csv' with csv
|
||||
\copy clicks from '@abs_srcdir@/data/clicks.csv' with csv
|
||||
\copy impressions from '@abs_srcdir@/data/impressions.csv' with csv
|
||||
\set companies_csv_file :abs_srcdir '/data/companies.csv'
|
||||
\set campaigns_csv_file :abs_srcdir '/data/campaigns.csv'
|
||||
\set ads_csv_file :abs_srcdir '/data/ads.csv'
|
||||
\set clicks_csv_file :abs_srcdir '/data/clicks.csv'
|
||||
\set impressions_csv_file :abs_srcdir '/data/impressions.csv'
|
||||
COPY companies from :'companies_csv_file' with csv;
|
||||
COPY campaigns from :'campaigns_csv_file' with csv;
|
||||
COPY ads from :'ads_csv_file' with csv;
|
||||
COPY clicks from :'clicks_csv_file' with csv;
|
||||
COPY impressions from :'impressions_csv_file' with csv;
|
||||
|
||||
SELECT a.campaign_id,
|
||||
RANK() OVER (
|
||||
|
@ -174,11 +179,11 @@ CREATE TABLE impressions (
|
|||
REFERENCES ads (company_id, id)
|
||||
);
|
||||
|
||||
\copy companies from '@abs_srcdir@/data/companies.csv' with csv
|
||||
\copy campaigns from '@abs_srcdir@/data/campaigns.csv' with csv
|
||||
\copy ads from '@abs_srcdir@/data/ads.csv' with csv
|
||||
\copy clicks from '@abs_srcdir@/data/clicks.csv' with csv
|
||||
\copy impressions from '@abs_srcdir@/data/impressions.csv' with csv
|
||||
COPY companies from :'companies_csv_file' with csv;
|
||||
COPY campaigns from :'campaigns_csv_file' with csv;
|
||||
COPY ads from :'ads_csv_file' with csv;
|
||||
COPY clicks from :'clicks_csv_file' with csv;
|
||||
COPY impressions from :'impressions_csv_file' with csv;
|
||||
|
||||
SELECT create_distributed_table('companies', 'id');
|
||||
SELECT create_distributed_table('campaigns', 'company_id');
|
|
@ -34,8 +34,10 @@ SELECT master_create_empty_shard('lineitem_range') AS new_shard_id
|
|||
UPDATE pg_dist_shard SET shardminvalue = 8997, shardmaxvalue = 14947
|
||||
WHERE shardid = :new_shard_id;
|
||||
|
||||
\copy lineitem_range FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_range FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_range FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_range FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
|
||||
-- Run aggregate(distinct) on partition column for range partitioned table
|
||||
|
||||
|
@ -93,8 +95,8 @@ CREATE TABLE lineitem_hash (
|
|||
SET citus.shard_replication_factor TO 1;
|
||||
SELECT create_distributed_table('lineitem_hash', 'l_orderkey', 'hash');
|
||||
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
COPY lineitem_hash FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_hash FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
|
||||
-- aggregate(distinct) on partition column is allowed
|
||||
SELECT count(distinct l_orderkey) FROM lineitem_hash;
|
|
@ -20,7 +20,8 @@ CREATE TABLE aggregate_type (
|
|||
SELECT create_distributed_table('aggregate_type', 'float_value', 'append');
|
||||
SELECT master_create_empty_shard('aggregate_type') AS shardid \gset
|
||||
|
||||
copy aggregate_type FROM '@abs_srcdir@/data/agg_type.data' with (append_to_shard :shardid);
|
||||
\set agg_type_data_file :abs_srcdir '/data/agg_type.data'
|
||||
copy aggregate_type FROM :'agg_type_data_file' with (append_to_shard :shardid);
|
||||
|
||||
-- Test conversions using aggregates on floats and division
|
||||
|
|
@ -29,7 +29,8 @@ CREATE TABLE lineitem_alter (
|
|||
WITH ( fillfactor = 80 );
|
||||
SELECT create_distributed_table('lineitem_alter', 'l_orderkey', 'append');
|
||||
SELECT master_create_empty_shard('lineitem_alter') AS shardid \gset
|
||||
copy lineitem_alter FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
copy lineitem_alter FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
|
||||
-- verify that the storage options made it to the table definitions
|
||||
SELECT relname, reloptions FROM pg_class WHERE relname = 'lineitem_alter';
|
||||
|
@ -64,9 +65,9 @@ SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
|
|||
ALTER TABLE lineitem_alter ALTER COLUMN float_column SET DEFAULT 1;
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN int_column1 DROP DEFAULT;
|
||||
|
||||
-- \copy to verify that default values take effect
|
||||
-- COPY to verify that default values take effect
|
||||
SELECT master_create_empty_shard('lineitem_alter') as shardid \gset
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
|
||||
SELECT float_column, count(*) FROM lineitem_alter GROUP BY float_column;
|
||||
SELECT int_column1, count(*) FROM lineitem_alter GROUP BY int_column1;
|
||||
|
@ -79,11 +80,11 @@ SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineite
|
|||
-- Drop default so that NULLs will be inserted for this column
|
||||
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP DEFAULT;
|
||||
|
||||
-- \copy should fail because it will try to insert NULLs for a NOT NULL column
|
||||
-- COPY should fail because it will try to insert NULLs for a NOT NULL column
|
||||
-- Note, this operation will create a table on the workers but it won't be in the metadata
|
||||
BEGIN;
|
||||
SELECT master_create_empty_shard('lineitem_alter') as shardid \gset
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
END;
|
||||
|
||||
-- Verify that DROP NOT NULL works
|
||||
|
@ -91,9 +92,9 @@ END;
|
|||
ALTER TABLE lineitem_alter ALTER COLUMN int_column2 DROP NOT NULL;
|
||||
SELECT "Column", "Type", "Modifiers" FROM table_desc WHERE relid='public.lineitem_alter'::regclass;
|
||||
|
||||
-- \copy should succeed now
|
||||
-- COPY should succeed now
|
||||
SELECT master_create_empty_shard('lineitem_alter') as shardid \gset
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
copy lineitem_alter (l_orderkey, l_partkey, l_suppkey, l_linenumber, l_quantity, l_extendedprice, l_discount, l_tax, l_returnflag, l_linestatus, l_shipdate, l_commitdate, l_receiptdate, l_shipinstruct, l_shipmode, l_comment) FROM :'lineitem_1_data_file' with (delimiter '|', append_to_shard :shardid);
|
||||
SELECT count(*) from lineitem_alter;
|
||||
|
||||
-- Verify that SET DATA TYPE works
|
||||
|
@ -516,7 +517,8 @@ DROP TABLE trigger_table;
|
|||
|
||||
-- test ALTER TABLE ALL IN TABLESPACE
|
||||
-- we expect that it will warn out
|
||||
CREATE TABLESPACE super_fast_ssd LOCATION '@abs_srcdir@/data';
|
||||
\set tablespace_location :abs_srcdir '/data'
|
||||
CREATE TABLESPACE super_fast_ssd LOCATION :'tablespace_location';
|
||||
ALTER TABLE ALL IN TABLESPACE pg_default SET TABLESPACE super_fast_ssd;
|
||||
ALTER TABLE ALL IN TABLESPACE super_fast_ssd SET TABLESPACE pg_default;
|
||||
DROP TABLESPACE super_fast_ssd;
|
|
@ -15,8 +15,10 @@ SELECT create_distributed_table('users_table', 'user_id');
|
|||
CREATE TABLE events_table (user_id int, time timestamp, event_type int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('events_table', 'user_id');
|
||||
|
||||
\COPY users_table FROM '@abs_srcdir@/data/users_table.data' WITH CSV;
|
||||
\COPY events_table FROM '@abs_srcdir@/data/events_table.data' WITH CSV;
|
||||
\set users_table_data_file :abs_srcdir '/data/users_table.data'
|
||||
\set events_table_data_file :abs_srcdir '/data/events_table.data'
|
||||
COPY users_table FROM :'users_table_data_file' WITH CSV;
|
||||
COPY events_table FROM :'events_table_data_file' WITH CSV;
|
||||
|
||||
SET citus.shard_count = 96;
|
||||
CREATE SCHEMA subquery_and_ctes;
|
||||
|
@ -28,8 +30,8 @@ SELECT create_distributed_table('users_table', 'user_id');
|
|||
CREATE TABLE events_table (user_id int, time timestamp, event_type int, value_2 int, value_3 float, value_4 bigint);
|
||||
SELECT create_distributed_table('events_table', 'user_id');
|
||||
|
||||
\COPY users_table FROM '@abs_srcdir@/data/users_table.data' WITH CSV;
|
||||
\COPY events_table FROM '@abs_srcdir@/data/events_table.data' WITH CSV;
|
||||
COPY users_table FROM :'users_table_data_file' WITH CSV;
|
||||
COPY events_table FROM :'events_table_data_file' WITH CSV;
|
||||
|
||||
SET citus.shard_count TO DEFAULT;
|
||||
SET search_path TO DEFAULT;
|
||||
|
@ -68,8 +70,8 @@ INSERT INTO users_ref_test_table VALUES(4,'User_4',48);
|
|||
INSERT INTO users_ref_test_table VALUES(5,'User_5',49);
|
||||
INSERT INTO users_ref_test_table VALUES(6,'User_6',50);
|
||||
|
||||
\COPY users_table FROM '@abs_srcdir@/data/users_table.data' WITH CSV;
|
||||
\COPY events_table FROM '@abs_srcdir@/data/events_table.data' WITH CSV;
|
||||
COPY users_table FROM :'users_table_data_file' WITH CSV;
|
||||
COPY events_table FROM :'events_table_data_file' WITH CSV;
|
||||
|
||||
-- create indexes for
|
||||
CREATE INDEX is_index1 ON users_table(user_id);
|
|
@ -163,7 +163,7 @@ SELECT master_create_empty_shard('events') AS new_shard_id
|
|||
UPDATE pg_dist_shard SET shardminvalue = '(2,2000000001)', shardmaxvalue = '(2,4300000000)'
|
||||
WHERE shardid = :new_shard_id;
|
||||
|
||||
\COPY events FROM STDIN WITH CSV
|
||||
COPY events FROM STDIN WITH CSV;
|
||||
"(1,1001)",20001,click,1472807012
|
||||
"(1,1001)",20002,submit,1472807015
|
||||
"(1,1001)",20003,pay,1472807020
|
||||
|
@ -207,7 +207,7 @@ SELECT master_create_empty_shard('users') AS new_shard_id
|
|||
UPDATE pg_dist_shard SET shardminvalue = '(2,2000000001)', shardmaxvalue = '(2,4300000000)'
|
||||
WHERE shardid = :new_shard_id;
|
||||
|
||||
\COPY users FROM STDIN WITH CSV
|
||||
COPY users FROM STDIN WITH CSV;
|
||||
"(1,1001)",1472807115
|
||||
"(1,1002)",1472807215
|
||||
"(1,1003)",1472807315
|
||||
|
@ -290,8 +290,12 @@ SELECT master_create_empty_shard('orders_subquery') AS new_shard_id
|
|||
UPDATE pg_dist_shard SET shardminvalue = 8997, shardmaxvalue = 14947
|
||||
WHERE shardid = :new_shard_id;
|
||||
|
||||
\copy lineitem_subquery FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_subquery FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
COPY lineitem_subquery FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_subquery FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
|
||||
\copy orders_subquery FROM '@abs_srcdir@/data/orders.1.data' with delimiter '|'
|
||||
\copy orders_subquery FROM '@abs_srcdir@/data/orders.2.data' with delimiter '|'
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
COPY orders_subquery FROM :'orders_1_data_file' with delimiter '|';
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY orders_subquery FROM :'orders_2_data_file' with delimiter '|';
|
|
@ -29,8 +29,10 @@ CREATE TABLE lineitem_hash (
|
|||
|
||||
SELECT create_distributed_table('lineitem_hash', 'l_orderkey', 'hash');
|
||||
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.1.data' with delimiter '|'
|
||||
\copy lineitem_hash FROM '@abs_srcdir@/data/lineitem.2.data' with delimiter '|'
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_hash FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_hash FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
|
||||
ANALYZE lineitem_hash;
|
||||
|
|
@ -2,6 +2,11 @@
|
|||
-- MULTI_COPY
|
||||
--
|
||||
|
||||
-- set file paths
|
||||
\set customer1datafile :abs_srcdir '/data/customer.1.data'
|
||||
\set customer2datafile :abs_srcdir '/data/customer.2.data'
|
||||
\set customer3datafile :abs_srcdir '/data/customer.3.data'
|
||||
\set lineitem1datafile :abs_srcdir '/data/lineitem.1.data'
|
||||
|
||||
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 560000;
|
||||
|
||||
|
@ -97,13 +102,17 @@ WITH (DELIMITER ' ');
|
|||
SELECT count(*) FROM customer_copy_hash WHERE c_custkey = 9;
|
||||
|
||||
-- Test server-side copy from file
|
||||
COPY customer_copy_hash FROM '@abs_srcdir@/data/customer.2.data' WITH (DELIMITER '|');
|
||||
COPY customer_copy_hash FROM :'customer2datafile' WITH (DELIMITER '|');
|
||||
|
||||
-- Confirm that data was copied
|
||||
SELECT count(*) FROM customer_copy_hash;
|
||||
|
||||
-- Test client-side copy from file
|
||||
\copy customer_copy_hash FROM '@abs_srcdir@/data/customer.3.data' WITH (DELIMITER '|');
|
||||
-- \copy does not support variable interpolation. Hence we store and execute
|
||||
-- the query in two steps for interpolation to kick in.
|
||||
-- See https://stackoverflow.com/a/67642094/4576416 for details.
|
||||
\set client_side_copy_command '\\copy customer_copy_hash FROM ' :'customer3datafile' ' WITH (DELIMITER '''|''');'
|
||||
:client_side_copy_command
|
||||
|
||||
-- Confirm that data was copied
|
||||
SELECT count(*) FROM customer_copy_hash;
|
||||
|
@ -175,7 +184,7 @@ CREATE TABLE customer_copy_range (
|
|||
SELECT master_create_distributed_table('customer_copy_range', 'c_custkey', 'range');
|
||||
|
||||
-- Test COPY into empty range-partitioned table
|
||||
COPY customer_copy_range FROM '@abs_srcdir@/data/customer.1.data' WITH (DELIMITER '|');
|
||||
COPY customer_copy_range FROM :'customer1datafile' WITH (DELIMITER '|');
|
||||
|
||||
SELECT master_create_empty_shard('customer_copy_range') AS new_shard_id
|
||||
\gset
|
||||
|
@ -188,7 +197,7 @@ UPDATE pg_dist_shard SET shardminvalue = 501, shardmaxvalue = 1000
|
|||
WHERE shardid = :new_shard_id;
|
||||
|
||||
-- Test copy into range-partitioned table
|
||||
COPY customer_copy_range FROM '@abs_srcdir@/data/customer.1.data' WITH (DELIMITER '|');
|
||||
COPY customer_copy_range FROM :'customer1datafile' WITH (DELIMITER '|');
|
||||
|
||||
-- Check whether data went into the right shard (maybe)
|
||||
SELECT min(c_custkey), max(c_custkey), avg(c_custkey), count(*)
|
||||
|
@ -284,14 +293,14 @@ SELECT create_distributed_table('lineitem_copy_append', 'l_orderkey', 'append');
|
|||
|
||||
BEGIN;
|
||||
SELECT master_create_empty_shard('lineitem_copy_append') AS shardid \gset
|
||||
COPY lineitem_copy_append FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard :shardid);
|
||||
COPY lineitem_copy_append FROM :'lineitem1datafile' with (delimiter '|', append_to_shard :shardid);
|
||||
END;
|
||||
|
||||
SELECT count(*) FROM pg_dist_shard WHERE logicalrelid = 'lineitem_copy_append'::regclass;
|
||||
|
||||
-- trigger some errors on the append_to_shard option
|
||||
COPY lineitem_copy_append FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard 1);
|
||||
COPY lineitem_copy_append FROM '@abs_srcdir@/data/lineitem.1.data' with (delimiter '|', append_to_shard 560000);
|
||||
COPY lineitem_copy_append FROM :'lineitem1datafile' with (delimiter '|', append_to_shard 1);
|
||||
COPY lineitem_copy_append FROM :'lineitem1datafile' with (delimiter '|', append_to_shard 560000);
|
||||
|
||||
-- Test schema support on append partitioned tables
|
||||
CREATE SCHEMA append;
|
||||
|
@ -310,8 +319,8 @@ SELECT master_create_empty_shard('append.customer_copy') AS shardid1 \gset
|
|||
SELECT master_create_empty_shard('append.customer_copy') AS shardid2 \gset
|
||||
|
||||
-- Test copy from the master node
|
||||
COPY append.customer_copy FROM '@abs_srcdir@/data/customer.1.data' with (delimiter '|', append_to_shard :shardid1);
|
||||
COPY append.customer_copy FROM '@abs_srcdir@/data/customer.2.data' with (delimiter '|', append_to_shard :shardid2);
|
||||
COPY append.customer_copy FROM :'customer1datafile' with (delimiter '|', append_to_shard :shardid1);
|
||||
COPY append.customer_copy FROM :'customer2datafile' with (delimiter '|', append_to_shard :shardid2);
|
||||
|
||||
-- Test the content of the table
|
||||
SELECT min(c_custkey), max(c_custkey), avg(c_acctbal), count(*) FROM append.customer_copy;
|
|
@ -0,0 +1,28 @@
|
|||
--
|
||||
-- MULTI_LOAD_DATA
|
||||
--
|
||||
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY orders FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders FROM :'orders_2_data_file' with delimiter '|';
|
||||
|
||||
COPY orders_reference FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders_reference FROM :'orders_2_data_file' with delimiter '|';
|
||||
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
\set part_data_file :abs_srcdir '/data/part.data'
|
||||
\set supplier_data_file :abs_srcdir '/data/supplier.data'
|
||||
COPY customer FROM :'customer_1_data_file' with delimiter '|';
|
||||
COPY customer_append FROM :'customer_1_data_file' with (delimiter '|', append_to_shard 360006);
|
||||
COPY nation FROM :'nation_data_file' with delimiter '|';
|
||||
COPY part FROM :'part_data_file' with delimiter '|';
|
||||
COPY part_append FROM :'part_data_file' with (delimiter '|', append_to_shard 360009);
|
||||
COPY supplier FROM :'supplier_data_file' with delimiter '|';
|
||||
COPY supplier_single_shard FROM :'supplier_data_file' with delimiter '|';
|
|
@ -0,0 +1,8 @@
|
|||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY lineitem_hash_part FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_hash_part FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
COPY orders_hash_part FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders_hash_part FROM :'orders_2_data_file' with delimiter '|';
|
|
@ -0,0 +1,28 @@
|
|||
--
|
||||
-- MULTI_STAGE_MORE_DATA
|
||||
--
|
||||
|
||||
|
||||
SET citus.next_shard_id TO 280000;
|
||||
|
||||
|
||||
-- We load more data to customer and part tables to test distributed joins. The
|
||||
-- loading causes the planner to consider customer and part tables as large, and
|
||||
-- evaluate plans where some of the underlying tables need to be repartitioned.
|
||||
|
||||
\set customer_2_data_file :abs_srcdir '/data/customer.2.data'
|
||||
\set customer_3_data_file :abs_srcdir '/data/customer.3.data'
|
||||
\set part_more_data_file :abs_srcdir '/data/part.more.data'
|
||||
COPY customer FROM :'customer_2_data_file' with delimiter '|';
|
||||
COPY customer FROM :'customer_3_data_file' with delimiter '|';
|
||||
COPY part FROM :'part_more_data_file' with delimiter '|';
|
||||
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid1 \gset
|
||||
SELECT master_create_empty_shard('customer_append') AS shardid2 \gset
|
||||
|
||||
copy customer_append FROM :'customer_2_data_file' with (delimiter '|', append_to_shard :shardid1);
|
||||
copy customer_append FROM :'customer_3_data_file' with (delimiter '|', append_to_shard :shardid2);
|
||||
|
||||
SELECT master_create_empty_shard('part_append') AS shardid \gset
|
||||
|
||||
copy part_append FROM :'part_more_data_file' with (delimiter '|', append_to_shard :shardid);
|
|
@ -0,0 +1,56 @@
|
|||
--
|
||||
-- MULTI_MULTIUSER_LOAD_DATA
|
||||
--
|
||||
|
||||
-- Tests for loading data in a distributed cluster. Please note that the number
|
||||
-- of shards uploaded depends on two config values: citusdb.shard_replication_factor and
|
||||
-- citusdb.shard_max_size. These values are manually set in pg_regress.c. We also set
|
||||
-- the shard placement policy to the local-node-first policy as other regression
|
||||
-- tests expect the placements to be in that order.
|
||||
|
||||
SET citusdb.shard_placement_policy TO 'local-node-first';
|
||||
|
||||
-- load as superuser
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_1_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
|
||||
-- as user with ALL access
|
||||
SET ROLE full_access;
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
RESET ROLE;
|
||||
|
||||
-- as user with SELECT access, should fail
|
||||
SET ROLE read_access;
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
RESET ROLE;
|
||||
|
||||
-- as user with no access, should fail
|
||||
SET ROLE no_access;
|
||||
\set copy_command '\\COPY lineitem FROM ' :'lineitem_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
RESET ROLE;
|
||||
|
||||
SET ROLE full_access;
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
\set copy_command '\\COPY orders FROM ' :'orders_1_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY orders FROM ' :'orders_2_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
\set part_data_file :abs_srcdir '/data/part.data'
|
||||
\set supplier_data_file :abs_srcdir '/data/supplier.data'
|
||||
\set copy_command '\\COPY customer FROM ' :'customer_1_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY nation FROM ' :'nation_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY part FROM ' :'part_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
||||
\set copy_command '\\COPY supplier FROM ' :'supplier_data_file' ' with delimiter '''|''';'
|
||||
:copy_command
|
|
@ -0,0 +1,79 @@
|
|||
--
|
||||
-- MULTI_MX_COPY_DATA
|
||||
--
|
||||
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
|
||||
SET search_path TO citus_mx_test_schema;
|
||||
COPY nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema_join_1.nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema_join_1.nation_hash_2 FROM :'nation_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema_join_2.nation_hash FROM :'nation_data_file' with delimiter '|';
|
||||
|
||||
SET citus.shard_replication_factor TO 2;
|
||||
CREATE TABLE citus_mx_test_schema.nation_hash_replicated AS SELECT * FROM citus_mx_test_schema.nation_hash;
|
||||
SELECT create_distributed_table('citus_mx_test_schema.nation_hash_replicated', 'n_nationkey');
|
||||
COPY nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
|
||||
-- now try loading data from worker node
|
||||
\c - - - :worker_1_port
|
||||
SET search_path TO public;
|
||||
|
||||
\set lineitem_1_data_file :abs_srcdir '/data/lineitem.1.data'
|
||||
\set lineitem_2_data_file :abs_srcdir '/data/lineitem.2.data'
|
||||
COPY lineitem_mx FROM :'lineitem_1_data_file' with delimiter '|';
|
||||
COPY lineitem_mx FROM :'lineitem_2_data_file' with delimiter '|';
|
||||
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY citus_mx_test_schema.nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
|
||||
\c - - - :worker_2_port
|
||||
-- and use second worker as well
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY orders_mx FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders_mx FROM :'orders_2_data_file' with delimiter '|';
|
||||
COPY citus_mx_test_schema.nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
|
||||
-- get ready for the next test
|
||||
TRUNCATE orders_mx;
|
||||
|
||||
\c - - - :worker_2_port
|
||||
SET citus.log_local_commands TO ON;
|
||||
-- simulate the case where there is no connection slots available
|
||||
ALTER SYSTEM SET citus.local_shared_pool_size TO -1;
|
||||
SELECT pg_reload_conf();
|
||||
SELECT pg_sleep(0.1);
|
||||
show citus.local_shared_pool_size;
|
||||
|
||||
\set orders_1_data_file :abs_srcdir '/data/orders.1.data'
|
||||
\set orders_2_data_file :abs_srcdir '/data/orders.2.data'
|
||||
COPY orders_mx FROM :'orders_1_data_file' with delimiter '|';
|
||||
COPY orders_mx FROM :'orders_2_data_file' with delimiter '|';
|
||||
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
COPY citus_mx_test_schema.nation_hash_replicated FROM :'nation_data_file' with delimiter '|';
|
||||
|
||||
-- set it back
|
||||
ALTER SYSTEM RESET citus.local_shared_pool_size;
|
||||
SELECT pg_reload_conf();
|
||||
SELECT pg_sleep(0.1);
|
||||
show citus.local_shared_pool_size;
|
||||
|
||||
-- These copies were intended to test copying data to single sharded table from
|
||||
-- worker nodes, yet in order to remove broadcast logic related codes we change
|
||||
-- the table to reference table and copy data from master. Should be updated
|
||||
-- when worker nodes gain capability to run dml commands on reference tables.
|
||||
\c - - - :master_port
|
||||
SET search_path TO public;
|
||||
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
\set nation_data_file :abs_srcdir '/data/nation.data'
|
||||
\set part_data_file :abs_srcdir '/data/part.data'
|
||||
\set supplier_data_file :abs_srcdir '/data/supplier.data'
|
||||
COPY customer_mx FROM :'customer_1_data_file' with delimiter '|';
|
||||
COPY nation_mx FROM :'nation_data_file' with delimiter '|';
|
||||
COPY part_mx FROM :'part_data_file' with delimiter '|';
|
||||
COPY supplier_mx FROM :'supplier_data_file' with delimiter '|';
|
|
@ -69,11 +69,13 @@ CREATE TABLE multi_outer_join_third_reference
|
|||
t_comment varchar(117) not null
|
||||
);
|
||||
SELECT create_reference_table('multi_outer_join_third_reference');
|
||||
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-1-10.data' with delimiter '|'
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\set customer_1_10_data :abs_srcdir '/data/customer-1-10.data'
|
||||
\set customer_11_20_data :abs_srcdir '/data/customer-11-20.data'
|
||||
\set customer_1_15_data :abs_srcdir '/data/customer-1-15.data'
|
||||
COPY multi_outer_join_left FROM :'customer_1_10_data' with delimiter '|';
|
||||
COPY multi_outer_join_left FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right FROM :'customer_1_15_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_reference FROM :'customer_1_15_data' with delimiter '|';
|
||||
|
||||
-- Make sure we do not crash if one table has no shards
|
||||
SELECT
|
||||
|
@ -87,8 +89,9 @@ FROM
|
|||
multi_outer_join_third a LEFT JOIN multi_outer_join_right_reference b ON (r_custkey = t_custkey);
|
||||
|
||||
-- Third table is a single shard table with all data
|
||||
\copy multi_outer_join_third FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\copy multi_outer_join_third_reference FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\set customer_1_30_data :abs_srcdir '/data/customer-1-30.data'
|
||||
COPY multi_outer_join_third FROM :'customer_1_30_data' with delimiter '|';
|
||||
COPY multi_outer_join_third_reference FROM :'customer_1_30_data' with delimiter '|';
|
||||
|
||||
-- Regular outer join should return results for all rows
|
||||
SELECT
|
||||
|
@ -167,7 +170,8 @@ FROM
|
|||
|
||||
|
||||
-- Turn the right table into a large table
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\set customer_21_30_data :abs_srcdir '/data/customer-21-30.data'
|
||||
COPY multi_outer_join_right FROM :'customer_21_30_data' with delimiter '|';
|
||||
|
||||
|
||||
-- Shards do not have 1-1 matching. We should error here.
|
||||
|
@ -181,11 +185,13 @@ TRUNCATE multi_outer_join_left;
|
|||
TRUNCATE multi_outer_join_right;
|
||||
|
||||
-- reload shards with 1-1 matching
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-subset-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\set customer_subset_11_20_data :abs_srcdir '/data/customer-subset-11-20.data'
|
||||
COPY multi_outer_join_left FROM :'customer_subset_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_left FROM :'customer_21_30_data' with delimiter '|';
|
||||
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right FROM '@abs_srcdir@/data/customer-subset-21-30.data' with delimiter '|'
|
||||
\set customer_subset_21_30_data :abs_srcdir '/data/customer-subset-21-30.data'
|
||||
COPY multi_outer_join_right FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right FROM :'customer_subset_21_30_data' with delimiter '|';
|
||||
|
||||
-- multi_outer_join_third is a single shard table
|
||||
-- Regular left join should work as expected
|
||||
|
@ -447,7 +453,8 @@ ORDER BY cnt DESC, l1.l_custkey DESC
|
|||
LIMIT 20;
|
||||
|
||||
-- Add a shard to the left table that overlaps with multiple shards in the right
|
||||
\copy multi_outer_join_left FROM '@abs_srcdir@/data/customer.1.data' with delimiter '|'
|
||||
\set customer_1_data_file :abs_srcdir '/data/customer.1.data'
|
||||
COPY multi_outer_join_left FROM :'customer_1_data_file' with delimiter '|';
|
||||
|
||||
|
||||
-- All outer joins should error out
|
||||
|
@ -483,7 +490,7 @@ SET citus.shard_replication_factor to 1;
|
|||
|
||||
SELECT create_distributed_table('left_values', 'val');
|
||||
|
||||
\copy left_values from stdin
|
||||
COPY left_values from stdin;
|
||||
1
|
||||
2
|
||||
3
|
||||
|
@ -495,7 +502,7 @@ CREATE TABLE right_values(val int);
|
|||
|
||||
SELECT create_distributed_table('right_values', 'val');
|
||||
|
||||
\copy right_values from stdin
|
||||
COPY right_values from stdin;
|
||||
2
|
||||
3
|
||||
4
|
|
@ -64,12 +64,15 @@ FROM
|
|||
multi_outer_join_left_hash a LEFT JOIN multi_outer_join_third_reference b ON (l_custkey = t_custkey);
|
||||
|
||||
-- Left table is a large table
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-1-10.data' with delimiter '|'
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\set customer_1_10_data :abs_srcdir '/data/customer-1-10.data'
|
||||
\set customer_11_20_data :abs_srcdir '/data/customer-11-20.data'
|
||||
COPY multi_outer_join_left_hash FROM :'customer_1_10_data' with delimiter '|';
|
||||
COPY multi_outer_join_left_hash FROM :'customer_11_20_data' with delimiter '|';
|
||||
|
||||
-- Right table is a small table
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\set customer_1_15_data :abs_srcdir '/data/customer-1-15.data'
|
||||
COPY multi_outer_join_right_reference FROM :'customer_1_15_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_hash FROM :'customer_1_15_data' with delimiter '|';
|
||||
|
||||
-- Make sure we do not crash if one table has data
|
||||
SELECT
|
||||
|
@ -83,8 +86,9 @@ FROM
|
|||
multi_outer_join_third_reference a LEFT JOIN multi_outer_join_right_reference b ON (r_custkey = t_custkey);
|
||||
|
||||
-- Third table is a single shard table with all data
|
||||
\copy multi_outer_join_third_reference FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-1-30.data' with delimiter '|'
|
||||
\set customer_1_30_data :abs_srcdir '/data/customer-1-30.data'
|
||||
COPY multi_outer_join_third_reference FROM :'customer_1_30_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_hash FROM :'customer_1_30_data' with delimiter '|';
|
||||
|
||||
|
||||
-- Regular outer join should return results for all rows
|
||||
|
@ -164,7 +168,8 @@ FROM
|
|||
|
||||
|
||||
-- load some more data
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
\set customer_21_30_data :abs_srcdir '/data/customer-21-30.data'
|
||||
COPY multi_outer_join_right_reference FROM :'customer_21_30_data' with delimiter '|';
|
||||
|
||||
-- Update shards so that they do not have 1-1 matching, triggering an error.
|
||||
UPDATE pg_dist_shard SET shardminvalue = '2147483646' WHERE shardid = 1260006;
|
||||
|
@ -180,14 +185,14 @@ UPDATE pg_dist_shard SET shardmaxvalue = '-1073741825' WHERE shardid = 1260006;
|
|||
TRUNCATE multi_outer_join_left_hash, multi_outer_join_right_hash, multi_outer_join_right_reference;
|
||||
|
||||
-- reload shards with 1-1 matching
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-1-15.data' with delimiter '|'
|
||||
\copy multi_outer_join_left_hash FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
COPY multi_outer_join_left_hash FROM :'customer_1_15_data' with delimiter '|';
|
||||
COPY multi_outer_join_left_hash FROM :'customer_21_30_data' with delimiter '|';
|
||||
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_reference FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
COPY multi_outer_join_right_reference FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_reference FROM :'customer_21_30_data' with delimiter '|';
|
||||
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-11-20.data' with delimiter '|'
|
||||
\copy multi_outer_join_right_hash FROM '@abs_srcdir@/data/customer-21-30.data' with delimiter '|'
|
||||
COPY multi_outer_join_right_hash FROM :'customer_11_20_data' with delimiter '|';
|
||||
COPY multi_outer_join_right_hash FROM :'customer_21_30_data' with delimiter '|';
|
||||
|
||||
-- multi_outer_join_third_reference is a single shard table
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
\set test_tablespace :abs_srcdir '/tmp_check/ts0'
|
||||
CREATE TABLESPACE test_tablespace LOCATION :'test_tablespace';
|
||||
\c - - - :worker_1_port
|
||||
\set test_tablespace :abs_srcdir '/tmp_check/ts1'
|
||||
CREATE TABLESPACE test_tablespace LOCATION :'test_tablespace';
|
||||
\c - - - :worker_2_port
|
||||
\set test_tablespace :abs_srcdir '/tmp_check/ts2'
|
||||
CREATE TABLESPACE test_tablespace LOCATION :'test_tablespace';
|
Loading…
Reference in New Issue