Skip to content

[fix](information_schema) List OLAP tables without partitions in table_options - #70522

Merged
yiguolei merged 1 commit into
apache:masterfrom
morningman:fix-table-options-zero-partition
Nov 18, 2026
Merged

yiguolei merged 1 commit into
apache:masterfrom
morningman:fix-table-options-zero-partition

Conversation

@morningman

Copy link
Copy Markdown
Contributor

Background

information_schema.table_options describes each internal OLAP table: its key model (TABLE_MODEL, TABLE_MODEL_KEY), distribution, bucket and partition counts, and, since #56122, its partitioning (PARTITION_METHOD, PARTITION_EXPRESSION, PARTITION_KEY, RANGE). #56122 made the FE emit one row per partition, so a table with N partitions has N rows that repeat the table-level columns, and an unpartitioned table, which always has its one implicit partition, has one row. A RANGE or LIST partitioned table can have no partition at all: an AUTO PARTITION table before its first load, or a table created with PARTITION BY RANGE(k) () before any ADD PARTITION.

What problem does this PR solve?

Issue Number: None
Related PR: #56122 (introduced the bug)
PR Type: Bugfix

Problem Summary:

On master, a partitioned OLAP table with no partition has no row in information_schema.table_options, although information_schema.tables lists it. Clients that read the key model from this table lose such tables; the OpenMetadata Doris connector, for example, builds primary keys from TABLE_MODEL and TABLE_MODEL_KEY and finds none for an AUTO PARTITION table that has not been loaded yet. This PR keeps one row per partition and adds one table-level row, with PARTITION_NUM 0, for a table without partitions.

Details

  • Frequency: Always. CREATE TABLE t (dt DATETIME NOT NULL, k INT NOT NULL) UNIQUE KEY(dt, k) AUTO PARTITION BY RANGE (date_trunc(dt, 'day')) () DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ("replication_num" = "1"); SELECT * FROM information_schema.table_options WHERE TABLE_NAME = 't'; returns an empty set until a load creates the first partition.
  • Root cause: MetadataGenerator.tableOptionsForInternalCatalog builds every row inside the loop over OlapTable.getAllPartitions() ([Enhancement](schema_table)Improve the field information of the information_schema.table_options table. #56122). For a table with no partition the loop body never runs, so the table contributes no row.
  • Why existing tests missed it: Unit tests: no FE unit test read table_options. Regression: query_p0/system/test_table_options (P0 and cloud P0) has RANGE and LIST tables with three partitions each and unpartitioned tables, which always have one partition; none of its tables has zero partitions, so the .out that [Enhancement](schema_table)Improve the field information of the information_schema.table_options table. #56122 regenerated could not show a missing table.
  • Fix: when getAllPartitions() is empty, emit one row before the per-partition loop. Its PARTITION_EXPRESSION is the partition columns, the value the table's rows carry once partitions exist, rather than the string NULL that marks an unpartitioned table; PARTITION_KEY and RANGE are empty, as for unpartitioned tables.
  • Other paths and branches: information_schema.partitions lists partitions, so a table without partitions has no row there by design. table_properties, information_schema.tables, SHOW TABLE STATUS, and the external-catalog rows of table_options are one row per table: not affected. Cloud mode runs the same code. branch-3.1, branch-4.0, branch-4.1, and branch-4.2 lack [Enhancement](schema_table)Improve the field information of the information_schema.table_options table. #56122 and emit one row per table, so only master has the bug.

Testing

  • Regression query_p0/system/test_table_options: three tables without partitions were added (AUTO RANGE, AUTO LIST, and PARTITION BY RANGE(k1) ()); select_check_1 and select_check_2 list them, and the regenerated .out adds only their six rows. On the unfixed FE the suite fails (Check tag 'select_check_1' failed, line 2 ... Expect cell is: auto_list_table_no_partition But real is: duplicate_table); on the fixed FE it passes. The privilege checks (select_check_3 to select_check_5) are unchanged.
  • FE UT TableOptionsMetadataGeneratorTest checks the single row of an AUTO RANGE table without partitions (PARTITION_NUM 0, PARTITION_EXPRESSION dt, empty PARTITION_KEY and RANGE) and that a LIST table with two partitions keeps one row per partition. With the fix: 2 tests, 0 failures; with MetadataGenerator reverted to master, testTableWithoutPartitionHasOneRow fails with expected: <1> but was: <0>.
  • Both ran locally. The regression suite ran on a single-FE, single-BE cluster: an FE built from this PR and a BE built from 6991e76 (the change is FE-only); the unfixed FE is the same jar with MetadataGenerator compiled from master.

Notes for Reviewers

Most of the MetadataGenerator diff moves the table-level columns, TABLE_CATALOG through PARTITION_METHOD, into newTableOptionsRow, which the new row and the per-partition rows both use. The moved lines are unchanged except that the comment key columTyp now reads TABLE_MODEL_KEY; git diff --color-moved shows the move.

Release note

None

Check List (For Author)

  • Behavior changed: No
  • Does this need documentation: No
  • Pre-submission status: Ready

AI Disclosure

@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Static review of PR #70522 at bb7447d82e42f884c7843015685ee99a9700dffa: no new actionable findings. No existing inline findings were present or independently confirmed as blocking. All four changed files and the relevant producer/consumer, initialization, locking and test paths were inspected.

The change restores one table-options row for an internal OLAP table with no partitions and preserves one row per partition otherwise. The inspected flow is:

information_schema.table_options
  -> BE SchemaTableOptionsScanner / SchemaPerDbScanner
  -> FE fetchSchemaTableData -> TABLE_OPTIONS dispatch
  -> tableOptionsForInternalCatalog (table read lock)
     -> empty: one table-level row
     -> nonempty: existing per-partition rows
  -> thirteen typed cells -> BE block
Critical checkpoint Conclusion
Goal and supporting tests The empty branch emits a complete row with partition count 0. Added FE tests cover empty AUTO RANGE and populated LIST; regression covers empty AUTO RANGE, AUTO LIST and manual RANGE. Inspected, not executed.
Scope and reuse Focused branch plus a shared helper; moved table-level cells retain their values.
Concurrency and locking Request-local rows; existing table read lock covers the collection and metadata. DDL publication uses the write lock. No new nested lock, RPC, IO or journal wait inside the lock.
Lifecycle and initialization Keys, partition columns and default distribution exist before catalog publication and do not depend on a partition. No new static state, async work or resource lifetime.
Configuration None added.
Compatibility Existing thirteen-cell schema and types retained; no new storage format or function symbol.
Thrift/protobuf field IDs No definition changes; cross-branch ID checks are inapplicable.
Parallel paths Cloud uses the same producer. External tables already emit per-table rows; populated and temporary-partition behavior is preserved.
Conditional checks The empty-collection state is reachable for AUTO/manual partitioned tables, and the comment explains the branch.
Test coverage New unit tests check zero/nonzero cardinality and metadata. Ordered regression snapshots retain RANGE, LIST, unpartitioned, HASH/RANDOM and privilege cases. Dedicated transition/concurrent-DDL tests are absent; those paths were inspected statically.
Expected results All six added rows match DDL/getters, including empty key/range fields; existing snapshots are consistent. Output-generation provenance was not independently verified.
Observability Existing RPC exception logging and error status propagation remain sufficient for this local metadata change.
Transactions and persistence Read-only metadata generation; no EditLog, commit, replay or failover behavior changed.
Data writes and atomicity No writes or new shared mutable state.
FE/BE variable propagation No new variable or sending path; cell order and types match FE schema and BE scanner.
Performance Nonempty cost is unchanged; an empty table adds one metadata row with no new external work.
Other issues and core invariants No additional defect substantiated after recheck. No change to committed-row visibility, visible-version limits or delete bitmaps; Java response objects have ordinary request lifetime, and errors still propagate through the existing RPC boundary.

No additional user review focus was supplied. Review scope was static only: no builds, tests or benchmarks ran, and no source files were modified. No unresolved candidate or required static coverage gap remains.

Review converged after 1 round(s).

…e_options

### Background

`information_schema.table_options` describes each internal OLAP table: its key model (`TABLE_MODEL`, `TABLE_MODEL_KEY`), distribution, bucket and partition counts, and, since apache#56122, its partitioning (`PARTITION_METHOD`, `PARTITION_EXPRESSION`, `PARTITION_KEY`, `RANGE`). apache#56122 made the FE emit one row per partition, so a table with N partitions has N rows that repeat the table-level columns, and an unpartitioned table, which always has its one implicit partition, has one row. A RANGE or LIST partitioned table can have no partition at all: an AUTO PARTITION table before its first load, or a table created with `PARTITION BY RANGE(k) ()` before any `ADD PARTITION`.

### What problem does this PR solve?

Issue Number: None
Related PR: apache#56122 (introduced the bug)
PR Type: Bugfix

Problem Summary:

On master, a partitioned OLAP table with no partition has no row in `information_schema.table_options`, although `information_schema.tables` lists it. Clients that read the key model from this table lose such tables; the OpenMetadata Doris connector, for example, builds primary keys from `TABLE_MODEL` and `TABLE_MODEL_KEY` and finds none for an AUTO PARTITION table that has not been loaded yet. This PR keeps one row per partition and adds one table-level row, with `PARTITION_NUM` 0, for a table without partitions.

### Details

- **Frequency:** Always. `CREATE TABLE t (dt DATETIME NOT NULL, k INT NOT NULL) UNIQUE KEY(dt, k) AUTO PARTITION BY RANGE (date_trunc(dt, 'day')) () DISTRIBUTED BY HASH(k) BUCKETS 1 PROPERTIES ("replication_num" = "1"); SELECT * FROM information_schema.table_options WHERE TABLE_NAME = 't';` returns an empty set until a load creates the first partition.
- **Root cause:** `MetadataGenerator.tableOptionsForInternalCatalog` builds every row inside the loop over `OlapTable.getAllPartitions()` (apache#56122). For a table with no partition the loop body never runs, so the table contributes no row.
- **Why existing tests missed it:** Unit tests: no FE unit test read `table_options`. Regression: `query_p0/system/test_table_options` (P0 and cloud P0) has RANGE and LIST tables with three partitions each and unpartitioned tables, which always have one partition; none of its tables has zero partitions, so the `.out` that apache#56122 regenerated could not show a missing table.
- **Fix:** when `getAllPartitions()` is empty, emit one row before the per-partition loop. Its `PARTITION_EXPRESSION` is the partition columns, the value the table's rows carry once partitions exist, rather than the string `NULL` that marks an unpartitioned table; `PARTITION_KEY` and `RANGE` are empty, as for unpartitioned tables.
- **Other paths and branches:** `information_schema.partitions` lists partitions, so a table without partitions has no row there by design. `table_properties`, `information_schema.tables`, `SHOW TABLE STATUS`, and the external-catalog rows of `table_options` are one row per table: not affected. Cloud mode runs the same code. branch-3.1, branch-4.0, branch-4.1, and branch-4.2 lack apache#56122 and emit one row per table, so only master has the bug.

### Testing

- Regression `query_p0/system/test_table_options`: three tables without partitions were added (AUTO RANGE, AUTO LIST, and `PARTITION BY RANGE(k1) ()`); `select_check_1` and `select_check_2` list them, and the regenerated `.out` adds only their six rows. On the unfixed FE the suite fails (`Check tag 'select_check_1' failed, line 2 ... Expect cell is: auto_list_table_no_partition But real is: duplicate_table`); on the fixed FE it passes. The privilege checks (`select_check_3` to `select_check_5`) are unchanged.
- FE UT `TableOptionsMetadataGeneratorTest` checks the single row of an AUTO RANGE table without partitions (`PARTITION_NUM` 0, `PARTITION_EXPRESSION` `dt`, empty `PARTITION_KEY` and `RANGE`) and that a LIST table with two partitions keeps one row per partition. With the fix: 2 tests, 0 failures; with `MetadataGenerator` reverted to master, `testTableWithoutPartitionHasOneRow` fails with `expected: <1> but was: <0>`.
- Both ran locally. The regression suite ran on a single-FE, single-BE cluster: an FE built from this PR and a BE built from 6991e76 (the change is FE-only); the unfixed FE is the same jar with `MetadataGenerator` compiled from master.

### Notes for Reviewers

Most of the `MetadataGenerator` diff moves the table-level columns, `TABLE_CATALOG` through `PARTITION_METHOD`, into `newTableOptionsRow`, which the new row and the per-partition rows both use. The moved lines are unchanged except that the comment `key columTyp` now reads `TABLE_MODEL_KEY`; `git diff --color-moved` shows the move.

### Release note

None

### Check List (For Author)

- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Ready

### AI Disclosure

- Tool: Claude Code (Claude Opus 5.5)
- Generated: code, tests, this description
- Human review: not stated
- Prompts: As part of the OpenMetadata integration work, asked that Doris keep the per-partition rows of apache#56122 and only add a row for tables without partitions, so the connector can read every table's key model; asked for full local verification (an FE build, the regression suite and the FE unit test, each before and after the fix).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@morningman
morningman force-pushed the fix-table-options-zero-partition branch from bb7447d to 53c69f2 Compare November 17, 2026 03:30
@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Review setup stopped before context preparation ran; inspect the first failed or cancelled setup step.
Workflow run: https://github.com/apache/doris/actions/runs/44010766523

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@morningman

Copy link
Copy Markdown
Contributor Author

Local pipeline review — ✅ PASS

schema: doris-repo-review/v1
status: PASS
pr: apache/doris#70522
commit: 53c69f2d3d7fd917dd0985ceb62bdec930c8814e
base: c298259d425b0418568bc8f25bbb397dd34b1e16
reviewed_at: 2026-11-17T12:04+08:00
reviewer: morningman
model: gpt-6.1-sol
effort: xhigh
findings: {blocker: 0, major: 0, minor: 0, nit: 0}
rounds: 1
converged: true

Notes for maintainers

  • Static review only; builds, FE unit tests and regression suites were not run during this review. The added test gates and expected rows were checked against the producer and FE/BE scanner contract.

Reviewed locally with the doris-repo-review pipeline. Repository policy may accept this receipt for the matching commit; it is not a human Apache approval.

@yiguolei
yiguolei merged commit bb6fff5 into apache:master Nov 18, 2026
35 of 36 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Nov 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR approved by at least one committer and no changes requested.

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

Labels

approved Indicates a PR has been approved by one committer. dev/4.2.x dev/4.2.x-conflict reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants