From b26e8e2e60f1877766080db422caec37b04260a1 Mon Sep 17 00:00:00 2001 From: Bobby Date: Fri, 30 Apr 2021 14:58:52 +1000 Subject: [PATCH] support more data types for bigquery --- ft_build/sparksLib/bigqueryIndex.ts | 30 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/ft_build/sparksLib/bigqueryIndex.ts b/ft_build/sparksLib/bigqueryIndex.ts index c616562a..7df0a76f 100644 --- a/ft_build/sparksLib/bigqueryIndex.ts +++ b/ft_build/sparksLib/bigqueryIndex.ts @@ -92,23 +92,25 @@ const transformToSQLValue = (value: any, ftType: string) => { case "ID": case "SINGLE_SELECT": case "URL": - // STRING + // SQL type: STRING return `"${sanitise(value)}"`; - case "JSON": - case "FILE": - case "IMAGE": - case "USER": - case "COLOR": - // STRING (json representation) + case "JSON": // JSON + case "FILE": // JSON + case "IMAGE": // JSON + case "USER": // JSON + case "COLOR": // JSON + case "DOCUMENT_SELECT": + case "SERVICE_SELECT": + case "ACTION": + case "AGGREGATE": + case "MULTI_SELECT": // array + // SQL type: STRING if (!value.length) { return `null`; } return `"${sanitise(JSON.stringify(value))}"`; - case "MULTI_SELECT": - // STRING (array representation, comma separated) - return `"${sanitise(value.toString())}"`; case "CHECK_BOX": - // BOOLEAN + // SQL type: BOOLEAN return value ? `true` : `false`; case "NUMBER": case "PERCENTAGE": @@ -119,7 +121,7 @@ const transformToSQLValue = (value: any, ftType: string) => { case "DATE": case "DATE_TIME": case "DURATION": - // TIMESTAMP + // SQL type: TIMESTAMP if (!value?.toDate) { return `null`; } @@ -127,10 +129,6 @@ const transformToSQLValue = (value: any, ftType: string) => { case "LAST": case "STATUS": case "SUB_TABLE": - case "DOCUMENT_SELECT": - case "SERVICE_SELECT": - case "ACTION": - case "AGGREGATE": default: // unknown or meaningless to sync return `null`;