Skip to content

fix: expose complete information_schema column metadata - #28228

Merged
XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
daviszhen:codex/issue-25103-metadata
Sep 6, 2026
Merged

XuPeng-SH merged 10 commits into
matrixorigin:mainfrom
daviszhen:codex/issue-25103-metadata

Conversation

@daviszhen

@daviszhen daviszhen commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #25103

What this PR does / why we need it:

Expose MySQL-compatible information_schema.COLUMNS metadata for numeric and temporal types:

  • NUMERIC_PRECISION for integer, unsigned, MEDIUMINT, floating-point, DECIMAL, BIT, and YEAR types.
  • NUMERIC_SCALE for exact numeric types, integer types (0), and explicit FLOAT(M,D)/DOUBLE(M,D).
  • DATETIME_PRECISION for TIME, DATETIME, and TIMESTAMP.

Add regression coverage for COLUMNS and the Connector/J information_schema getImportedKeys query, and refresh distributed metadata expectations.

Tests:

  • go test ./pkg/sql/plan/function -run "TestBuiltInInternal(CharMetadata|NumericPrecision|NumericScale|DatetimeScale)" -count=1
  • go test ./pkg/tests/issues -run TestIssue25103InformationSchemaMetadata -count=1 -timeout=10m
  • go test ./pkg/util/sysview ./pkg/bootstrap/versions/v4_0_6 -count=1 -timeout=10m

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH 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.

Deep re-review of exact head 1435a9fc70230b4568fac90be253d66789881bfd. The previous FLOAT(M,D) parser blocker is fixed: the 24/25 storage boundary is now applied only when D is absent, and the generated parser, public DDL test, and metadata helper agree. The integer, MEDIUMINT, BIT, YEAR, DECIMAL, and temporal matrix also matches a clean MySQL 8.0.44 oracle. One reachable metadata distinction is still lost.

[P1 correctness] Do not expose an implicit float scale as explicit NUMERIC_SCALE = 0.

internalNumericScale returns a non-NULL scale for every FLOAT/DOUBLE with typ.Scale >= 0. However, MatrixOne's ordinary function/expression float type is created with types.T_float32.ToType() or types.T_float64.ToType(), whose metadata is Width = 0, Scale = 0. Scientific float literals use that path through makePlan2Float64ConstExprWithType, and many float-returning functions do as well. The zero scale here is an internal default, not evidence of an explicit FLOAT(M,0) declaration.

Consequently a CTAS/expression-derived ordinary DOUBLE is exposed by information_schema.COLUMNS with NUMERIC_SCALE = 0. MySQL leaves NUMERIC_SCALE NULL whenever D is omitted; I verified both ordinary FLOAT/DOUBLE and CTAS expression columns on MySQL 8.0.44. This also contradicts the helper's own contract that only FLOAT(M,D) / DOUBLE(M,D) should expose scale.

Please require the same explicit-width evidence already used by internalNumericPrecision (for example, typ.Width > 0 && typ.Scale >= 0) before returning a float scale. Add helper coverage for T_float32.ToType() and T_float64.ToType(), plus one public CTAS/function-produced FLOAT or DOUBLE column, while retaining FLOAT(M,0) as non-NULL scale 0. The path is common metadata generated by the current system, not malformed legacy state.

@daviszhen

Copy link
Copy Markdown
Contributor Author

Addressed the latest P1 in commit 1bf893d5f7.

internalNumericScale now returns a float scale only when Width > 0 && Scale >= 0, so ordinary T_float32.ToType()/T_float64.ToType() expressions with the internal Scale=0 default remain NUMERIC_SCALE = NULL, while explicit FLOAT(M,0) remains 0. Added helper coverage for implicit and explicit float metadata plus a public CTAS/function regression using abs(1e0).

Validation: gofmt and git diff --check passed; the focused Go test is blocked locally because the workstation lacks usearch.h, jemalloc.h, xxhash.h, and roaring.h. The ordinary push is complete and the new CI run is in progress.

@daviszhen

Copy link
Copy Markdown
Contributor Author

已修复并推送最新 head:ddb3828f92(test(plan): fix explicit float scale expectation)。

  • 根因:显式 DOUBLE(18,6) 的 NUMERIC_SCALE 应为 6,回归测试第 12 行误写为 0,导致 Ubuntu UT 失败;UT Coverage 及 Utils Coverage 为连锁失败。
  • 修复:更新 pkg/sql/plan/function/func_builtin_test.go 的期望值;git diff --check 通过。
  • 本地测试:受工作站缺少 jemalloc.h、xxhash.h、roaring.h、usearch.h 阻塞,未能完成编译;该失败断言已由 CI 日志精确定位。
  • 新 head 的 required checks 已重新排队/运行,未重复触发已有 job。

@XuPeng-SH XuPeng-SH 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.

Deep re-review of exact head ddb3828f92626a418b94f1982e18b3e89ecff47c against merge-base 109bf926fdb31de31e0578ad0fb17be160d7d8d0 and current main/c1293102fd18908b59c4b049140aad67a50e0b16.

The previous blockers are closed end to end: the FLOAT(p) 24/25 storage boundary, FLOAT(M,D) type retention, YEAR and signed/unsigned MEDIUMINT metadata, and implicit versus explicit floating scale all agree across grammar, generated parser, persisted type metadata, helper output, and the public DDL/CTAS path. I also checked integer/decimal/BIT/default-width and TIME/DATETIME/TIMESTAMP NULL/scale boundaries, the information_schema view consumers, changed expected results, and the current-main delta; no further correctness, compatibility, lifecycle, boundedness, or performance blocker was found.

Evidence reused on this exact head: Shared Build, Ubuntu UT, SCA, UT Coverage, proxy BVT, pessimistic BVT, and Utils Coverage are terminal green. The newly added issue regression exercises the public SQL/protocol metadata path; focused helper/parser coverage preserves the internal boundaries. git diff --check passes and the isolated worktree is clean.

@XuPeng-SH
XuPeng-SH merged commit efeae71 into matrixorigin:main Sep 6, 2026
15 of 18 checks passed

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants