Skip to content

Conversation

@yjhjstz
Copy link
Member

@yjhjstz yjhjstz commented Jan 11, 2026

The storage type detection logic failed to properly identify mixed storage when foreign and non-foreign partitions coexisted, leading to incorrect metadata that could cause issues with scan type selection and query planning.

Fixes #ISSUE_Number

What does this PR do?

Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change (fix or feature with breaking changes)
  • Documentation update

Breaking Changes

Test Plan

  • Unit tests added/updated
  • Integration tests added/updated
  • Passed make installcheck
  • Passed make -C src/test installcheck-cbdb-parallel

Impact

Performance:

User-facing changes:

Dependencies:

Checklist

Additional Context

CI Skip Instructions


…gn partitions

The storage type detection logic failed to properly identify mixed storage when
foreign and non-foreign partitions coexisted, leading to incorrect metadata that
could cause issues with scan type selection and query planning.
Copilot AI review requested due to automatic review settings January 11, 2026 15:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a bug in ORCA's storage type detection for partitioned tables that contain a mix of foreign and non-foreign partitions. The issue caused incorrect metadata generation when such mixed storage configurations existed, which could lead to problems with scan type selection and query planning.

Changes:

  • Added logic to detect and mark mixed storage when foreign partitions are encountered after non-foreign partitions (or vice versa)
  • Converted an independent if statement to an else if to create a proper conditional chain for storage type transitions
  • Improved handling of the initial state when the first partition encountered is foreign

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

// 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants