You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BUG] JSQLParser 5.0: Alter alter = (Alter) CCJSqlParserUtil.parse(sqlStr); Table table = alter.getTable(); for ALTER TABLE the_needed_db.the_table ADD [...] not getting the needed DB #2062
Just wanted to reach out with a bug. If not a bug, could you please consider this as feature request?
I have a very simple query in which I would like to extract both the DB name and the table name.
Looking at the doc, I found this construct: CCJSqlParserUtil.parse and alter.getTable
However, it seems getTable cannot take into account the DB name.
For instance, on this simple statement: String sqlStr = "ALTER TABLE the_needed_db.the_table ADD [...]
I have this piece of code:
try {
// Set<String> tableNames = TablesNamesFinder.findTables(sqlStr); why java.lang.UnsupportedOperationException: Finding tables from Alter is not supported ...
Alter alter = (Alter) CCJSqlParserUtil.parse(sqlStr);
Table table = alter.getTable();
System.out.println("the table name for analyze statement " + table.getName());
} catch (Exception e) {
System.err.println("issue with analyze statement " + sqlStr);
e.printStackTrace();
}
Expected result: the table name for analyze statement the_needed_db.the_table
Actual result: the table name for analyze statement the_table
Could you please help on this bug?
In the event this has been thought over and is per design.
Would it be possible to consider this ticket as enhancement request, giving the user who cares about the DB name to have some API that can extract both the DB name and the table name please?
Business justification, table names can be the same across two distinct DBs.
Example:
ALTER TABLE the_cool_db.the_table ADD [...]
ALTER TABLE the_needed_db.the_table ADD [...]
Without DB name, the result execution of both would be the same, while it might be interesting to the user to distinguish the actual DB.