Skip to content

unparsable section when using session_user in insert, statement postgres dialect #6474

@nickcwcbng

Description

@nickcwcbng

Search before asking

  • I searched the issues and found no similar issues.

What Happened

I have a file called: cut_down_to_raise_bug.sql

CREATE TABLE schema_version (id SERIAL PRIMARY KEY, version VARCHAR(32), create_time TIMESTAMP,
            update_time TIMESTAMP, who VARCHAR(128));

INSERT INTO public.schema_version VALUES (
    DEFAULT,
    0.0,
    CURRENT_TIMESTAMP,
    CURRENT_TIMESTAMP,
    session_user
);

When I lint it I get an unparsable error

sqlfluff lint src\tests\cut_down_to_raise_bug.sql
==== sqlfluff ====
sqlfluff:                3.2.5 python:                 3.11.9
implementation:        cpython verbosity:                   1
dialect:              postgres templater:               jinja
rules:                                all
==== readout ====

== [src\tests\cut_down_to_raise_bug.sql] FAIL
L:   8 | P:  22 |  PRS | Line 8, Position 22: Found unparsable section: ',\n
                       | session_user'
WARNING: Parsing errors found and dialect is set to 'postgres'. Have you configured your dialect correctly?
==== summary ====
violations:        1 status:         FAIL
All Finished 📜 🎉!

This file works fine in the db itself as you can see the table is created as expected.

test-db=# select * from schema_version;
 id | version |        create_time         |        update_time         | who
----+---------+----------------------------+----------------------------+------
 41 | 1.17    | 2024-11-27 13:12:29.822401 | 2024-11-27 13:12:29.822401 | root
(1 row)

Expected Behaviour

I would expect the file to be parsed without error.

Observed Behaviour

Unpassable section

How to reproduce

lint the file.

Dialect

postgres

Version

sqlfluff: 3.2.5
python: 3.11.9

Configuration

.sqlfluff

[sqlfluff]

verbose = 1

dialect = postgres

large_file_skip_byte_limit = 0



exclude_rules  = layout,capitalisation, references


Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpostgresIssues relating to the Postgres dialect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions