From 1d350b3384d8cf0b6d5929bd8e5a3083c0f0c916 Mon Sep 17 00:00:00 2001 From: Amogh-Bharadwaj Date: Mon, 27 Nov 2023 19:23:34 +0530 Subject: [PATCH 1/2] quote watermark table --- ui/app/mirrors/create/handlers.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ui/app/mirrors/create/handlers.ts b/ui/app/mirrors/create/handlers.ts index 3f90b37297..f65ecc8fd8 100644 --- a/ui/app/mirrors/create/handlers.ts +++ b/ui/app/mirrors/create/handlers.ts @@ -187,6 +187,15 @@ export const handleCreateCDC = async ( setLoading(false); }; +const quotedWatermarkTable = (watermarkTable: string): string => { + if (watermarkTable.includes('.')) { + const [schema, table] = watermarkTable.split('.'); + return `"${schema}"."${table}"`; + } else { + return `"${watermarkTable}"`; + } +}; + export const handleCreateQRep = async ( flowJobName: string, query: string, @@ -210,7 +219,9 @@ export const handleCreateQRep = async ( if (xmin == true) { config.watermarkColumn = 'xmin'; - config.query = `SELECT * FROM ${config.watermarkTable} WHERE xmin::text::bigint BETWEEN {{.start}} AND {{.end}}`; + config.query = `SELECT * FROM ${quotedWatermarkTable( + config.watermarkTable + )} WHERE xmin::text::bigint BETWEEN {{.start}} AND {{.end}}`; query = config.query; config.initialCopyOnly = false; } From 95aba751324f173e9c10f6e7c8eb34f14e79029c Mon Sep 17 00:00:00 2001 From: Amogh-Bharadwaj Date: Mon, 27 Nov 2023 21:41:39 +0530 Subject: [PATCH 2/2] quote watermark table and fix default dst tablename --- ui/app/mirrors/create/qrep/qrep.tsx | 33 +++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/ui/app/mirrors/create/qrep/qrep.tsx b/ui/app/mirrors/create/qrep/qrep.tsx index 993e7bc1aa..6b5b7b4b35 100644 --- a/ui/app/mirrors/create/qrep/qrep.tsx +++ b/ui/app/mirrors/create/qrep/qrep.tsx @@ -114,7 +114,17 @@ export default function QRepConfigForm({ ) => { if (val) { if (setting.label === 'Table') { - setter((curr) => ({ ...curr, destinationTableIdentifier: val })); + if (mirrorConfig.destinationPeer?.type === DBType.BIGQUERY) { + setter((curr) => ({ + ...curr, + destinationTableIdentifier: val.split('.')[1], + })); + } else { + setter((curr) => ({ + ...curr, + destinationTableIdentifier: val, + })); + } loadColumnOptions(val); } handleChange(val, setting); @@ -127,6 +137,20 @@ export default function QRepConfigForm({ ); }, [mirrorConfig.sourcePeer]); + useEffect(() => { + if (mirrorConfig.destinationPeer?.type === DBType.BIGQUERY) { + setter((curr) => ({ + ...curr, + destinationTableIdentifier: mirrorConfig.watermarkTable?.split('.')[1], + })); + } else { + setter((curr) => ({ + ...curr, + destinationTableIdentifier: mirrorConfig.watermarkTable, + })); + } + }, [mirrorConfig.destinationPeer, mirrorConfig.watermarkTable, setter]); + useEffect(() => { // set defaults setter((curr) => ({ ...curr, ...blankQRepSetting })); @@ -255,12 +279,7 @@ export default function QRepConfigForm({ type={setting.type} defaultValue={ setting.label === 'Destination Table Name' - ? mirrorConfig.destinationPeer?.type === - DBType.BIGQUERY - ? mirrorConfig.destinationTableIdentifier?.split( - '.' - )[1] - : mirrorConfig.destinationTableIdentifier + ? mirrorConfig.destinationTableIdentifier : setting.default } onChange={(e: React.ChangeEvent) =>