-
Notifications
You must be signed in to change notification settings - Fork 202
ISSUE-2103 Handle trailing and trailing statement comments #2108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
spatel11
wants to merge
45
commits into
dataform-co:main
Choose a base branch
from
spatel11:iss-2103
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
6642a03
ISSUE-2103 Handle trailing and trailing statement comments
spatel11 a71284a
Merge branch 'main' into iss-2103
spatel11 4fb904f
Merge branch 'main' into iss-2103
spatel11 237a5ee
Bump vm2 from 3.10.2 to 3.11.3 (#2168)
dependabot[bot] 60b69bf
Bump DF_VERSION from 3.0.56 to 3.0.57 (#2173)
rafal-hawrylak f1bfb2e
Support onSchemaChange for incremental tables (#2101)
SuchodolskiEdvin c8d5d6a
feat: implement .jitCode() support for Assertion actions (#2170)
rafal-hawrylak bbbc192
fix: Resolve presubmit failure introduced by PR #2101
SuchodolskiEdvin 62b18ba
Bump DF_VERSION from 3.0.57 to 3.0.58 (#2176)
rafal-hawrylak 8d43204
Guard workflow_settings.yaml and dataform.json require with existence…
rafal-hawrylak 3226940
Refactor CompileChildProcess to use BaseWorker (#2179)
rafal-hawrylak b50f212
Rename worker timeout error to "Compilation timed out" (#2186)
rafal-hawrylak f2c8431
Extract task creation into executionSql helpers (#2180)
rafal-hawrylak a2f8d70
Add JiT compilation support for assertion actions (#2193)
rafal-hawrylak 4ad875e
Fix caller-file error (#2177) and enforce Core/CLI version match (#2191)
rafal-hawrylak 00b33a3
Raise default compile timeout to 60s and improve timeout error messag…
rafal-hawrylak c8f0b29
Bump DF_VERSION from 3.0.58 to 3.0.59 (#2194)
rafal-hawrylak 5ab292f
Bump vm2 from 3.11.3 to 3.11.4 (#2188)
dependabot[bot] 97a4c22
Extract BigQueryClientProvider for injectable BQ clients (#2181)
rafal-hawrylak 1730f58
Bump protobufjs from 7.5.5 to 7.5.8 (#2172)
dependabot[bot] c6c226c
Add go_package option to db_adapter.proto and jit.proto (#2197)
kolina 320af99
Migrate to bazel 7.3.2 (#2187)
ikholopov-omni 9d9f48b
Update gcloud to 572.0.0 (#2207)
ikholopov-omni c4af15e
Add metadata field to AssertionConfig (#2208)
rafal-hawrylak 5afdeb4
Bump DF_VERSION from 3.0.59 to 3.0.60 (#2209)
rafal-hawrylak 45a6aba
Ignore trailing positional arguments in the global flag parser (#2199)
aicayzer bcd3716
Bump protobufjs-cli from 1.0.0 to 1.3.3 (#2202)
dependabot[bot] a8cd8f3
Bump js-yaml from 4.1.1 to 4.2.0 (#2205)
dependabot[bot] 2276440
feat: add getContents() for reading external markdown files into tabl…
AmmanuelT 3da6b13
Bump protobufjs from 7.5.8 to 7.6.3 (#2204)
dependabot[bot] 427ebba
feat(gcloud): support client certificate environment in gcloud action…
kolina e7444f9
Prevent .sqlx files in actions.yaml configs with a clear error (#2189)
aicayzer cce5b9f
Bump tmp from 0.2.4 to 0.2.7 (#2183)
dependabot[bot] 6da16ea
Bump @tootallnate/once from 2.0.0 to 2.0.1 (#2171)
dependabot[bot] 7b4c045
Bump fast-uri from 3.0.6 to 3.1.2 (#2161)
dependabot[bot] ed868f0
Merge branch 'main' into iss-2103
spatel11 aaefb9d
remove extra utils_test.ts from api build
spatel11 6b3fd34
allow pbts command to run on mac
spatel11 5c4d7c5
refactor concatenateQueries to be a bit more readable
spatel11 60bfef3
update on_schema_change tests to reflect the new format
spatel11 585f786
update format for api spec
spatel11 3c7bbbc
replace drop table in statement comment test because it was causing a…
spatel11 59a5ebd
add new tests for comments within a query
spatel11 4ceac97
update test count in bigquery spec
spatel11 c19998f
multi line comment tests
spatel11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import { expect } from "chai"; | ||
|
|
||
| import { concatenateQueries } from "df/cli/api/dbadapters/tasks"; | ||
| import { suite, test } from "df/testing"; | ||
|
|
||
| suite("concatenateQueries", () => { | ||
| test("adds semicolons to non-last statements and joins with newlines", () => { | ||
| expect(concatenateQueries(["SELECT 1", "SELECT 2"])).deep.equals( | ||
| "SELECT 1;\nSELECT 2" | ||
| ); | ||
| }); | ||
|
|
||
| test("does not add semicolon to the last statement", () => { | ||
| expect(concatenateQueries(["SELECT 1", "SELECT 2", "SELECT 3"])).deep.equals( | ||
| "SELECT 1;\nSELECT 2;\nSELECT 3" | ||
| ); | ||
| }); | ||
|
|
||
| test("preserves existing semicolons on non-last statements", () => { | ||
| expect(concatenateQueries(["SELECT 1;", "SELECT 2"])).deep.equals( | ||
| "SELECT 1;\nSELECT 2" | ||
| ); | ||
| }); | ||
|
|
||
| test("preserves existing semicolons on last statement", () => { | ||
| expect(concatenateQueries(["SELECT 1;", "SELECT 2;"])).deep.equals( | ||
| "SELECT 1;\nSELECT 2;" | ||
| ); | ||
| }); | ||
|
|
||
| test("adds semicolon before trailing comment if necessary, verifies fix for https://github.com/dataform-co/dataform/issues/1231", () => { | ||
| expect(concatenateQueries(["SELECT 1 -- blah", "drop table foo; -- baz", "SELECT 2"])).deep.equals( | ||
| "SELECT 1; -- blah\ndrop table foo; -- baz\nSELECT 2" | ||
| ); | ||
| }); | ||
|
|
||
| test("preserves comment-only lines, verifies fix for https://github.com/dataform-co/dataform/issues/2103", () => { | ||
| expect(concatenateQueries(["SELECT 1;", "--drop table foo", "SELECT 2", "--baz"])).deep.equals( | ||
| "SELECT 1;\n--drop table foo\nSELECT 2;\n--baz" | ||
| ); | ||
| }); | ||
|
|
||
| test("preserves single line comments within a query", () => { | ||
| expect(concatenateQueries(["SELECT 1\n--test\nFROM UNNEST([]);"])).deep.equals( | ||
| "SELECT 1\n--test\nFROM UNNEST([]);" | ||
| ); | ||
| }); | ||
|
|
||
| test("preserves multi line comments within a query", () => { | ||
| expect(concatenateQueries(["SELECT 1\n\*multi\nline\ncomment\n*/\nFROM UNNEST([]);"])).deep.equals( | ||
| "SELECT 1\n\*multi\nline\ncomment\n*/\nFROM UNNEST([]);" | ||
| ); | ||
| }); | ||
|
|
||
| test("trims whitespace from statements", () => { | ||
| expect(concatenateQueries([" SELECT 1 ", " SELECT 2 ", " SELECT 3 -- blah"])).deep.equals( | ||
| "SELECT 1;\nSELECT 2;\nSELECT 3 -- blah" | ||
| ); | ||
| }); | ||
|
|
||
| test("filters out empty and falsy statements", () => { | ||
| expect(concatenateQueries(["SELECT 1", "", "SELECT 2"])).deep.equals( | ||
| "SELECT 1;\nSELECT 2" | ||
| ); | ||
| expect(concatenateQueries(["SELECT 1", undefined, "SELECT 2"])).deep.equals( | ||
| "SELECT 1;\nSELECT 2" | ||
| ); | ||
| }); | ||
|
|
||
| test("returns empty string for empty input", () => { | ||
| expect(concatenateQueries([])).deep.equals(""); | ||
| }); | ||
|
|
||
| test("returns single statement without semicolon", () => { | ||
| expect(concatenateQueries(["SELECT 1"])).deep.equals("SELECT 1"); | ||
| }); | ||
|
|
||
| test("applies modifier to code portion of each statement", () => { | ||
| expect( | ||
| concatenateQueries(["SELECT 1", "SELECT 2"], stmt => `(${stmt})`) | ||
| ).deep.equals("(SELECT 1);\n(SELECT 2)"); | ||
| }); | ||
|
|
||
| test("applies modifier only to code portion, not comment", () => { | ||
| expect( | ||
| concatenateQueries(["SELECT 1 --comment", "SELECT 2"], stmt => `(${stmt})`) | ||
| ).deep.equals("(SELECT 1); --comment\n(SELECT 2)"); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
tests/integration/bigquery_project/definitions/example_internal_comment_in_query.sqlx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| config { | ||
| type: "table", | ||
| description: "Verifies fix for https://github.com/dataform-co/dataform/issues/1231" | ||
| } | ||
|
|
||
| post_operations { | ||
| select * | ||
| -- single line comment | ||
| /* | ||
| multi | ||
| line | ||
| comment | ||
| */ | ||
| from ${self()} | ||
| } | ||
|
|
||
| select 1 as col1 | ||
| -- single line comment | ||
| /* | ||
| multi | ||
| line | ||
| comment | ||
| */ | ||
| FROM UNNEST([]) |
13 changes: 13 additions & 0 deletions
13
tests/integration/bigquery_project/definitions/example_trailing_comment_in_operations.sqlx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| config { | ||
| "type": "table", | ||
| "description": "Verifies fix for https://github.com/dataform-co/dataform/issues/2103" | ||
| } | ||
|
|
||
| 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)) | ||
| } |
12 changes: 12 additions & 0 deletions
12
...tion/bigquery_project/definitions/example_trailing_statement_comment_with_operations.sqlx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| config { | ||
| type: "table", | ||
| schema: "test", | ||
| name: "testtab", | ||
| description: "Verifies fix for https://github.com/dataform-co/dataform/issues/1231" | ||
| } | ||
|
|
||
| post_operations { | ||
| select * from ${self()} | ||
| } | ||
|
|
||
| select 1 as col1 -- test comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.