Skip to content

Commit

Permalink
QRep UI: Validate schema qualification (#1595)
Browse files Browse the repository at this point in the history
This PR adds schema qualification verification for QRep destination
table field.

<img width="1285" alt="Screenshot 2024-04-10 at 11 05 46 PM"
src="https://github.com/PeerDB-io/peerdb/assets/65964360/eb569366-6ad2-4964-b362-4565600622f3">
<img width="1285" alt="Screenshot 2024-04-10 at 11 06 12 PM"
src="https://github.com/PeerDB-io/peerdb/assets/65964360/1e016c47-0ba3-4b74-89ce-305279bb8712">

---------

Co-authored-by: Kevin Biju <52661649+heavycrystal@users.noreply.github.com>
  • Loading branch information
Amogh-Bharadwaj and heavycrystal committed Apr 14, 2024
1 parent 7a9356e commit 52a2066
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions ui/app/mirrors/create/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
UTablesResponse,
} from '@/app/dto/PeersDTO';
import { notifyErr } from '@/app/utils/notify';
import { DBTypeToGoodText } from '@/components/PeerTypeComponent';
import {
FlowConnectionConfigs,
QRepConfig,
Expand Down Expand Up @@ -229,6 +230,26 @@ export const handleCreateQRep = async (
config.flowJobName = flowJobName;
config.query = query;

const isSchemaLessPeer =
config.destinationPeer?.type === DBType.BIGQUERY ||
config.destinationPeer?.type === DBType.CLICKHOUSE;
if (isSchemaLessPeer && config.destinationTableIdentifier?.includes('.')) {
notifyErr(
'Destination table should not be schema qualified for ' +
DBTypeToGoodText(config.destinationPeer?.type) +
' targets'
);
return;
}
if (!isSchemaLessPeer && !config.destinationTableIdentifier?.includes('.')) {
notifyErr(
'Destination table should be schema qualified for ' +
DBTypeToGoodText(config.destinationPeer?.type) +
' targets'
);
return;
}

setLoading(true);
const statusMessage: UCreateMirrorResponse = await fetch(
'/api/mirrors/qrep',
Expand Down
2 changes: 1 addition & 1 deletion ui/components/PeerTypeComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Label } from '@/lib/Label';
import Image from 'next/image';
import { DBTypeToImageMapping } from './PeerComponent';

export const DBTypeToGoodText = (ptype: DBType) => {
export const DBTypeToGoodText = (ptype?: DBType) => {
switch (ptype) {
case DBType.POSTGRES:
return 'PostgreSQL';
Expand Down

0 comments on commit 52a2066

Please sign in to comment.