Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/backend/gpopt/translate/CTranslatorRelcacheToDXL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3147,18 +3147,36 @@ CTranslatorRelcacheToDXL::RetrieveStorageTypeForPartitionedTable(Relation rel)
"Queries with partitions of greenplum_fdw are not supported"));
}
GPOS_DELETE(fdw_name_str);

// Check for mixed storage before continuing
// If we already encountered non-foreign partitions, mark as mixed
if (rel_storage_type != IMDRelation::ErelstorageSentinel &&
rel_storage_type != IMDRelation::ErelstorageForeign)
{
// Already have non-foreign partition(s), now found foreign → mixed
rel_storage_type = IMDRelation::ErelstorageMixedPartitioned;
}
else if (rel_storage_type == IMDRelation::ErelstorageSentinel)
{
// First partition is foreign
rel_storage_type = IMDRelation::ErelstorageForeign;
}
continue;
}
all_foreign = false;
if (rel_storage_type == IMDRelation::ErelstorageSentinel)
{
rel_storage_type = child_storage;
}

else if (rel_storage_type == IMDRelation::ErelstorageForeign)
{
// Previously had foreign partition(s), now found non-foreign → mixed
rel_storage_type = IMDRelation::ErelstorageMixedPartitioned;
}
// mark any partitioned table with supported partitions of mixed storage types,
// this is more conservative for certain skans (eg: we can't do an index scan if any
// partition is ao, we must only do a sequential or bitmap scan)
if (rel_storage_type != child_storage)
else if (rel_storage_type != child_storage)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but in which cases this logic failed? For me it should always set ErelstorageMixedPartitioned in a case of mixed storage options

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create table part (a int, b int) partition by range (b);
create external table p1_e (a int, b int) location ('file://@hostname@@abs_srcdir@/data/part1.csv') format 'csv';
create external table p2_e (a int, b int) location ('file://@hostname@@abs_srcdir@/data/part2.csv') format 'csv';
alter table part attach partition p1_e for values from (0) to (10);
alter table part attach partition p2_e for values from (10) to (19);
analyze part;
create table p3 (a int, b int) distributed by (a);
create table p4 (a int, b int) distributed by (a);
alter table part attach partition p3 for values from (20) to (30);
alter table part attach partition p4 for values from (30) to (40);
insert into part select i,i from generate_series(25,35)i;
analyze part;

you can test this case.

{
rel_storage_type = IMDRelation::ErelstorageMixedPartitioned;
}
Expand Down
Loading