Skip to content

Error while extract schema #528

Closed
Closed

Description

@dofy1034

Hello,

I found if using a function that contains keywords, like fromUnixTimestamp64Milli, I got an error result when extract db and table name.

Here is code snippet:

private String extractDBAndTableName(String sql) {
        if (Utils.startsWithIgnoreCase(sql, "select")) {
            String withoutStrings = Utils.retainUnquoted(sql, '\'');
            int fromIndex = withoutStrings.indexOf("from");
            if (fromIndex == -1) {
                fromIndex = withoutStrings.indexOf("FROM");
            }
            if (fromIndex != -1) {
                String fromFrom = withoutStrings.substring(fromIndex);
                String fromTable = fromFrom.substring("from".length()).trim();
                return fromTable.split(" ")[0];
            }
        }
        if (Utils.startsWithIgnoreCase(sql, "desc")) {
            return "system.columns";
        }
        if (Utils.startsWithIgnoreCase(sql, "show")) {
            return "system.tables";
        }
        return "system.unknown";
    }

Activity

  1. added this to the 0.2.5 release milestone on Dec 28, 2020
  2. self-assigned this
    on Jan 2, 2021
  3. added a commit that references this issue on Jan 3, 2021
    dca2bdb
  4. linked a pull request that will close this issueAdd JavaCC based new parser #563on Feb 7, 2021
  5. assigned and unassigned on Feb 7, 2021
  6. added
    api-diagnostics
    jdbc
    legacy
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-diagnosticsbugjdbclegacy

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions