Skip to content

Fixes 37548: Map LARGEINT as numeric in profiler ORM and decode 128-bit values - #38810

Merged
pmbrull merged 4 commits into
open-metadata:mainfrom
codewithsruthi:fix/37548-doris-profiler-largeint-metrics
Nov 27, 2026
Merged

pmbrull merged 4 commits into
open-metadata:mainfrom
codewithsruthi:fix/37548-doris-profiler-largeint-metrics

Conversation

@codewithsruthi

@codewithsruthi codewithsruthi commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

Fixes #37548

Mapped DataType.LARGEINT to a quantifiable CustomLargeInt(TypeDecorator) in the profiler ORM so Doris (and StarRocks) LARGEINT columns are no longer dropped as UndeterminedType, and updated SumFn / MedianFn so 128-bit LARGEINT values decode cleanly into Decimal without overflowing 64-bit BIGINT/UNSIGNED casts.

Previously, DataType.LARGEINT was missing from CommonMapTypes._TYPE_MAP, CommonMapTypes.map_sqa_to_om_types(), and QUANTIFIABLE_SET. Doris LARGEINT columns therefore fell back to UndeterminedType (in NOT_COMPUTE), skipping all column metrics (mean, sum, min, max, stddev, quartiles, histogram). Because Doris and StarRocks transmit 128-bit LARGEINT over the MySQL wire protocol as MYSQL_TYPE_STRING while DorisPyMySQLDialect and MySQLDialect_pymysql set supports_native_decimal = True, bare sqlalchemy.NUMERIC installs no result processor; wrapping NUMERIC in CustomLargeInt ensures str values decode to exact Decimal.

Type of change:

  • Bug fix

High-level design:

  • Approach & components:
    • ingestion/src/metadata/profiler/orm/types/custom_largeint.py & orm/registry.py: Added CustomLargeInt(TypeDecorator) (impl = NUMERIC, cache_ok = True, quantifiable = True, python_type = Decimal), registered as CustomTypes.LARGEINT, and added DataType.LARGEINT.value to QUANTIFIABLE_SET. process_result_value decodes str/int to Decimal while passing float (e.g. Doris percentile_approx) and None through unchanged.
    • ingestion/src/metadata/profiler/orm/converter/common.py: Mapped DataType.LARGEINT to CustomTypes.LARGEINT.value in CommonMapTypes._TYPE_MAP and added {CustomTypes.LARGEINT.value: {DataType.LARGEINT}} to map_sqa_to_om_types() so global profiler metric configs targeting LARGEINT stay cleanly scoped from NUMBER/NUMERIC.
    • ingestion/src/metadata/profiler/metrics/static/sum.py & orm/functions/sum.py: Propagated type_=self.col.type on SumFn for CustomLargeInt (with a self.col is None guard for type narrowing), added @compiles(SumFn, Dialects.Doris) returning SUM(...) without CAST(... AS BIGINT), and guarded @compiles(SumFn, Dialects.MySQL) to emit SUM(...) when isinstance(element.type, CustomTypes.LARGEINT.value) (covering StarRocksConnection, which connects over mysql+pymysql, while preserving CAST(... AS UNSIGNED INTEGER) for regular MySQL integer columns).
    • ingestion/src/metadata/profiler/metrics/window/percentille_mixin.py: Wrapped MedianFn with sqlalchemy.type_coerce(fn, column.type) when column.type is CustomLargeInt so quartile/median queries decode string-encoded LARGEINT values to Decimal (preventing TypeError in InterQuartileRange).
  • Alternatives considered:
    • Bare sqlalchemy.NUMERIC / sqlalchemy.BIGINT: rejected because supports_native_decimal = True on DorisPyMySQLDialect and MySQLDialect_pymysql causes bare NUMERIC (and BIGINT) to install no result_processor, leaving MIN/MAX/SUM/quartile results as raw str and breaking numeric comparisons in Data Quality validators and InterQuartileRange.
  • Backward compatibility: Fully backward-compatible; existing NUMERIC/BIGINT/MySQL integer behavior and partition auto-detection are unchanged.

Tests:

Use cases covered

  • Doris and StarRocks LARGEINT columns map to CustomLargeInt (not UndeterminedType), pass NOT_COMPUTE filtering, satisfy is_quantifiable, and resolve DataType.LARGEINT in CommonMapTypes.map_sqa_to_om_types().
  • Numeric profiler metrics (Mean, Sum, Min, Max, StdDev, FirstQuartile, Median, ThirdQuartile) generate valid SQLAlchemy expressions for Doris LARGEINT columns.
  • Sum(largeint_col).fn() compiles to SUM(amount) without BIGINT/UNSIGNED casts under both DorisPyMySQLDialect (pydoris) and MySQLDialect_pymysql (mysql), while regular MySQL INT columns keep CAST(... AS UNSIGNED INTEGER).
  • result_processor on col.type, Min, Max, Sum, FirstQuartile, Median, and ThirdQuartile decodes 128-bit positive/negative LARGEINT strings (±2^127) to exact Decimal, passes float through unchanged, and preserves None.

Unit tests

  • I added unit tests for the new/changed logic.
  • Files added/updated:
    • ingestion/tests/unit/observability/profiler/test_converter.py (test_largeint_columns_are_mapped_as_numeric, test_doris_largeint_numeric_metrics_and_sum_sql)
  • Commands & results:
    • cd ingestion && make static-checks → 0 errors (basedpyright passed)
    • cd ingestion && make py_format_check → All checks passed (ruff check + ruff format --check)
    • cd ingestion && make unit_ingestion ARGS="-n 0 tests/unit/observability/profiler/test_converter.py tests/unit/observability/profiler/sqlalchemy/test_metrics.py tests/unit/test_partition.py tests/unit/source/database/doris/" → 393 passed

Backend integration tests

  • Not applicable (no backend API changes).

Ingestion integration tests

  • Not run locally — no existing integration test directly imports the modified profiler modules, and no Doris integration test exists yet (tracked in Add a Doris integration test #37543); merge-queue CI runs tests/integration/.

Playwright (UI) tests

  • Not applicable (no UI changes).

Manual testing performed

  1. Built a Doris Table entity with a DataType.LARGEINT column through ometa_to_sqa_orm and verified Mean, Sum, Min, Max, StdDev, FirstQuartile, Median, and ThirdQuartile all produce SQLAlchemy expressions.
  2. Compiled Sum(col).fn() with DorisPyMySQLDialect() and MySQLDialect_pymysql(), confirming SUM(amount) without CAST(...), and verified result_processor decodes 128-bit string bounds (170141183460469231731687303715884105727 and -170141183460469231731687303715884105728) to Decimal.

UI screen recording:

Not applicable — Python profiler ORM fix only; no UI changes.

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes 37548: Map LARGEINT as numeric in profiler ORM and decode 128-bit values
  • My PR is linked to a GitHub issue via Fixes #37548 above.
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: Not applicable (no JSON Schema changes; DataType.LARGEINT already exists in table.json).
  • For a UI feature or feature task: Not applicable (Python profiler fix only).
  • I have added tests (unit / integration / Playwright as applicable) and listed them above.
  • Self-review: Reviewed against REVIEW.md and addressed review feedback from @pmbrull.
  • Decision check: Not applicable — bug fix implementing numeric profiling for an existing schema DataType.LARGEINT; no new cross-repo contract or default introduced.
  • I have added a test that covers the exact scenario we are fixing.

… and avoid BIGINT/UNSIGNED casts in Doris/StarRocks SumFn
@codewithsruthi
codewithsruthi requested a review from a team as a code owner November 26, 2026 08:32
@github-actions

Copy link
Copy Markdown
Contributor

❌ PR checklist incomplete

This PR cannot be merged until the following are addressed on its linked issue:

The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically.

Maintainers can bypass this check by adding the skip-pr-checks label.

@pmbrull pmbrull left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working on LARGEINT profiling.

🔴 Keep automatic partition detection from dropping rows. With auto-detection enabled and no table override, a Doris table with a LARGEINT integer-range partition now gets a filter from 1 to 10000 regardless of its actual bounds. In a local test using the inferred predicate, the parent selected a row with ID 20000 and this revision excluded it. Please leave automatic range detection out of the ORM fix, or use valid bounds and add a sampling regression with rows outside the current default range. Range inference, Profiler caller.

@akashverma0786

Copy link
Copy Markdown
Collaborator

@codewithsruthi Thanks for your contribution,

Could you please check @pmbrull's comment, also the failing ci

@codewithsruthi

codewithsruthi commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks for catching that, @pmbrull! I pulled the LARGEINT partition auto-detection change back out in 750b36e so this stays scoped to the ORM/metrics fix and won't filter out rows outside 1..10000. Also added a None guard in Sum.fn to clear up the pyright errors from CI. Ready for another look whenever you have a moment!

@gitar-bot

gitar-bot Bot commented Nov 27, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 🟡 Medium risk

Mapping Doris/StarRocks LARGEINT into profiler metrics and changing SUM result decoding could alter reported statistics for 128-bit columns.

Maps Doris and StarRocks LARGEINT columns to a numeric profiler type so they are no longer skipped as UndeterminedType, and decodes 128-bit string results to Decimal in SumFn, MedianFn, and the partition sampler. No issues found.

Verification

Rules No rules evaluated

Functional validation Not enabled

Set up

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Display: compact → Showing compact verification results.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@pmbrull
pmbrull merged commit bb02361 into open-metadata:main Nov 27, 2026
30 of 31 checks passed
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.

Doris: LARGEINT columns get no profiler metrics

3 participants