Skip to content

Commit

Permalink
API clone summary: replace illegal chars in clone query (#1899)
Browse files Browse the repository at this point in the history
Initial load UI for PG -> PG and SF would not load because dots weren't
replaced with underscores for clone name
This PR does the equivalent of our shared code which is used for clone
name construction:

```golang
// shared/string.go
var (
	reIllegalIdentifierCharacters = regexp.MustCompile("[^a-zA-Z0-9_]+")
	...
)

func ReplaceIllegalCharactersWithUnderscores(s string) string {
	return reIllegalIdentifierCharacters.ReplaceAllString(s, "_")
}
```

in the clone query:
```sql
WHERE qr.flow_name ^@ ($1||regexp_replace(qr.destination_table, '[^a-zA-Z0-9_]', '_', 'g'))
```

functionally tested
  • Loading branch information
Amogh-Bharadwaj authored Jul 3, 2024
1 parent 67026f4 commit e438e30
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion flow/cmd/mirror_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (h *FlowRequestHandler) cloneTableSummary(
AVG(EXTRACT(EPOCH FROM (qp.end_time - qp.start_time)) * 1000) FILTER (WHERE qp.end_time IS NOT NULL) AS AvgTimePerPartitionMs
FROM peerdb_stats.qrep_partitions qp
RIGHT JOIN peerdb_stats.qrep_runs qr ON qp.flow_name = qr.flow_name
WHERE qr.flow_name ^@ ($1||qr.destination_table)
WHERE qr.flow_name ^@ ($1||regexp_replace(qr.destination_table, '[^a-zA-Z0-9_]', '_', 'g'))
GROUP BY qr.flow_name, qr.destination_table, qr.source_table, qr.start_time, qr.fetch_complete, qr.consolidate_complete;
`
var flowName pgtype.Text
Expand Down

0 comments on commit e438e30

Please sign in to comment.