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

Change character literal treatment and char/varchar coercion #9031

Open
findepi opened this issue Aug 30, 2021 · 5 comments
Open

Change character literal treatment and char/varchar coercion #9031

findepi opened this issue Aug 30, 2021 · 5 comments

Comments

@findepi
Copy link
Member

findepi commented Aug 30, 2021

to be considered

  • what should be the type of VARCHAR 'abc'? Currently it's unbounded varchar, but maybe it should be varchar(3) so that there is a concise literal form for varchar(n) values.
  • what about literals with length exceeding CharType.MAX_LENGTH (65536)?

Follows https://github.com/trinodb/trino/pull/8984/files#diff-b2201e0a7ed30a2cb81a3672435281f5822574fd25e127010e3aaa58ee62b04dR483

cc @martint @sopel39 @kasiafi @losipiuk @weiatwork

@sopel39
Copy link
Member

sopel39 commented Aug 30, 2021

Also very importantly, current comparison semantics (trailing space insensitive between char/varchars) should be preserved. Some old design doc about it: https://docs.google.com/document/d/1UngGirjV_I7nPnIGU6G7SDS0cY8j7N_Jb3Wk3EoHChc/edit?usp=sharing.

@findepi
Copy link
Member Author

findepi commented Aug 30, 2021

Some old design doc about it: https://docs.google.com/document/d/1UngGirjV_I7nPnIGU6G7SDS0cY8j7N_Jb3Wk3EoHChc/edit?usp=sharing.

The doc seem to focus on INSERT, which today is handled explicitly see #2061 cc @kasiafi

@sopel39 Are there other parts of this doc, which i should still read carefully?

@sopel39
Copy link
Member

sopel39 commented Aug 30, 2021

The doc seem to focus on INSERT, which today is handled explicitly see #2061 cc @kasiafi

There is section about COMPARISON_ARGUMENT<T1,T2,X>

@martint
Copy link
Member

martint commented Jul 26, 2022

Related: #4394

@cshao239
Copy link
Contributor

More on this topic, Concat previously can take free combinations of char(n) and varchar within the limit of the number of parameters. In ConcatFunction.java class, Trino constructs a FunctionMetadata with signature that has input type of varchar, and output type of varchar, and the number of inputs can be varied, and not exceeding 254. In SignatureBinder.java, expandVarargFormalTypeSignature method would generate 253 (2,3,4,....254) different TypeSignatures for inputs and binding to functions.
If we want to simulate the functionality of char -> varchar auto coercion by adding more function signature, we will have to create (65538^254 + 65538^253 + 65538^252 + ..... 65538^2) signatures for concat function: each of the parameter could be varchar, char(0,1,2...65536), total of 65538 possibilities; and there are 253 different lengths of arguments (2, 3, .... 254). From the memory point view, This is not a good idea. Plus, in order to implement this, significant refactoring is needed to support such Type-Interpolation in Signature class.
So it would be better to bring the char -> varchar auto coercion back

findinpath added a commit to findinpath/coral that referenced this issue Jul 31, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Jul 31, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Jul 31, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Aug 10, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Aug 23, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Sep 19, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Sep 19, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Sep 19, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Sep 19, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Sep 28, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Sep 28, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/coral that referenced this issue Sep 28, 2023
…set operation

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
wmoustafa pushed a commit to linkedin/coral that referenced this issue Oct 5, 2023
…set operation (#442)

In case of dealing with Hive views which make use of set operation (e.g. UNION)
ensure that the `char` fields from the inner SELECT statements have the same type
as the output field types of the set operation.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb/trino#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findinpath added a commit to findinpath/trino that referenced this issue Oct 26, 2023
Bump coral to 2.2.14 to support Hive view translation cnsisting of a UNION
between a char and a varchar field.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
findepi pushed a commit that referenced this issue Oct 27, 2023
Bump coral to 2.2.14 to support Hive view translation cnsisting of a UNION
between a char and a varchar field.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
shreyas-dview pushed a commit to dview-io/trino that referenced this issue Dec 12, 2023
Bump coral to 2.2.14 to support Hive view translation cnsisting of a UNION
between a char and a varchar field.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
lucasdlemos pushed a commit to lucasdlemos/trino that referenced this issue Feb 1, 2024
Bump coral to 2.2.14 to support Hive view translation cnsisting of a UNION
between a char and a varchar field.

Due to wrong coercion between `varchar` and `char` in Trino, as described in
trinodb#9031
, a work-around needs to be applied in case of translating Hive views which
contain a UNION dealing with char and varchar types.
The work-around consists in the explicit cast of the field
having char type towards varchar type corresponding of the set operation
output type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants