Skip to content

ISSUE-2103 Handle trailing and trailing statement comments#2108

Open
spatel11 wants to merge 3 commits into
dataform-co:mainfrom
spatel11:iss-2103
Open

ISSUE-2103 Handle trailing and trailing statement comments#2108
spatel11 wants to merge 3 commits into
dataform-co:mainfrom
spatel11:iss-2103

Conversation

@spatel11

@spatel11 spatel11 commented Mar 9, 2026

Copy link
Copy Markdown

This PR fixes an issue with trailing comments in (at least) pre_operations blocks. It adds tests for the existing task.concatenateQueries function, and some example definitions in the integration tests.

Should fix: #2103
While preserving fix for: #1231

@google-cla

google-cla Bot commented Mar 9, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@spatel11 spatel11 marked this pull request as ready for review June 8, 2026 21:29
@spatel11 spatel11 requested a review from a team as a code owner June 8, 2026 21:29
@spatel11 spatel11 requested review from Ceridan and removed request for a team June 8, 2026 21:30
@kolina

kolina commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

/gcbrun

@kolina kolina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@@ -1,16 +1,44 @@
import { dataform } from "df/protos/ts";

export function concatenateQueries(statements: string[], modifier?: (mod: string) => string) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this logic will need to be made more complicated because there can be multiple comments in one statement https://docs.cloud.google.com/bigquery/docs/reference/standard-sql/lexical#comments.

You may have something like:

SELECT a
-- my comment
FROM table

To fix your specific issue, we'd need to find the last comment in SQL statement and check if there are any new lines in the statement after it.

}
return code || comment;
})
.join("\n");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Having 2 new lines makes sense here for better readability

@kolina kolina removed the request for review from Ceridan June 27, 2026 14:34
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.

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

2 participants