Skip to content

Commit b3952e6

Browse files
committed
fix: create udfs if not exists
1 parent 4639a63 commit b3952e6

File tree

1 file changed

+5
-5
lines changed
  • firestore-bigquery-export/scripts/gen-schema-view/src

1 file changed

+5
-5
lines changed

firestore-bigquery-export/scripts/gen-schema-view/src/udf.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ function firestoreArrayFunction(datasetId: string): any {
6868

6969
function firestoreArrayDefinition(datasetId: string): string {
7070
return sqlFormatter.format(`
71-
CREATE FUNCTION \`${
71+
CREATE FUNCTION IF NOT EXISTS \`${
7272
process.env.PROJECT_ID
7373
}.${datasetId}.firestoreArray\`(json STRING)
7474
RETURNS ARRAY<STRING>
@@ -87,7 +87,7 @@ function firestoreBooleanFunction(datasetId: string): any {
8787

8888
function firestoreBooleanDefinition(datasetId: string): string {
8989
return sqlFormatter.format(`
90-
CREATE FUNCTION \`${
90+
CREATE FUNCTION IF NOT EXISTS \`${
9191
process.env.PROJECT_ID
9292
}.${datasetId}.firestoreBoolean\`(json STRING)
9393
RETURNS BOOLEAN AS (SAFE_CAST(json AS BOOLEAN));`);
@@ -103,7 +103,7 @@ function firestoreNumberFunction(datasetId: string): any {
103103

104104
function firestoreNumberDefinition(datasetId: string): string {
105105
return sqlFormatter.format(`
106-
CREATE FUNCTION \`${
106+
CREATE FUNCTION IF NOT EXISTS \`${
107107
process.env.PROJECT_ID
108108
}.${datasetId}.firestoreNumber\`(json STRING)
109109
RETURNS NUMERIC AS (SAFE_CAST(json AS NUMERIC));`);
@@ -119,7 +119,7 @@ function firestoreTimestampFunction(datasetId: string): any {
119119

120120
function firestoreTimestampDefinition(datasetId: string): string {
121121
return sqlFormatter.format(`
122-
CREATE FUNCTION \`${
122+
CREATE FUNCTION IF NOT EXISTS \`${
123123
process.env.PROJECT_ID
124124
}.${datasetId}.firestoreTimestamp\`(json STRING)
125125
RETURNS TIMESTAMP AS
@@ -136,7 +136,7 @@ function firestoreGeopointFunction(datasetId: string): any {
136136

137137
function firestoreGeopointDefinition(datasetId: string): string {
138138
return sqlFormatter.format(`
139-
CREATE FUNCTION \`${
139+
CREATE FUNCTION IF NOT EXISTS \`${
140140
process.env.PROJECT_ID
141141
}.${datasetId}.firestoreGeopoint\`(json STRING)
142142
RETURNS GEOGRAPHY AS

0 commit comments

Comments
 (0)