Skip to content

Postgres parser fails on schema-qualified COMMENT ON TYPE and COMMENT ON VIEW #7683

@devfros

Description

@devfros

First, thank you for maintaining sqlglot. It has been very useful for my personal project.

Problem

sqlglot fails to parse valid PostgreSQL COMMENT ON statements when the target is schema-qualified for some object kinds, notably TYPE and VIEW.

Reproduction

from sqlglot import Dialects, parse

cases = [
    "COMMENT ON TYPE mood IS 'x';",
    "COMMENT ON TYPE foo.mood IS 'x';",
    "COMMENT ON VIEW foo.bat IS 'x';",
    "COMMENT ON TABLE foo.bar IS 'x';",
    "COMMENT ON COLUMN foo.bar.baz IS 'x';",
]

for sql in cases:
    print(sql)
    print(parse(sql, dialect=Dialects.POSTGRES))
ParseError: Required keyword: 'expression' missing for <class 'sqlglot.expressions.ddl.Comment'>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions