Repository navigation
Fixes 37548: Map LARGEINT as numeric in profiler ORM and decode 128-bit values - #38810
Conversation
… and avoid BIGINT/UNSIGNED casts in Doris/StarRocks SumFn
❌ PR checklist incompleteThis 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 |
pmbrull
left a comment
There was a problem hiding this comment.
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.
|
@codewithsruthi Thanks for your contribution, Could you please check @pmbrull's comment, also the failing ci |
|
Thanks for catching that, @pmbrull! I pulled the |
Code Review ✅ Approved 🟡 Medium riskMapping Doris/StarRocks LARGEINT into profiler metrics and changing SUM result decoding could alter reported statistics for 128-bit columns. Maps Doris and StarRocks VerificationRules No rules evaluated Functional validation Not enabledAuto-approval Not enabledFor more verification details, comment OptionsDisplay: compact → Showing compact verification results. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
Describe your changes:
Fixes #37548
Mapped
DataType.LARGEINTto a quantifiableCustomLargeInt(TypeDecorator)in the profiler ORM so Doris (and StarRocks)LARGEINTcolumns are no longer dropped asUndeterminedType, and updatedSumFn/MedianFnso 128-bitLARGEINTvalues decode cleanly intoDecimalwithout overflowing 64-bitBIGINT/UNSIGNEDcasts.Previously,
DataType.LARGEINTwas missing fromCommonMapTypes._TYPE_MAP,CommonMapTypes.map_sqa_to_om_types(), andQUANTIFIABLE_SET. DorisLARGEINTcolumns therefore fell back toUndeterminedType(inNOT_COMPUTE), skipping all column metrics (mean,sum,min,max,stddev, quartiles, histogram). Because Doris and StarRocks transmit 128-bitLARGEINTover the MySQL wire protocol asMYSQL_TYPE_STRINGwhileDorisPyMySQLDialectandMySQLDialect_pymysqlsetsupports_native_decimal = True, baresqlalchemy.NUMERICinstalls no result processor; wrappingNUMERICinCustomLargeIntensuresstrvalues decode to exactDecimal.Type of change:
High-level design:
ingestion/src/metadata/profiler/orm/types/custom_largeint.py&orm/registry.py: AddedCustomLargeInt(TypeDecorator)(impl = NUMERIC,cache_ok = True,quantifiable = True,python_type = Decimal), registered asCustomTypes.LARGEINT, and addedDataType.LARGEINT.valuetoQUANTIFIABLE_SET.process_result_valuedecodesstr/inttoDecimalwhile passingfloat(e.g. Dorispercentile_approx) andNonethrough unchanged.ingestion/src/metadata/profiler/orm/converter/common.py: MappedDataType.LARGEINTtoCustomTypes.LARGEINT.valueinCommonMapTypes._TYPE_MAPand added{CustomTypes.LARGEINT.value: {DataType.LARGEINT}}tomap_sqa_to_om_types()so global profiler metric configs targetingLARGEINTstay cleanly scoped fromNUMBER/NUMERIC.ingestion/src/metadata/profiler/metrics/static/sum.py&orm/functions/sum.py: Propagatedtype_=self.col.typeonSumFnforCustomLargeInt(with aself.col is Noneguard for type narrowing), added@compiles(SumFn, Dialects.Doris)returningSUM(...)withoutCAST(... AS BIGINT), and guarded@compiles(SumFn, Dialects.MySQL)to emitSUM(...)whenisinstance(element.type, CustomTypes.LARGEINT.value)(coveringStarRocksConnection, which connects overmysql+pymysql, while preservingCAST(... AS UNSIGNED INTEGER)for regular MySQL integer columns).ingestion/src/metadata/profiler/metrics/window/percentille_mixin.py: WrappedMedianFnwithsqlalchemy.type_coerce(fn, column.type)whencolumn.typeisCustomLargeIntso quartile/median queries decode string-encodedLARGEINTvalues toDecimal(preventingTypeErrorinInterQuartileRange).sqlalchemy.NUMERIC/sqlalchemy.BIGINT: rejected becausesupports_native_decimal = TrueonDorisPyMySQLDialectandMySQLDialect_pymysqlcauses bareNUMERIC(andBIGINT) to install noresult_processor, leavingMIN/MAX/SUM/quartile results as rawstrand breaking numeric comparisons in Data Quality validators andInterQuartileRange.NUMERIC/BIGINT/MySQL integer behavior and partition auto-detection are unchanged.Tests:
Use cases covered
LARGEINTcolumns map toCustomLargeInt(notUndeterminedType), passNOT_COMPUTEfiltering, satisfyis_quantifiable, and resolveDataType.LARGEINTinCommonMapTypes.map_sqa_to_om_types().Mean,Sum,Min,Max,StdDev,FirstQuartile,Median,ThirdQuartile) generate valid SQLAlchemy expressions for DorisLARGEINTcolumns.Sum(largeint_col).fn()compiles toSUM(amount)withoutBIGINT/UNSIGNEDcasts under bothDorisPyMySQLDialect(pydoris) andMySQLDialect_pymysql(mysql), while regular MySQLINTcolumns keepCAST(... AS UNSIGNED INTEGER).result_processoroncol.type,Min,Max,Sum,FirstQuartile,Median, andThirdQuartiledecodes 128-bit positive/negativeLARGEINTstrings (±2^127) to exactDecimal, passesfloatthrough unchanged, and preservesNone.Unit tests
ingestion/tests/unit/observability/profiler/test_converter.py(test_largeint_columns_are_mapped_as_numeric,test_doris_largeint_numeric_metrics_and_sum_sql)cd ingestion && make static-checks→ 0 errors (basedpyrightpassed)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 passedBackend integration tests
Ingestion integration tests
tests/integration/.Playwright (UI) tests
Manual testing performed
Tableentity with aDataType.LARGEINTcolumn throughometa_to_sqa_ormand verifiedMean,Sum,Min,Max,StdDev,FirstQuartile,Median, andThirdQuartileall produce SQLAlchemy expressions.Sum(col).fn()withDorisPyMySQLDialect()andMySQLDialect_pymysql(), confirmingSUM(amount)withoutCAST(...), and verifiedresult_processordecodes 128-bit string bounds (170141183460469231731687303715884105727and-170141183460469231731687303715884105728) toDecimal.UI screen recording:
Not applicable — Python profiler ORM fix only; no UI changes.
Checklist:
Fixes 37548: Map LARGEINT as numeric in profiler ORM and decode 128-bit valuesFixes #37548above.DataType.LARGEINTalready exists intable.json).REVIEW.mdand addressed review feedback from@pmbrull.DataType.LARGEINT; no new cross-repo contract or default introduced.