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

ADQL-2.1 branch: Issue getting original column name from aliased query #156

Open
jwfraustro opened this issue Jul 18, 2024 · 0 comments
Open
Assignees
Labels

Comments

@jwfraustro
Copy link

Hi, I'm currently switching our fork over to using the feature branch supporting ADQL 2.1. I am having some issues with getting the original column name after parsing a query that uses a column alias.

For an ADQL query like:
SELECT table_name AS columnalias FROM tap_schema.tables AS tablealias

the ADQLParser successfully parses and (for SQLServer at least) translates the query into:
SELECT tablealias.table_name AS columnalias FROM tap_schema.tables AS tablealias

After parsing the query, I need to perform some operations that involve getting the column's original name table_name. In our old code, we made a call to getResultingColumns(), then to getDBName()

For example, an abstract code snippet:

queryObject = parser.parseQuery("SELECT table_name AS columnalias FROM tap_schema.tables AS tablealias");
// (new SQLServerTranslator()).translate(queryObject) produces correct translation
DBColumn columns = queryObject.getResultingColumns();
columns[0].getDBName();
// "table_name"

However, in the new branch, it seems that no longer works, and instead just returns the aliased name:

columns[0].getDBName();
// "columnalias"

It seems the line of affected code comes from the commit here, where Line 437 in getResultingColumns()
d341569
was changed from:

col = col.copy(col.getDBName(), alias, col.getTable());

to

col = col.copy(alias, alias, col.getTable()); 

Indeed, in our own code, reverting the change does fix our issue with getting the original column name, but seems to fail some of your other aliasing tests.

Any advice would be much appreciated. Thank you!

@gmantele gmantele self-assigned this Jul 24, 2024
@gmantele gmantele added the bug label Jul 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants