Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature parametric types #4005

Closed
wants to merge 3 commits into from

Conversation

pnowojski
Copy link
Member

This is part of the work for the following issue: #3938

  • generailized parametric types
  • deprecated literalParameters
  • added parser support for BIGINT typeParameter
  • propagated TypeParameterSignature to most of previous TypeSignature uses

TODO/Questions:

  • check/add backward compatibility with old clients (changes in ClientTypeSignature)
  • move parseSignature to presto-main and base it on antlr

@pnowojski
Copy link
Member Author

I am not entirely sure if that's right direction. It seems like having two separate lists for literal parameters and type parameters was simpler from code's perspective. Do we really want to unify both of those things? Without unifying we are losing the way to distinguish between two types foo(BIGINT, 42) and foo(42, BIGINT) but do we need that?

@losipiuk
Copy link
Contributor

some comments

@pnowojski
Copy link
Member Author

@martint I have changed implementation of *Parameter classes to your proposed one and I have pushed two more commits that moved ROW type to generalized type parameters (thus completely dropping old literalParameters).

It would be best to minimize changes to commits from this pull request, since there is a lot of more code that depends on those three commits (rebased Dain's VARCHAR changes + decimal changes).

We still need to decide at least what to do with backward compatibility with previous clients.

As a future refactor somewhere down the road, we should indeed do something about redundancy between TypeSignatureParameter, TypeParameter and ClientTypeSignatureParameter classes. Do we need ClientTypeSignature at all? It predates dependency of presto-client to presto-spi, so it might HAD some sense long time ago, but at this moment, I don't see a point of having TypeSignature and ClientTypeSignature?

- generalized parametric types
- deprecated literalParameters
- added parser support for BIGINT typeParameter
- renamed getParameters to getTypeParametersAsTypeSignatures
- bindParameters for generalized type signature
@martint
Copy link
Contributor

martint commented Dec 28, 2015

Great, I'll take a look.

I don't think we need ClientTypeSignature any more, by the way.

@@ -238,7 +238,7 @@ valueExpression
primaryExpression
: NULL #nullLiteral
| interval #intervalLiteral
| identifier STRING #typeConstructor
| type STRING #typeConstructor
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 not sure we want to allow arbitrary types for the "type constructor" idiom. I actually think we made a mistake in allowing anything beyond the special cases described in the SQL spec (INTERVAL, DATE, etc).

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't this out of scope of this pull request? Can we create an issue for "disallow arbitrary types in type constructor"? Especially that @losipiuk said that such solution was discussed with you about constructing decimal literals.

@martint
Copy link
Contributor

martint commented Jan 4, 2016

Isn't this out of scope of this pull request? Can we create an issue for "disallow arbitrary types in type constructor"

What I was suggesting is not that we change what we support today (at least not yet), but to not extend the syntax beyond that. These look weird to me: VARCHAR(10) 'hello', DECIMAL(5,2) '123.456'.

Is there a use case for specifying the type parameters in these expressions given that it can be inferred from the value?

@martint
Copy link
Contributor

martint commented Jan 8, 2016

Superseded by #4264

@martint martint closed this Jan 8, 2016
@pnowojski pnowojski deleted the feature_parametric-types branch January 8, 2016 07:43
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.

4 participants