Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
94180: streamingccl: don't resume job in TestTenantStreamingCutoverOnSourceFailure r=adityamaru a=stevendanna

    ALTER TENANT ... COMPLETE REPLICATION

resumes the job for the user, so there is no need to resume the job here. This does raise the question about whether or not it is the right behaviour to resume the job by default.

Fixes #94034

Release note: None

95753: roachtest: fix env var passing in activerecord test r=srosenberg a=andyyang890

This patch fixes the rails version pinning in the activerecord
roachtest. The rails version is passed in via the env variable
`RAILS_VERSION` and was previously being set before the `sudo`
in the adapter install command and thus erroneously discarded.

Informs #94211

Release note: None

95773: multiregionccl: add a missing log scope r=ajwerner a=ajwerner

Epic: none

Release note: None

95802: builtins: array_to_string should traverse nested arrays r=yuzefovich a=msirek

Fixes #95588

In Postgres, `array_to_string` traverses nested arrays and prints their contents. In CRDB, the nested array structures are printed out. For example,
`SELECT array_to_string(ARRAY[ARRAY[ARRAY[5,6], ARRAY[2,3]]], ' ');`

CRDB Result: `ARRAY[ARRAY[5:::INT8,6:::INT8],ARRAY[2:::INT8,3:::INT8]]` Postgres Result: `5 6 2 3`

This fix brings the behavior of `array_to_string` in line with Postgres, and avoids printing the nested ARRAY structures.

Some tools like GoldenGate rely on Postgres-compatible  behavior of `array_to_string` for proper functioning.

Release note (bug fix): This patch fixes the array_to_string built-in function so that nested arrays are traversed without printing 'ARRAY' at each nesting level.

95824: sql/execinfrapb: remove no-effect nullable from GenerativeSplitAndScatterSpec r=rhu713 a=rhu713

Remove no-effect nullable from GenerativeSplitAndScatterSpec that was causing warning messages during build.

Release note: None

Co-authored-by: Steven Danna <[email protected]>
Co-authored-by: Andy Yang <[email protected]>
Co-authored-by: Andrew Werner <[email protected]>
Co-authored-by: Mark Sirek <[email protected]>
Co-authored-by: Rui Hu <[email protected]>
  • Loading branch information
6 people committed Jan 25, 2023
6 parents 1f0aeb4 + 9e84744 + 4d4539f + f907b7d + eb88269 + 3386c72 commit 6fc1022
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
1 change: 1 addition & 0 deletions pkg/ccl/multiregionccl/regional_by_row_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ USE t;
for _, rbrChange := range regionalByRowChanges {
for _, regionChange := range regionChanges {
t.Run(fmt.Sprintf("setup %s executing %s with racing %s", rbrChange.setup, rbrChange.cmd, regionChange.cmd), func(t *testing.T) {
defer log.Scope(t).Close(t)
interruptStartCh := make(chan struct{})
interruptEndCh := make(chan struct{})
performInterrupt := false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,9 +590,6 @@ func TestTenantStreamingCutoverOnSourceFailure(t *testing.T) {
cutoverOutput := replicationtestutils.DecimalTimeToHLC(t, cutoverStr)
require.Equal(c.T, cutoverTime, cutoverOutput)

// Resume ingestion.
c.DestSysSQL.Exec(t, fmt.Sprintf("RESUME JOB %d", ingestionJobID))

// Ingestion job should succeed despite source failure due to the successful cutover
jobutils.WaitForJobToSucceed(t, c.DestSysSQL, jobspb.JobID(ingestionJobID))
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/cmd/roachtest/tests/activerecord.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func registerActiveRecord(r registry.Registry) {
"installing gems",
fmt.Sprintf(
`cd /mnt/data1/activerecord-cockroachdb-adapter/ && `+
`RAILS_VERSION=%s sudo bundle install`, supportedRailsVersion),
`sudo RAILS_VERSION=%s bundle install`, supportedRailsVersion),
); err != nil {
t.Fatal(err)
}
Expand All @@ -172,8 +172,9 @@ func registerActiveRecord(r registry.Registry) {
t.Status("running activerecord test suite")

result, err := c.RunWithDetailsSingleNode(ctx, t.L(), node,
`cd /mnt/data1/activerecord-cockroachdb-adapter/ && `+
`sudo RUBYOPT="-W0" TESTOPTS="-v" bundle exec rake test`,
fmt.Sprintf(
`cd /mnt/data1/activerecord-cockroachdb-adapter/ && `+
`sudo RAILS_VERSION=%s RUBYOPT="-W0" TESTOPTS="-v" bundle exec rake test`, supportedRailsVersion),
)

// Fatal for a roachprod or SSH error. A roachprod error is when result.Err==nil.
Expand Down
2 changes: 1 addition & 1 deletion pkg/sql/execinfrapb/processors_bulk_io.proto
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ message GenerativeSplitAndScatterSpec {
repeated roachpb.Span spans = 10 [(gogoproto.nullable) = false];
repeated jobs.jobspb.RestoreDetails.BackupLocalityInfo backup_locality_info = 11 [(gogoproto.nullable) = false];
// HighWater is the high watermark of the previous run of restore.
optional bytes high_water = 12 [(gogoproto.nullable) = false];
optional bytes high_water = 12;
// User who initiated the restore.
optional string user_proto = 13 [(gogoproto.nullable) = false, (gogoproto.casttype) = "github.com/cockroachdb/cockroach/pkg/security/username.SQLUsernameProto"];
// ChunkSize is the number of import spans per chunk.
Expand Down
12 changes: 12 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/builtin_function
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,18 @@ SELECT array_to_string(NULL, ','), array_to_string(NULL, 'foo', 'zerp')
----
NULL NULL

# Builtin array_to_string should recursively search nested arrays.
query T
SELECT array_to_string(ARRAY[ARRAY[ARRAY[5,6], ARRAY[2,3]], ARRAY[ARRAY[7,8], ARRAY[4,44]]], ' ');
----
5 6 2 3 7 8 4 44

# Builtin array_to_string should recursively search nested arrays.
query T
SELECT array_to_string(ARRAY[(SELECT ARRAY[1,2]::int2vector)],' ');
----
1 2

# Examples from https://www.postgresql.org/docs/9.3/functions-string.html#FUNCTIONS-STRING-FORMAT
query T
SELECT format('Hello %s', 'World')
Expand Down
15 changes: 13 additions & 2 deletions pkg/sql/sem/builtins/builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -9860,6 +9860,13 @@ func arrayToString(
evalCtx *eval.Context, arr *tree.DArray, delim string, nullStr *string,
) (tree.Datum, error) {
f := evalCtx.FmtCtx(tree.FmtArrayToString)
arrayToStringHelper(evalCtx, arr, delim, nullStr, f)
return tree.NewDString(f.CloseAndGetString()), nil
}

func arrayToStringHelper(
evalCtx *eval.Context, arr *tree.DArray, delim string, nullStr *string, f *tree.FmtCtx,
) {

for i := range arr.Array {
if arr.Array[i] == tree.DNull {
Expand All @@ -9868,13 +9875,17 @@ func arrayToString(
}
f.WriteString(*nullStr)
} else {
f.FormatNode(arr.Array[i])
if nestedArray, ok := arr.Array[i].(*tree.DArray); ok {
// "Unpack" nested arrays to be consistent with postgres.
arrayToStringHelper(evalCtx, nestedArray, delim, nullStr, f)
} else {
f.FormatNode(arr.Array[i])
}
}
if i < len(arr.Array)-1 {
f.WriteString(delim)
}
}
return tree.NewDString(f.CloseAndGetString()), nil
}

// encodeEscape implements the encode(..., 'escape') Postgres builtin. It's
Expand Down

0 comments on commit 6fc1022

Please sign in to comment.