From 7631a19c44a9674132b30ee277be60a526402b84 Mon Sep 17 00:00:00 2001 From: Bobby Date: Fri, 30 Apr 2021 02:36:50 +1000 Subject: [PATCH] fix bigquery spark update and url issue --- ft_build/sparksLib/bigqueryIndex.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ft_build/sparksLib/bigqueryIndex.ts b/ft_build/sparksLib/bigqueryIndex.ts index aff63926..43c68d39 100644 --- a/ft_build/sparksLib/bigqueryIndex.ts +++ b/ft_build/sparksLib/bigqueryIndex.ts @@ -91,6 +91,7 @@ const transformToSQLValue = (value: any, ftType: string) => { case "RICH_TEXT": case "ID": case "SINGLE_SELECT": + case "URL": // STRING return `"${sanitise(value)}"`; case "JSON": @@ -174,13 +175,12 @@ const bigqueryIndex = async (payload, sparkContext) => { console.log(res); } - async function update(data: Record) { - const keys = Object.keys(data); - const dictValues = Array.from(Array(keys.length).keys()) - .map((i) => `${keys[i]}=${transformToSQLValue(data[i], fieldTypes[i])}`) + async function update(data) { + const values = Object.keys(data) + .map((key) => `${key}=${transformToSQLValue(data[key], fieldTypes[key])}`) .join(","); const query = `UPDATE ${index} - SET ${dictValues} + SET ${values} WHERE objectID="${objectID}" ;`; console.log(query);