Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions firestore-bigquery-export/scripts/gen-schema-view/src/udf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function firestoreArrayFunction(datasetId: string): any {

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

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

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

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

function firestoreGeopointDefinition(datasetId: string): string {
return sqlFormatter.format(`
CREATE FUNCTION \`${
CREATE FUNCTION IF NOT EXISTS \`${
process.env.PROJECT_ID
}.${datasetId}.firestoreGeopoint\`(json STRING)
RETURNS GEOGRAPHY AS
Expand Down