Skip to content

Conversation

@martint
Copy link
Member

@martint martint commented Dec 8, 2025

Description

See individual commit details.

Release notes

(x) Release notes are required, with the following suggested text:

## SPI
* Remove support for `TypeSignatureParameter`. Use `TypeParameter`, instead. ({issue}`27574`)
* Remove support for `ParameterKind`. Use `TypeParameter.Type`, `TypeParameter.Numeric`, `TypeParameter.Variable`, instead. ({issue}`27574`)
* Remove support for `NamedType`, `NamedTypeSignature` and `NamedTypeParameter`. Use `TypeParameter.Type`, instead. ({issue}`27574`)

@cla-bot cla-bot bot added the cla-signed label Dec 8, 2025
@github-actions github-actions bot added iceberg Iceberg connector delta-lake Delta Lake connector hive Hive connector mongodb MongoDB connector blackhole Blackhole connector labels Dec 8, 2025
@github-actions github-actions bot added the jdbc Relates to Trino JDBC driver label Dec 8, 2025
@martint martint force-pushed the type-parameter branch 3 times, most recently from e62a20a to 6fa0b0c Compare December 9, 2025 01:35
@github-actions github-actions bot added bigquery BigQuery connector kafka Kafka connector pinot Pinot connector labels Dec 9, 2025
@martint martint force-pushed the type-parameter branch 3 times, most recently from 84e65fc to c0b738d Compare December 9, 2025 04:08
@martint martint marked this pull request as ready for review December 9, 2025 05:02
@martint martint requested review from dain and findepi December 9, 2025 05:03
Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Get type arguments directly from the type LGTM

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Remove TypeParameter LGTM

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Rename TypeSignatureParameter -> TypeParameter LGTM assuming it's mechanical rename

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Fix incorrect type declaration LGTM

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Remove NamedType and friends LGTM


if (kind == ParameterKind.VARIABLE) {
prefix = "@";
prefix += "@";
Copy link
Member

Choose a reason for hiding this comment

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

aren't name.isPresent() and kind == ParameterKind.VARIABLE exclusive conditions?
if so, better to have a check then lenient +=

Copy link
Member Author

Choose a reason for hiding this comment

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

In theory, it would be possible to have a named field with an unbound type.

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Deprecate Type.getTypeParameters()

TL;DR

many of these refactors looks good on their own, but it's hard to review all of them at once

// Until we support HASH_SWITCH strategy for code generation here, we treat structural type as an unsupported case
// and fall back to existing expression evaluator for small lists
if (!type.getTypeParameters().isEmpty()) {
if (type instanceof ArrayType || type instanceof MapType || type instanceof RowType) {
Copy link
Member

Choose a reason for hiding this comment

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

  • ParametricType is in SPI so one could imagine a plugin adding a structural type. The new check doesn't reject this.
    • in fact, ClassifierType is an example for which the new check returns different result

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed. However, that's only a theoretical concern right now. There's also a difference from a structural type (i.e., a container such as map/array/row) and a specialized type for type-safety and static type validations.

Copy link
Member

Choose a reason for hiding this comment

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

in fact, i don't know why we throw for some types, and return false for some other types.
it's looks like throwing isn't necessary in this method at all, because the final type validation/rejection needs to be done somewhere later ... and therefore it doesn't matter much what we do here. the new validation is weaker (more persmissive), and therefore likely incorrect, but it's whatever

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Improve type safety for TypeParameter

this change is least mechanical of all the commits in this PR.
i'd suggest separate PR.

@martint
Copy link
Member Author

martint commented Dec 10, 2025

i'd suggest separate PR.

Happy to do that. However, since all these commits affect the SPI, I wanted to get them all in the same timeframe to avoid thrash across multiple releases.

@martint
Copy link
Member Author

martint commented Dec 10, 2025

many of these refactors looks good on their own, but it's hard to review all of them at once

They are meant to be reviewed individually. They are all logically independent from each other, although they build on/touch the same areas the previous commit touched.

@findepi
Copy link
Member

findepi commented Dec 11, 2025

many of these refactors looks good on their own, but it's hard to review all of them at once

They are meant to be reviewed individually.

fair & my understanding as well. just the diff is longish

Copy link
Member

@findepi findepi left a comment

Choose a reason for hiding this comment

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

Deprecate Type.getTypeParameters()

i don't like this single long diff of manual & interesting changes to be forced upon me within this PR.
but ok, looked thru and LGTM % comments

Type elementType = switch (type) {
case RowType rowType -> rowType.getFields().getFirst().getType();
case ArrayType arrayType -> arrayType.getElementType();
default -> throw new IllegalArgumentException("Unexpected type: " + type);
Copy link
Member

Choose a reason for hiding this comment

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

  • it's weird to take just a first field of a row. worth code comment
  • the code also worked for map type which is now unhandled. i understand map never lands in this (test) code?

Copy link
Member Author

@martint martint Dec 11, 2025

Choose a reason for hiding this comment

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

That was confusing to me, too. But I think this method is designed to handle the case of decoding a list of uniform values and either pivot it into a row or map it to a Trino array. I actually have no idea why this method would be called with a row type where only the first field type matters. It seems like a I'm not sure what the semantics would be for a Map (maybe key-value pairs?), either, but it doesn't matter since it doesn't happen in practice. We can always add that whenever the use case comes up.

BTW, getting the first field the row is not a new behavior -- that's implicitly how it it was done before. I just ported the behavior.

@findepi
Copy link
Member

findepi commented Dec 11, 2025

Happy to do that. However, since all these commits affect the SPI, I wanted to get them all in the same timeframe to avoid thrash across multiple releases.

I don't think it's a really big problem.

TypeSignature should not be used in contexts where the Type is
available. It's purpose is mainly for doing type inference
and generic manipulation of types.
It's only used during instantiation of parametric types, as a
mirror of TypeSignatureParameter. The translation is not needed.
The type parameter must match the argument it corresponds to.
It's not an ideal abstraction. Naming of fields is orthogonal
to what type the argument is, so we don't need a dedicated class
for it.
For general use, it's preferable to call the type-specific
methods (e.g., ArrayType.getElementType(), MapType.getKeyType, MapType.getValueType())
Use a sum type instead of a tag + value. It makes it possible
to use deconstruction patterns and switch statements/expressions
to manipulate the values of the type.
@martint
Copy link
Member Author

martint commented Dec 12, 2025

@findepi , updated

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

Labels

bigquery BigQuery connector blackhole Blackhole connector cla-signed delta-lake Delta Lake connector hive Hive connector iceberg Iceberg connector jdbc Relates to Trino JDBC driver kafka Kafka connector mongodb MongoDB connector pinot Pinot connector

Development

Successfully merging this pull request may close these issues.

2 participants