-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove a job task for define a field as default and create a ddl for it
- Loading branch information
Showing
2 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# bin/bash -e | ||
# | ||
# | ||
############################################################################### | ||
# Define a default value for a field in a table | ||
# | ||
# Author: Cayo Dias | ||
# Date: 27 November 2023 | ||
# | ||
# The script will define a column as default in case of necessity to recreate or | ||
# rename the table. | ||
# The project id, dataset ids, table id and field are hardcoded; if you need | ||
# to update tables for a different environment, change the parameters. | ||
############################################################################### | ||
|
||
PROJECT_ID=test-hubble-319619 | ||
DATASET_ID=test_crypto_stellar_internal | ||
TABLE=raw_mgi_stellar_transactions | ||
FIELD=batch_insert_ts | ||
|
||
echo "Creating default value field $FIELD in $TABLE in $DATASET_ID" | ||
|
||
bq query --use_legacy_sql=false \ | ||
"ALTER TABLE \`$PROJECT_ID.$DATASET_ID.$TABLE\` \ | ||
ALTER COLUMN $FIELD SET DEFAULT CURRENT_TIMESTAMP();" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters