Skip to content

Redshift MERGE INTO statement breaks #6799

@robmcd

Description

@robmcd

Search before asking

  • I searched the issues and found no similar issues.

What Happened

sqlfluff fix didn't work

Expected Behaviour

fix should format the code as per my sqlfluff config

Observed Behaviour

==== parsing violations ====
L: 32 | P: 1 | PRS | Line 32, Position 1: Found unparsable section: 'MERGE INTO
| target_table\nUSING source_tab...'
WARNING: Parsing errors found and dialect is set to 'redshift'. Have you configured your dialect correctly?

How to reproduce


-- Create source and target tables
drop table if exists source_table;
CREATE TABLE source_table (
    id INT,
    name VARCHAR(50),
    value INT,
    updated_at TIMESTAMP
);

drop table if exists target_table;
CREATE TABLE target_table (
    id INT,
    name VARCHAR(50),
    value INT,
    updated_at TIMESTAMP
);

-- Insert sample data into source table
INSERT INTO source_table VALUES
    (1, 'Alice', 100, '2023-01-01 10:00:00'),
    (2, 'Bob', 200, '2023-01-01 11:00:00'),
    (3, 'Charlie', 300, '2023-01-01 12:00:00');

-- Insert sample data into target table
INSERT INTO target_table VALUES
    (1, 'Alice', 100, '2023-01-01 08:00:00'),
    (2, 'Bob', 180, '2023-01-01 09:00:00'),
    (4, 'David', 400, '2023-01-01 13:00:00');

MERGE INTO target_table
USING source_table AS source
ON target_table.id = source.id
REMOVE DUPLICATES;

sqlfluff.exe fix scratch_69.sql --show-lint-violations

no formatting occurred.

Dialect

redshift

Version

3.3.1

Configuration

N/A

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 workingredshiftIssues relating to Amazon Redshift dialect

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions