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

feature(athena): add SHOW #4782

Closed
wants to merge 7 commits into from
Closed

Conversation

theborch
Copy link

Parse the following Athena statements as SHOW:

SHOW COLUMNS
SHOW CREATE TABLE
SHOW CREATE VIEW
SHOW DATABASES
SHOW PARTITIONS
SHOW TABLES
SHOW TBLPROPERTIES
SHOW VIEWS

Example:

from sqlglot import parse_one

parse_one("show create table db.table;", dialect="athena")

Output:

Show(
  this=CREATE TABLE,
  target=Identifier(this=table, quoted=False),
  db=Identifier(this=db, quoted=False))

Notes:

  1. if a regular expression is used in SHOW TABLES it needs to be prefixed with LIKE
    • this is valid athena syntax, despite missing from the current AWS docs.
  2. SHOW TBLPROPERTIES does not currently parse the optional ('property_name').

@georgesittas
Copy link
Collaborator

Ηι @theborch, can you please fix the build?

Copy link
Collaborator

@georgesittas georgesittas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@theborch, please open a new PR that only inludes changes related to the SHOW syntax. There's too much going on here and it's hard to review.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert all the changes to this file, they're unrelated to the PR and it's not clear why they were made.

properties: t.Optional[exp.Properties] = expression.args.get("properties")
properties: exp.Properties | None = expression.args.get("properties")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, please avoid making changes like these. It makes reviewing PRs harder. Stylistic changes need to be discussed with the core team first and, if accepted, reviewed separately.

Comment on lines +114 to +115
IDENTIFIERS: ClassVar[list] = ['"', "`"]
KEYWORDS: ClassVar[dict] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these added? This pattern is inconsistent with the rest of the codebase.

target = f"IN {target}"
like = self._prefixed_sql("LIKE", expression, "like")
rlike = self._prefixed_sql("LIKE", expression, "rlike")
print(this, target, db, like, rlike)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants