Skip to content

[Enhancement](schema_table)Improve the field information of the information_schema.table_options table. - #56122

Merged
dataroaring merged 4 commits into
apache:masterfrom
hacklu-tu:feature/Enhancement-schema_table
Oct 31, 2025
Merged

dataroaring merged 4 commits into
apache:masterfrom
hacklu-tu:feature/Enhancement-schema_table

Conversation

@hacklu-tu

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #xxx

Related PR: #xxx

Problem Summary:
Improve the field information of the information_schema.table_options table.
desc table_options;
+----------------------+---------------+------+-------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+---------------+------+-------+---------+-------+
| TABLE_CATALOG | varchar(64) | Yes | false | NULL | |
| TABLE_SCHEMA | varchar(64) | Yes | false | NULL | |
| TABLE_NAME | varchar(64) | Yes | false | NULL | |
| TABLE_MODEL | text | Yes | false | NULL | |
| TABLE_MODEL_KEY | text | Yes | false | NULL | |
| DISTRIBUTE_KEY | text | Yes | false | NULL | |
| DISTRIBUTE_TYPE | text | Yes | false | NULL | |
| BUCKETS_NUM | int | Yes | false | NULL | |
| PARTITION_NUM | int | Yes | false | NULL | |
| PARTITION_METHOD | varchar(13) | Yes | false | NULL | |
| PARTITION_EXPRESSION | varchar(2048) | Yes | false | NULL | |
| PARTITION_KEY | text | Yes | false | NULL | |
| RANGE | text | Yes | false | NULL | |
+----------------------+---------------+------+-------+---------+-------+

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@Thearas

Thearas commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@dataroaring
dataroaring force-pushed the feature/Enhancement-schema_table branch from 5760794 to f03f71a Compare October 30, 2025 12:25
@dataroaring

Copy link
Copy Markdown
Contributor

run buildall

@doris-robot

Copy link
Copy Markdown
ClickBench: Total hot run time: 29.1 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit f03f71a50d2c455db90c2e09a0c7ffed91cf1974, data reload: false

query1	0.07	0.06	0.06
query2	0.10	0.07	0.06
query3	0.26	0.09	0.10
query4	1.62	0.13	0.13
query5	0.30	0.27	0.28
query6	1.16	0.67	0.67
query7	0.04	0.03	0.04
query8	0.06	0.04	0.05
query9	0.66	0.58	0.55
query10	0.65	0.64	0.62
query11	0.19	0.14	0.13
query12	0.20	0.14	0.13
query13	0.64	0.64	0.61
query14	1.05	1.03	1.02
query15	0.92	0.92	0.88
query16	0.43	0.42	0.44
query17	1.13	1.21	1.13
query18	0.23	0.22	0.22
query19	2.07	1.89	1.92
query20	0.01	0.01	0.01
query21	15.39	0.23	0.14
query22	4.81	0.08	0.05
query23	15.63	0.30	0.11
query24	2.84	0.52	0.41
query25	0.08	0.08	0.07
query26	0.17	0.16	0.17
query27	0.06	0.06	0.06
query28	4.30	1.17	0.98
query29	12.59	4.74	3.79
query30	0.30	0.15	0.13
query31	2.85	0.66	0.41
query32	3.25	0.58	0.49
query33	3.21	3.20	3.26
query34	15.96	5.25	4.60
query35	4.63	4.59	4.66
query36	0.73	0.54	0.53
query37	0.11	0.08	0.08
query38	0.07	0.05	0.04
query39	0.04	0.04	0.03
query40	0.18	0.17	0.16
query41	0.09	0.04	0.04
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 99.16 s
Total hot run time: 29.1 s

@doris-robot

Copy link
Copy Markdown

BE UT Coverage Report

Increment line coverage 0.00% (0/6) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.71% (18041/34225)
Line Coverage 37.96% (163715/431245)
Region Coverage 32.33% (124834/386106)
Branch Coverage 33.71% (54588/161956)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (6/6) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.41% (24017/33632)
Line Coverage 57.84% (249760/431823)
Region Coverage 52.89% (207095/391540)
Branch Coverage 54.65% (89095/163027)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 87.04% (47/54) 🎉
Increment coverage report
Complete coverage report

@hacklu-tu

Copy link
Copy Markdown
Contributor Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 87.04% (47/54) 🎉
Increment coverage report
Complete coverage report

@doris-robot

Copy link
Copy Markdown

BE UT Coverage Report

Increment line coverage 0.00% (0/6) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 52.72% (18042/34225)
Line Coverage 37.97% (163729/431261)
Region Coverage 32.33% (124816/386125)
Branch Coverage 33.70% (54584/161958)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100.00% (6/6) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 71.44% (24026/33632)
Line Coverage 57.87% (249914/431839)
Region Coverage 52.99% (207494/391559)
Branch Coverage 54.70% (89176/163029)

@github-actions

Copy link
Copy Markdown
Contributor

PR approved by anyone and no changes requested.

@dataroaring dataroaring 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.

LGTM

@github-actions github-actions Bot added the approved Indicates a PR has been approved by one committer. label Oct 31, 2025
@github-actions

Copy link
Copy Markdown
Contributor

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

@dataroaring
dataroaring merged commit 3eb94a1 into apache:master Oct 31, 2025
morningman added a commit to morningman/doris that referenced this pull request Nov 17, 2026
…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]>
yiguolei pushed a commit that referenced this pull request Nov 18, 2026
…e_options (#70522)

### 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()`
(#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 #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 #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 #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]>
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. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants