diff --git a/pkg/ccl/changefeedccl/changefeed_test.go b/pkg/ccl/changefeedccl/changefeed_test.go index da987743befb..67ca1b6096bc 100644 --- a/pkg/ccl/changefeedccl/changefeed_test.go +++ b/pkg/ccl/changefeedccl/changefeed_test.go @@ -5155,15 +5155,15 @@ func TestChangefeedDescription(t *testing.T) { }{ { create: "CREATE CHANGEFEED FOR foo INTO $1 WITH updated, envelope = $2", - descr: `CREATE CHANGEFEED FOR TABLE foo INTO '` + redactedSink + `' WITH envelope = 'wrapped', updated`, + descr: `CREATE CHANGEFEED FOR TABLE foo INTO '` + redactedSink + `' WITH OPTIONS (envelope = 'wrapped', updated)`, }, { create: "CREATE CHANGEFEED FOR public.foo INTO $1 WITH updated, envelope = $2", - descr: `CREATE CHANGEFEED FOR TABLE public.foo INTO '` + redactedSink + `' WITH envelope = 'wrapped', updated`, + descr: `CREATE CHANGEFEED FOR TABLE public.foo INTO '` + redactedSink + `' WITH OPTIONS (envelope = 'wrapped', updated)`, }, { create: "CREATE CHANGEFEED FOR d.public.foo INTO $1 WITH updated, envelope = $2", - descr: `CREATE CHANGEFEED FOR TABLE d.public.foo INTO '` + redactedSink + `' WITH envelope = 'wrapped', updated`, + descr: `CREATE CHANGEFEED FOR TABLE d.public.foo INTO '` + redactedSink + `' WITH OPTIONS (envelope = 'wrapped', updated)`, }, { // TODO(#85143): remove schema_change_policy='stop' from this test. diff --git a/pkg/ccl/changefeedccl/scheduled_changefeed_test.go b/pkg/ccl/changefeedccl/scheduled_changefeed_test.go index 535fd118844d..2ccc67efda68 100644 --- a/pkg/ccl/changefeedccl/scheduled_changefeed_test.go +++ b/pkg/ccl/changefeedccl/scheduled_changefeed_test.go @@ -194,8 +194,8 @@ func TestSerializesScheduledChangefeedExecutionArgs(t *testing.T) { query: "CREATE SCHEDULE FOR CHANGEFEED d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH initial_scan='only' RECURRING '@hourly'", es: expectedSchedule{ nameRe: "CHANGEFEED .+", - changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH initial_scan = 'only'", - shownStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=redacted' WITH initial_scan = 'only'", + changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH OPTIONS (initial_scan = 'only')", + shownStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=redacted' WITH OPTIONS (initial_scan = 'only')", period: time.Hour, }, }, @@ -204,7 +204,7 @@ func TestSerializesScheduledChangefeedExecutionArgs(t *testing.T) { query: "CREATE SCHEDULE FOR CHANGEFEED foo INTO 'webhook-https://0/changefeed' WITH initial_scan = 'only' RECURRING '@hourly'", es: expectedSchedule{ nameRe: "CHANGEFEED .+", - changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed' WITH initial_scan = 'only'", + changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed' WITH OPTIONS (initial_scan = 'only')", period: time.Hour, }, }, @@ -220,8 +220,8 @@ func TestSerializesScheduledChangefeedExecutionArgs(t *testing.T) { queryArgs: []interface{}{th.env.Now()}, es: expectedSchedule{ nameRe: "foo-changefeed", - changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH format = 'JSON', initial_scan = 'only'", - shownStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=redacted' WITH format = 'JSON', initial_scan = 'only'", + changefeedStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=nevershown' WITH OPTIONS (format = 'JSON', initial_scan = 'only')", + shownStmt: "CREATE CHANGEFEED FOR TABLE d.public.foo INTO 'webhook-https://0/changefeed?AWS_SECRET_ACCESS_KEY=redacted' WITH OPTIONS (format = 'JSON', initial_scan = 'only')", period: time.Hour, runsNow: true, }, diff --git a/pkg/ccl/changefeedccl/show_changefeed_jobs_test.go b/pkg/ccl/changefeedccl/show_changefeed_jobs_test.go index 3a167d72c1d8..6573f42b4a43 100644 --- a/pkg/ccl/changefeedccl/show_changefeed_jobs_test.go +++ b/pkg/ccl/changefeedccl/show_changefeed_jobs_test.go @@ -419,7 +419,7 @@ func TestShowChangefeedJobsAlterChangefeed(t *testing.T) { out = obtainJobRowFn() require.Equal(t, jobID, out.id, "Expected id:%d but found id:%d", jobID, out.id) - require.Equal(t, "CREATE CHANGEFEED FOR TABLE d.public.bar INTO 'kafka://does.not.matter/' WITH resolved = '5s'", out.description, "Expected description:%s but found description:%s", "CREATE CHANGEFEED FOR TABLE bar INTO 'kafka://does.not.matter/ WITH resolved = '5s''", out.description) + require.Equal(t, "CREATE CHANGEFEED FOR TABLE d.public.bar INTO 'kafka://does.not.matter/' WITH OPTIONS (resolved = '5s')", out.description, "Expected description:%s but found description:%s", "CREATE CHANGEFEED FOR TABLE bar INTO 'kafka://does.not.matter/ WITH resolved = '5s''", out.description) require.Equal(t, sinkURI, out.SinkURI, "Expected sinkUri:%s but found sinkUri:%s", sinkURI, out.SinkURI) require.Equal(t, "bar", out.topics, "Expected topics:%s but found topics:%s", "bar", sortedTopics) require.Equal(t, "{d.public.bar}", string(out.FullTableNames), "Expected fullTableNames:%s but found fullTableNames:%s", "{d.public.bar}", string(out.FullTableNames)) diff --git a/pkg/ccl/logictestccl/testdata/logic_test/changefeed b/pkg/ccl/logictestccl/testdata/logic_test/changefeed index e0a07c061eb2..1f7b6f64608f 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/changefeed +++ b/pkg/ccl/logictestccl/testdata/logic_test/changefeed @@ -59,9 +59,9 @@ SELECT job_id FROM [SHOW CHANGEFEED JOBS] WHERE user_name = 'testuser' query TT SELECT user_name, description FROM [SHOW CHANGEFEED JOB $job_id] ---- -testuser CREATE CHANGEFEED FOR TABLE t INTO 'null://sink' WITH initial_scan = 'only' +testuser CREATE CHANGEFEED FOR TABLE t INTO 'null://sink' WITH OPTIONS (initial_scan = 'only') query TT SELECT user_name, description FROM [SHOW CHANGEFEED JOBS] ---- -testuser CREATE CHANGEFEED FOR TABLE t INTO 'null://sink' WITH initial_scan = 'only' \ No newline at end of file +testuser CREATE CHANGEFEED FOR TABLE t INTO 'null://sink' WITH OPTIONS (initial_scan = 'only') diff --git a/pkg/sql/parser/testdata/changefeed b/pkg/sql/parser/testdata/changefeed index 96e3ccec16ba..284ce341fc18 100644 --- a/pkg/sql/parser/testdata/changefeed +++ b/pkg/sql/parser/testdata/changefeed @@ -62,10 +62,10 @@ CREATE CHANGEFEED FOR TABLE _ INTO 'sink' -- identifiers removed parse CREATE CHANGEFEED FOR TABLE foo INTO 'sink' WITH bar = 'baz' ---- -CREATE CHANGEFEED FOR TABLE foo INTO 'sink' WITH bar = 'baz' -CREATE CHANGEFEED FOR TABLE (foo) INTO ('sink') WITH bar = ('baz') -- fully parenthesized -CREATE CHANGEFEED FOR TABLE foo INTO '_' WITH bar = '_' -- literals removed -CREATE CHANGEFEED FOR TABLE _ INTO 'sink' WITH _ = 'baz' -- identifiers removed +CREATE CHANGEFEED FOR TABLE foo INTO 'sink' WITH OPTIONS (bar = 'baz') -- normalized! +CREATE CHANGEFEED FOR TABLE (foo) INTO ('sink') WITH OPTIONS (bar = ('baz')) -- fully parenthesized +CREATE CHANGEFEED FOR TABLE foo INTO '_' WITH OPTIONS (bar = '_') -- literals removed +CREATE CHANGEFEED FOR TABLE _ INTO 'sink' WITH OPTIONS (_ = 'baz') -- identifiers removed parse CREATE CHANGEFEED AS SELECT * FROM foo diff --git a/pkg/sql/parser/testdata/import_export b/pkg/sql/parser/testdata/import_export index 7a13627edff9..a1863dd52b63 100644 --- a/pkg/sql/parser/testdata/import_export +++ b/pkg/sql/parser/testdata/import_export @@ -81,15 +81,15 @@ EXPORT INTO CSV 'a' FROM SELECT * FROM _ -- identifiers removed parse EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM TABLE a ---- -EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM TABLE a -EXPORT INTO CSV ('s3://my/path/%part%.csv') WITH delimiter = ('|') FROM TABLE a -- fully parenthesized -EXPORT INTO CSV '_' WITH delimiter = '_' FROM TABLE a -- literals removed -EXPORT INTO CSV 's3://my/path/%part%.csv' WITH _ = '|' FROM TABLE _ -- identifiers removed +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH OPTIONS(delimiter = '|') FROM TABLE a -- normalized! +EXPORT INTO CSV ('s3://my/path/%part%.csv') WITH OPTIONS(delimiter = ('|')) FROM TABLE a -- fully parenthesized +EXPORT INTO CSV '_' WITH OPTIONS(delimiter = '_') FROM TABLE a -- literals removed +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH OPTIONS(_ = '|') FROM TABLE _ -- identifiers removed parse EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM SELECT a, sum(b) FROM c WHERE d = 1 ORDER BY sum(b) DESC LIMIT 10 ---- -EXPORT INTO CSV 's3://my/path/%part%.csv' WITH delimiter = '|' FROM SELECT a, sum(b) FROM c WHERE d = 1 ORDER BY sum(b) DESC LIMIT 10 -EXPORT INTO CSV ('s3://my/path/%part%.csv') WITH delimiter = ('|') FROM SELECT (a), (sum((b))) FROM c WHERE ((d) = (1)) ORDER BY (sum((b))) DESC LIMIT (10) -- fully parenthesized -EXPORT INTO CSV '_' WITH delimiter = '_' FROM SELECT a, sum(b) FROM c WHERE d = _ ORDER BY sum(b) DESC LIMIT _ -- literals removed -EXPORT INTO CSV 's3://my/path/%part%.csv' WITH _ = '|' FROM SELECT _, sum(_) FROM _ WHERE _ = 1 ORDER BY sum(_) DESC LIMIT 10 -- identifiers removed +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH OPTIONS(delimiter = '|') FROM SELECT a, sum(b) FROM c WHERE d = 1 ORDER BY sum(b) DESC LIMIT 10 -- normalized! +EXPORT INTO CSV ('s3://my/path/%part%.csv') WITH OPTIONS(delimiter = ('|')) FROM SELECT (a), (sum((b))) FROM c WHERE ((d) = (1)) ORDER BY (sum((b))) DESC LIMIT (10) -- fully parenthesized +EXPORT INTO CSV '_' WITH OPTIONS(delimiter = '_') FROM SELECT a, sum(b) FROM c WHERE d = _ ORDER BY sum(b) DESC LIMIT _ -- literals removed +EXPORT INTO CSV 's3://my/path/%part%.csv' WITH OPTIONS(_ = '|') FROM SELECT _, sum(_) FROM _ WHERE _ = 1 ORDER BY sum(_) DESC LIMIT 10 -- identifiers removed diff --git a/pkg/sql/sem/tree/changefeed.go b/pkg/sql/sem/tree/changefeed.go index c9cfbad57ed0..4a1150d6a402 100644 --- a/pkg/sql/sem/tree/changefeed.go +++ b/pkg/sql/sem/tree/changefeed.go @@ -47,8 +47,9 @@ func (node *CreateChangefeed) Format(ctx *FmtCtx) { ctx.FormatNode(node.SinkURI) } if node.Options != nil { - ctx.WriteString(" WITH ") + ctx.WriteString(" WITH OPTIONS (") ctx.FormatNode(&node.Options) + ctx.WriteString(")") } } diff --git a/pkg/sql/sem/tree/export.go b/pkg/sql/sem/tree/export.go index e5c5541ceacd..9b592ff65ad6 100644 --- a/pkg/sql/sem/tree/export.go +++ b/pkg/sql/sem/tree/export.go @@ -27,8 +27,9 @@ func (node *Export) Format(ctx *FmtCtx) { ctx.WriteString(" ") ctx.FormatNode(node.File) if node.Options != nil { - ctx.WriteString(" WITH ") + ctx.WriteString(" WITH OPTIONS(") ctx.FormatNode(&node.Options) + ctx.WriteString(")") } ctx.WriteString(" FROM ") ctx.FormatNode(node.Query)