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

Generate column names instead of labels #7036

Closed
mlkersten opened this issue Dec 20, 2020 · 10 comments
Closed

Generate column names instead of labels #7036

mlkersten opened this issue Dec 20, 2020 · 10 comments
Labels
bug
Milestone

Comments

@mlkersten
Copy link
Member

@mlkersten mlkersten commented Dec 20, 2020

Is your feature request related to a problem? Please describe.
Consider the following statements:

sql> create table table_3a as select count(*) from sys.tables;
CREATE TABLE: generated labels not allowed in column names, use an alias instead
sql> create table table_3a as select count(*) as x from sys.tables;
operation successful

Describe the solution you'd like
I would expect that proper columns names are automatically generated. e.g. col_1, col_2,...
such that the resulting table can be easily re-used.

It is a programming convenience. Especially if you can easily retrieve the
number of columns in table_3a. (which we can from the catalogue)

@mlkersten mlkersten added the enhancement label Dec 20, 2020
@kutsurak
Copy link
Member

@kutsurak kutsurak commented Dec 21, 2020

I believe that the idea behind the generated labels is to precisely be disallowed as column names so that there is no overlap with user provided names for columns.

In my opinion adding as x clauses in these kinds of queries is a reasonable inconvenience to the user, compared to the engineering effort it would take to avoid having conflicts.

@kutsurak kutsurak added this to the NEXTRELEASE milestone Dec 21, 2020
@kutsurak kutsurak removed this from the NEXTRELEASE milestone Dec 21, 2020
@mlkersten mlkersten added this to the NEXTFEATURERELEASE milestone Dec 21, 2020
@mlkersten
Copy link
Member Author

@mlkersten mlkersten commented Dec 21, 2020

It is highly convenient for a tool that wishes to preserve the result set as a real table and only sees the user entering a SELECT
statement without further analysis.
Column confusion is not a problem, because the SQL optimizer pipeline can in the final stage replace the labels with permissible names before it creates the table from the result set. And simply check for a clash of an alias/colname with the generated one

@PedroTadim
Copy link
Contributor

@PedroTadim PedroTadim commented Dec 28, 2020

I'm going to close this issue as a duplicate of issue 7032.

@mlkersten
Copy link
Member Author

@mlkersten mlkersten commented Dec 29, 2020

No, it is not the same, as 7032 calls for better handling of duplicate names in error handling. I wish to let the system generate meaningful, distinct default column names. One can not depend on the user in all cases. It is needed in the next feature release.
However, a proper solution will help both issues.

@mlkersten mlkersten reopened this Dec 29, 2020
@njnes
Copy link
Contributor

@njnes njnes commented Dec 29, 2020

just add the as 'alias', gives the user full control.

@njnes njnes closed this as completed Dec 29, 2020
@mlkersten
Copy link
Member Author

@mlkersten mlkersten commented Dec 29, 2020

The user is an application that generates them!! it has no control over the expressions.
Futhermore, from a design point of view the relational model stresses the fact that the result of a relational query is again a relation. Not being able to address the attributes subsequently is a gross misstake.

@mlkersten mlkersten reopened this Dec 29, 2020
@mlkersten
Copy link
Member Author

@mlkersten mlkersten commented Dec 29, 2020

Niels :
i) If any two columns in the table specified by the QUERY EXPRESSION have equivalent COLUMN NAMEs, or if any column of that table has an implementation-dependent name, then a VIEWCOLUMNLIST shall be specified.

Martin Kersten :
We are talking here about implementation-dependent names, and I ask you to make sure that these names are disjoint to begin with. I could say not doing so is a bug in system-dependent name generation.

@mlkersten mlkersten added bug and removed enhancement labels Dec 29, 2020
@PedroTadim
Copy link
Contributor

@PedroTadim PedroTadim commented Dec 29, 2020

"Not being able to address the attributes subsequently is a gross misstake." This is a user mistake, not a database one.

@mlkersten
Copy link
Member Author

@mlkersten mlkersten commented Dec 29, 2020

Though shall never generate identifiers in a substructure that makes the complete structure invalid.
This means that the valid expression

CREATE TABLE pair AS SELECT 1, 2

becomes invalid while this can be easily avoided using a proper system-dependent name generation.
it is not the user at fault, but the system not doing its work properly in name generation. It re-uses the same label,

If you take the SQL standard literally, then the following expression should also be at fault
CREATE TABLE one AS SELECT 1
because it has a single system generated name "v". This, however, is accepted by our implementation.

@PedroTadim
Copy link
Contributor

@PedroTadim PedroTadim commented Dec 30, 2020

We are doing exactly like postgres, ie it has a default name for column without labels. If there is more than one column without a label then a duplicate name is generated, thus error.

@sjoerdmullender sjoerdmullender removed this from the NEXTFEATURERELEASE milestone Jan 26, 2021
@sjoerdmullender sjoerdmullender added this to the Oct2020-SP2 milestone Jan 26, 2021
@sjoerdmullender sjoerdmullender removed this from the Oct2020-SP2 milestone Jan 26, 2021
@njnes njnes closed this as completed Apr 20, 2022
@sjoerdmullender sjoerdmullender added this to the NEXTRELEASE milestone May 16, 2022
@sjoerdmullender sjoerdmullender removed this from the NEXTRELEASE milestone May 31, 2022
@sjoerdmullender sjoerdmullender added this to the Jan2022-SP3 milestone May 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug
Projects
None yet
Development

No branches or pull requests

5 participants