diff --git a/raster_loader/cli/bigquery.py b/raster_loader/cli/bigquery.py index 1d7b83a..e200f53 100644 --- a/raster_loader/cli/bigquery.py +++ b/raster_loader/cli/bigquery.py @@ -37,6 +37,12 @@ def bigquery(args=None): default=False, is_flag=True, ) +@click.option( + "--append", + help="Append records into a table if it already exists.", + default=False, + is_flag=True, +) @click.option( "--output_quadbin", help=( @@ -56,6 +62,7 @@ def upload( chunk_size, input_crs, overwrite=False, + append=False, output_quadbin=False, test=False, ): @@ -110,6 +117,7 @@ def upload( input_crs, client=client, overwrite=overwrite, + append=append, output_quadbin=output_quadbin, ) diff --git a/raster_loader/io.py b/raster_loader/io.py index f9c0f53..22c1d2d 100644 --- a/raster_loader/io.py +++ b/raster_loader/io.py @@ -971,6 +971,7 @@ def rasterio_to_bigquery( input_crs: int = None, client=None, overwrite: bool = False, + append: bool = False, output_quadbin: bool = False, pseudo_planar: bool = False, ) -> bool: @@ -1041,7 +1042,7 @@ def rasterio_to_bigquery( elif not check_if_bigquery_table_is_empty( project_id, dataset_id, table_id, client ): - append_records = ask_yes_no_question( + append_records = append or ask_yes_no_question( f"Table {table_id} already exists in dataset {dataset_id} " "and is not empty. Append records? [yes/no] " )