Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ao set ao aoco-related cherry-picks #886

Merged
merged 8 commits into from
Jan 25, 2025
Merged

Conversation

reshke
Copy link
Contributor

@reshke reshke commented Jan 22, 2025

Fixes #ISSUE_Number

What does this PR do?

needed for #859

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


@my-ship-it my-ship-it added the cherry-pick cherry-pick upstream commts label Jan 22, 2025
@reshke reshke force-pushed the ao_set_ao_aoco branch 3 times, most recently from 12e5b7c to afab447 Compare January 23, 2025 08:07
huansong and others added 7 commits January 24, 2025 06:56
Currently adding support for the following cases:

```
CREATE TABLE foo (appendonly=true);
ALTER TABLE foo SET ACCESS METHOD ao_column;
-- Or:
ALTER TABLE foo SET WITH (appendonly=true, orientation=column);
```

Similar to other variations of ATSETAM commands, user can also
specify reloptions in a WITH clause, such as:

```
ALTER TABLE foo SET ACCESS METHOD ao_column WITH (blocksize=65536);
```

If no reloptions are given, the new AOCO table will use the existing
table-level options for its column encoding options. If any reloption
is given in the WITH clause, it will be recorded in the catalog and
then used for the column encoding option too.

Note that there was once a thought to support specifying column-level
encoding in the ATSETAM command, but was abandoned because there exists
better alternatives. Discussions see https://groups.google.com/a/greenplum.org/g/gpdb-dev/c/NaNH6TssgA8
Previously, we only remove the existing reloptions when the AM is
changing between Heap and AO/AOCO, since the reloptions are mutually
exclusive between them.

Now we do the same when changing AM between AO and AOCO too, for
the following reasons:
1. Keep behaviors consistent.
2. Even between AO and AOCO there's certain reloption that's not
   applicable to one of them: e.g. 'compresslevel=rle_type' only
   applies to AOCO but not AO.
3. If customer specifies reloptions themselves within the ATSETAM
   statement, we then need to pick and remove those conflicting
   with the new reloptions. Too much complicities will be introduced.

With this change, we also refactored ATExecSetRelOptions a little bit
since now we don't rely on it to remove reloptions. And it becomes
more readable too.
As part of the ATSETAM support, this commit adds support for
changing AM of a table from AOCO to AO. E.g.:

```
CREATE TABLE foo (appendonly=true, orientation=column);
ALTER TABLE foo SET ACCESS METHOD ao_row;
-- Or:
ALTER TABLE foo SET WITH (appendoptimized=true);
```

Optionally, user can specify reloptions in a WITH clause too, e.g.:

```
ALTER TABLE foo SET ACCESS METHOD ao_row WITH (compresslevel=7);
```

Additionally for the regress test:
1. Add more cases for altering with the same existing AM;
2. Add more cases for the "Final scenario" in the test.
It is found that when changing from AO to AOCO we cannot specify
`compresstype=rle_type` which would complain that it is not
applicable to AO table, despite that it should be a valid usage.

This is because during setting new reloptions, we miss the
information about the new AM being AOCO, and the code behavior
is to validate the reloptions as AO tables.

Fixing it by passing the new AM into ATExecSetRelOptions() based
on which we can validate the reloptions. If there is no AM
change, an InvalidOid will be passed in and we will use the
current table AM to validate the reloptions.
Currently adding support for the following cases:

```
CREATE TABLE foo;
ALTER TABLE foo SET ACCESS METHOD ao_column;
-- Or:
ALTER TABLE foo SET WITH (appendonly=true, orientation=column);
```

Similar to other variations of ATSETAM commands, user can also
specify reloptions in a WITH clause, such as:

```
ALTER TABLE foo SET ACCESS METHOD ao_column WITH (blocksize=65536);
```

If no reloptions are given, the new AOCO table will use the default
reloptions for its column encoding options. If any reloption
is given in the WITH clause, it will be recorded in the catalog and
then used for the column encoding option too.
As part of the ATSETAM support, this commit adds support for
changing AM of a table from AOCO to heap. E.g.:

```
CREATE TABLE foo (appendonly=true, orientation=column);
ALTER TABLE foo SET ACCESS METHOD heap;
-- Or:
ALTER TABLE foo SET WITH (appendonly=false);
```

Optionally, user can specify reloptions in a WITH clause too, e.g.:

```
ALTER TABLE foo SET ACCESS METHOD heap WITH (fillfactor=70);
```
@reshke reshke force-pushed the ao_set_ao_aoco branch 5 times, most recently from 7f45a8d to a04125e Compare January 25, 2025 10:37
@reshke reshke merged commit f375254 into apache:main Jan 25, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick cherry-pick upstream commts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants