Skip to content

Make TupleDescriptor.FieldDescriptors lazy-computed#204

Merged
SergeiPavlov merged 5 commits into
master-servicetitanfrom
LazyRecordsetHeader
Apr 10, 2024
Merged

Make TupleDescriptor.FieldDescriptors lazy-computed#204
SergeiPavlov merged 5 commits into
master-servicetitanfrom
LazyRecordsetHeader

Conversation

@SergeiPavlov
Copy link
Copy Markdown
Collaborator

We need not to build PackedFieldDescriptor until materialization Stage.

There are many intermediate translation stages (e.g. JOIN) when DO operates TupleDescriptor but does not use its .FieldDescriptors property.

@SergeiPavlov SergeiPavlov requested a review from botinko April 9, 2024 04:35
@SergeiPavlov SergeiPavlov merged commit 0e84b8f into master-servicetitan Apr 10, 2024
@SergeiPavlov SergeiPavlov deleted the LazyRecordsetHeader branch April 10, 2024 03:36
snaumenko-st added a commit that referenced this pull request Apr 27, 2026
Restore PR #204's lazy normalize-only body. The upstream merge kept
the eager switch+Configure block but routed writes through the lazy
`Data` property, forcing `LazyData` materialization (and the
DO_MAX_1000_COLUMNS guard) at construction time. Deferring layout to
`LazyData` removes the eager 1000-column trip during query translation
and obviates the `RecordSetHeader.Add` workaround.

Made-with: Cursor
snaumenko-st added a commit that referenced this pull request Apr 27, 2026
* Fix QueryTranslationException from RecordSetHeader.Join dead code

Remove an unused `CreateTupleDescriptor(newColumns)` call in
`RecordSetHeader.Join`. After upstream PR #248 changed the return
statement to use the lazy two-arg `TupleDescriptor(a, b)` constructor,
the local `newTupleDescriptor` became dead code. Combined with the
later move of the >1000-column guard into `LazyData` (PR #204), this
dead call eagerly tripped `NotSupportedException` during translation
of complex queries whose transient joined headers exceed 1000 columns,
even when the materialized recordset (after column pruning) would not.

Made-with: Cursor

* Bump DO version

* Fix QueryTranslationException from RecordSetHeader.Add eager validation

Switch `RecordSetHeader.CreateTupleDescriptor` (used by both `Add`
overloads) from `TupleDescriptor.Create` to `TupleDescriptor.CreateFromNormalized`,
matching the lazy normalization pattern already used by `Select` and
the upstream-optimized `Join`. The eager `Create` factory routes to
the single-arg `TupleDescriptor` constructor that synchronously
materializes `LazyData` and trips the >1000-column guard during
query translation, even when the resulting header is transient and
gets pruned before execution. This affected `IncludeProvider`-driven
translations of `Contains`-based predicates over already-wide
intermediate headers (e.g. `e.statusesList.Contains(e.Membership.Status)`
within complex multi-Select/SelectMany/GroupJoin chains).

Add `Xtensive.Orm.Tests.Core/Rse/RecordSetHeaderTest.cs` with
regression tests covering both `Add` overloads, `Join`, and the
preserved runtime guard via `LazyData` access.

Made-with: Cursor

* Update DoVersionSuffix version

* Fix SQL 2100-parameter limit in Bulk Update with large Contains

Auto+TVP path of SqlDml.Variant lost its TvpTypeMapping because the
complex-condition branch always allocated a fresh QueryParameterBinding,
discarding the TVP binding the caller had just created. Reuse the
incoming binding so CommandFactory can switch to a single table-valued
parameter once the collection grows past MaxNumberOfConditions.

Adds regression tests covering Bulk Update Contains over 2200 ids/guids.

Made-with: Cursor

* Fix botched merge of TupleDescriptor single-arg ctor in PR #481

Restore PR #204's lazy normalize-only body. The upstream merge kept
the eager switch+Configure block but routed writes through the lazy
`Data` property, forcing `LazyData` materialization (and the
DO_MAX_1000_COLUMNS guard) at construction time. Deferring layout to
`LazyData` removes the eager 1000-column trip during query translation
and obviates the `RecordSetHeader.Add` workaround.

Made-with: Cursor

* Update DoVersionSuffix version
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.

2 participants