mirror of https://github.com/citusdata/citus.git
Improve single hash-repartitioning with numeric (or non-int) types
We used to treat the shard interval array that we passed as numeric[]. However, it should be int[], as the shard ranges are int[].pull/3467/head
parent
3826e81056
commit
c7e2309f4c
|
@ -4278,13 +4278,17 @@ CreateMapQueryString(MapMergeJob *mapMergeJob, Task *filterTask,
|
||||||
ShardInterval **intervalArray = mapMergeJob->sortedShardIntervalArray;
|
ShardInterval **intervalArray = mapMergeJob->sortedShardIntervalArray;
|
||||||
uint32 intervalCount = mapMergeJob->partitionCount;
|
uint32 intervalCount = mapMergeJob->partitionCount;
|
||||||
|
|
||||||
if (partitionType != SINGLE_HASH_PARTITION_TYPE && partitionType !=
|
if (partitionType == DUAL_HASH_PARTITION_TYPE)
|
||||||
RANGE_PARTITION_TYPE)
|
|
||||||
{
|
{
|
||||||
partitionColumnType = INT4OID;
|
partitionColumnType = INT4OID;
|
||||||
partitionColumnTypeMod = get_typmodin(INT4OID);
|
partitionColumnTypeMod = get_typmodin(INT4OID);
|
||||||
intervalArray = GenerateSyntheticShardIntervalArray(intervalCount);
|
intervalArray = GenerateSyntheticShardIntervalArray(intervalCount);
|
||||||
}
|
}
|
||||||
|
else if (partitionType == SINGLE_HASH_PARTITION_TYPE)
|
||||||
|
{
|
||||||
|
partitionColumnType = INT4OID;
|
||||||
|
partitionColumnTypeMod = get_typmodin(INT4OID);
|
||||||
|
}
|
||||||
|
|
||||||
ArrayType *splitPointObject = SplitPointObject(intervalArray, intervalCount);
|
ArrayType *splitPointObject = SplitPointObject(intervalArray, intervalCount);
|
||||||
StringInfo splitPointString = ArrayObjectToString(splitPointObject,
|
StringInfo splitPointString = ArrayObjectToString(splitPointObject,
|
||||||
|
|
|
@ -493,10 +493,24 @@ DETAIL: Creating dependency on merge taskId 20
|
||||||
ERROR: the query contains a join that requires repartitioning
|
ERROR: the query contains a join that requires repartitioning
|
||||||
HINT: Set citus.enable_repartition_joins to on to enable repartitioning
|
HINT: Set citus.enable_repartition_joins to on to enable repartitioning
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
CREATE TABLE test_numeric (a numeric, b numeric);
|
||||||
|
SET citus.shard_count TO 7;
|
||||||
|
SELECT create_distributed_table('test_numeric', 'a');
|
||||||
|
create_distributed_table
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
INSERT INTO test_numeric SELECT i,i FROM generate_series(0,1000) i;
|
||||||
|
SET citus.enable_single_hash_repartition_joins TO ON;
|
||||||
|
SET citus.enable_repartition_joins TO on;
|
||||||
|
SELECT count(*) FROM test_numeric t1 JOIN test_numeric as t2 ON (t1.a = t2.b);
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1001
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
RESET search_path;
|
RESET search_path;
|
||||||
DROP SCHEMA single_hash_repartition CASCADE;
|
DROP SCHEMA single_hash_repartition CASCADE;
|
||||||
NOTICE: drop cascades to 3 other objects
|
|
||||||
DETAIL: drop cascades to table single_hash_repartition.single_hash_repartition_first
|
|
||||||
drop cascades to table single_hash_repartition.single_hash_repartition_second
|
|
||||||
drop cascades to table single_hash_repartition.ref_table
|
|
||||||
SET citus.enable_single_hash_repartition_joins TO OFF;
|
SET citus.enable_single_hash_repartition_joins TO OFF;
|
||||||
|
|
|
@ -137,6 +137,16 @@ WHERE
|
||||||
|
|
||||||
RESET client_min_messages;
|
RESET client_min_messages;
|
||||||
|
|
||||||
|
CREATE TABLE test_numeric (a numeric, b numeric);
|
||||||
|
SET citus.shard_count TO 7;
|
||||||
|
SELECT create_distributed_table('test_numeric', 'a');
|
||||||
|
|
||||||
|
INSERT INTO test_numeric SELECT i,i FROM generate_series(0,1000) i;
|
||||||
|
SET citus.enable_single_hash_repartition_joins TO ON;
|
||||||
|
SET citus.enable_repartition_joins TO on;
|
||||||
|
SELECT count(*) FROM test_numeric t1 JOIN test_numeric as t2 ON (t1.a = t2.b);
|
||||||
|
|
||||||
|
SET client_min_messages TO ERROR;
|
||||||
RESET search_path;
|
RESET search_path;
|
||||||
DROP SCHEMA single_hash_repartition CASCADE;
|
DROP SCHEMA single_hash_repartition CASCADE;
|
||||||
SET citus.enable_single_hash_repartition_joins TO OFF;
|
SET citus.enable_single_hash_repartition_joins TO OFF;
|
||||||
|
|
Loading…
Reference in New Issue