Skip to content

PHOENIX-7955 CREATE TABLE IF NOT EXISTS should not mutate existing HBase table properties#2569

Open
PDavid wants to merge 2 commits into
apache:masterfrom
PDavid:PHOENIX-7955-create-existing-table-hbase-properties
Open

PHOENIX-7955 CREATE TABLE IF NOT EXISTS should not mutate existing HBase table properties#2569
PDavid wants to merge 2 commits into
apache:masterfrom
PDavid:PHOENIX-7955-create-existing-table-hbase-properties

Conversation

@PDavid

@PDavid PDavid commented Jul 7, 2026

Copy link
Copy Markdown

Why are the changes needed?

Problem

When CREATE TABLE IF NOT EXISTS was executed against an already-existing table, Phoenix would overwrite the HBase-level table and column family properties (e.g. REGION_REPLICATION, VERSIONS, TTL) with the values from the new DDL statement. This is unexpected - IF NOT EXISTS should be a no-op if the table already exists.

(Please see the ticket about reproduction steps.)

Fix

Added new method parameter boolean createIfNotExists to ConnectionQueryServices.createTable() method to signal in CREATE statement was issued with IF NOT EXISTS.

  • When CREATE TABLE IF NOT EXISTS was executed and table already exists:
    • and the table is already a Phoenix-managed table we return early, don't modify HBase table-level properties.
    • and plain HBase table being mapped we fall through, add coprocessors via modifyTable.
  • When CREATE TABLE IF NOT EXISTS was executed and table DOES NOT exists, no change.
  • When CREATE TABLE without IF NOT EXISTS is executed, no change.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Added new test in CreateTableIT which reproduces the problem and verifies the fix.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Opus 4.6 noreply@anthropic.com

@PDavid
PDavid force-pushed the PHOENIX-7955-create-existing-table-hbase-properties branch from da941d5 to 2419cbe Compare July 7, 2026 14:31
@PDavid
PDavid marked this pull request as draft July 10, 2026 09:10
PDavid and others added 2 commits July 20, 2026 14:44
…ase table properties

Problem:
When CREATE TABLE IF NOT EXISTS was executed against an already-existing table, Phoenix would overwrite the HBase-level table and column family properties (e.g. REGION_REPLICATION, VERSIONS, TTL) with the values from the new DDL statement. This is unexpected - IF NOT EXISTS should be a no-op if the table already exists.

Fix:
In ConnectionQueryServicesImpl changed ensureTableCreated call for TABLE types - passes modifyExistingMetaData = false when the table type is TABLE, so existing properties are not overwritten.

Testing:
Added new test in CreateTableIT which reproduces the problem and verifies the fix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@PDavid
PDavid force-pushed the PHOENIX-7955-create-existing-table-hbase-properties branch from 7781f28 to 45f5777 Compare July 21, 2026 11:54
@PDavid
PDavid marked this pull request as ready for review July 21, 2026 13:22
@PDavid
PDavid requested a review from richardantal July 21, 2026 13:23
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