Skip to content

[repr types] analysis and MRE typechecker#34792

Merged
mgree merged 2 commits intoMaterializeInc:mainfrom
mgree:repr-types-analysis-and-typ
Jan 28, 2026
Merged

[repr types] analysis and MRE typechecker#34792
mgree merged 2 commits intoMaterializeInc:mainfrom
mgree:repr-types-analysis-and-typ

Conversation

@mgree
Copy link
Contributor

@mgree mgree commented Jan 21, 2026

Adds direct generation of repr types via analysis (and the underlying try_repr_col_with_input_repr_cols) function. Will allow us to replace calls to .typ() with calls to .repr_typ(), used in many transforms.

Motivation

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@mgree mgree requested a review from a team as a code owner January 21, 2026 22:10
@ggevay
Copy link
Contributor

ggevay commented Jan 28, 2026

The goal somewhat soon is that we should be able to remove the old try_col_with_input_cols and the associated old Analysis, right? But anyhow, until that time it would be good to note in the doc comments of these things that we have some mostly copy-pasted code that one should be careful to keep in sync. (And we should not live with this tech-debt forever!)

Copy link
Contributor

@ggevay ggevay left a comment

Choose a reason for hiding this comment

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

LGTM, just minor comments

.expect("ReprRelationType analysis discovered type-less expression")
});

let sql_typ = expr.try_repr_col_with_input_repr_cols(input_cols).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable name is stale from a copy-paste, I guess.

) => Ok(ReprScalarType::Range {
element_type: Box::new(element_type.union(other_element_type)?),
}),
(_, _) => bail!("Can't union scalar types: {:?} and {:?}", self, scalar_type),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit worried that somebody will add a type and forget to handle it here. Maybe we could add an Arbitrary/proptest-based test that generates (a, a) pairs, and calls this function, and expects to not error? Plus maybe a big warning comment in ReprScalarType to not forget to add new variants to Arbitrary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good thought! Added a proptest and appropriate notes on the enum.

@mgree mgree enabled auto-merge (squash) January 28, 2026 18:33
@mgree mgree merged commit 99f8c00 into MaterializeInc:main Jan 28, 2026
131 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.

2 participants