Skip to content

Dataform CLI run (dry) fails when trailing comments are in pre_operations #2103

@spatel11

Description

@spatel11

Dataform core version 3.0.47

This definition will fail when running dataform run --dry-run

config {
  "type": "table",
}

SELECT 1 AS foo

pre_operations {

  DECLARE bar DATE DEFAULT DATE_TRUNC(CURRENT_DATE(), WEEK(MONDAY));

  -- DECLARE bar DATE DEFAULT DATE_TRUNC(DATE('2026-01-01'), WEEK(MONDAY))
}

Dataset creation failed: test.trailing_comment_test [table]
DECLARE bar DATE DEFAULT DATE_TRUNC(CURRENT_DATE(), WEEK(MONDAY));

-- DECLARE bar DATE DEFAULT DATE_TRUNC(DATE('2026-01-01'), WEEK(MONDAY))
;
create or replace table projectid.test.trailing_comment_test as

SELECT 1 AS foo
bigquery error: Syntax error: Unexpected ";" at [4:1]

It will also fail with:

DECLARE bar DATE DEFAULT DATE_TRUNC(CURRENT_DATE(), WEEK(MONDAY))

---

  -- DECLARE bar DATE DEFAULT DATE_TRUNC(DATE('2026-01-01'), WEEK(MONDAY))

Dataset creation failed: test.trailing_comment_test [table]
DECLARE bar DATE DEFAULT DATE_TRUNC(CURRENT_DATE(), WEEK(MONDAY))
;
-- DECLARE bar DATE DEFAULT DATE_TRUNC(DATE('2026-01-01'), WEEK(MONDAY))
;
create or replace table projectid.test.trailing_comment_test as

SELECT 1 AS foo
bigquery error: Syntax error: Unexpected ";" at [4:1]

both forms will work in the GCP dataform service (they'll compile and run).

Moving the comment above the declaration works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions