Recasting a column in BigQuery can sometimes be a pain, but using this code will make it much easier.
- INT64
- FLOAT64
- BOOL
- STRING
- BYTES
- DATE
- DATETIME
- TIME
- TIMESTAMP
Example:
select
account_id,
account_code,
eff_dt_id
from nyt_pdw_dev.fact_hd_snapshot
Add a CAST(COLUMN_NAME
AS TYPE
) AS COLUMN_NAME
in place of your key.
select
account_id,
account_code,
CAST(eff_dt_id AS INT64) AS eff_date_id,
from nyt_pdw_dev.fact_hd_snapshot
First, click the Query Table
button.
One the new view MAKE SURE you are using "standard sql". If you don't know what that is, click on Show Options, and be sure Standard SQL
is checked.
You may want to add LIMIT 10
to the bottom of your query for testing. Just run the query to make sure there are no mistakes.
- REMOVE the
LIMIT 10
from bottom of your query. - Click on Show Options (if not open)
- Find
Destination Table
row (top item) and click onSelect Table
. - Choose the Collection and write in the table id. We're going to replace our table. (You can change the table name here to make sure you don't mess up for further testing.)
- Once selected go to the
Write Preference
and click onOverwrite Table
to replace your table.
@dovy Can you elaborate on "3. Run the code found in get_table_query.js when the table you want to alter is selected." ?