diff --git a/ui/app/mirrors/create/tablemapping.tsx b/ui/app/mirrors/create/tablemapping.tsx index e8c392570..4919702fb 100644 --- a/ui/app/mirrors/create/tablemapping.tsx +++ b/ui/app/mirrors/create/tablemapping.tsx @@ -78,8 +78,7 @@ const TableMapping = ({ // find the row with source and update the destination const newRows = [...rows]; const index = newRows.findIndex((row) => row.source === source); - let dstName = peerType == DBType.BIGQUERY ? dest : `${schema}.${dest}`; - newRows[index].destination = dstName; + newRows[index].destination = dest; return newRows; }; @@ -95,14 +94,22 @@ const TableMapping = ({ fetchTables(sourcePeerName, schemaName, setLoading).then((tableNames) => setRows((curr) => { const newRows = [...curr]; + tableNames.forEach((tableName) => { const row = newRows.find( (row) => row.source === `${schemaName}.${tableName}` ); if (!row) { + const dstName = + peerType != undefined && dBTypeToJSON(peerType) == 'BIGQUERY' + ? tableName + : `${schemaName}.${tableName}`; newRows.push({ source: `${schemaName}.${tableName}`, - destination: `${schemaName}.${tableName}`, + destination: + peerType != undefined && dBTypeToJSON(peerType) == 'BIGQUERY' + ? tableName + : `${schemaName}.${tableName}`, partitionKey: '', selected: false, }); @@ -112,7 +119,7 @@ const TableMapping = ({ }) ); }, - [sourcePeerName, setRows] + [sourcePeerName, setRows, peerType] ); const [searchQuery, setSearchQuery] = useState(''); @@ -121,6 +128,36 @@ const TableMapping = ({ return row.source.toLowerCase().includes(searchQuery.toLowerCase()); }); + useEffect(() => { + if (peerType != undefined && dBTypeToJSON(peerType) == 'BIGQUERY') { + setRows((rows) => { + const newRows = [...rows]; + newRows.forEach((_, i) => { + const row = newRows[i]; + newRows[i] = { + ...row, + destination: row.destination.split('.')[1], + }; + }); + return newRows; + }); + } else { + setRows((rows) => { + const newRows = [...rows]; + newRows.forEach((_, i) => { + const row = newRows[i]; + newRows[i] = { + ...row, + destination: `${schema}.${ + row.destination.split('.')[1] || row.destination + }`, + }; + }); + return newRows; + }); + } + }, [peerType, setRows, schema]); + useEffect(() => { fetchSchemas(sourcePeerName, setLoading).then((res) => setAllSchemas(res)); setSchema('public');