You are ingesting CSV files into BigQuery using the bq load command. The CSV files have a header row, and you want BigQuery to automatically detect the schema and skip the header. Which flags should you include?
Trap 1: --autodetect --header=true
--autodetect is correct, but --header=true is not a recognized flag in the bq load command. BigQuery uses --skip_leading_rows to skip header rows. Without that flag, the header row would be treated as data, potentially causing type mismatches or extra rows. So this combination would fail to skip the header as required.
Trap 2: --infer_schema --skip_rows=1
Neither --infer_schema nor --skip_rows is a valid bq load flag. BigQuery's schema inference is enabled with --autodetect, and header skipping is done with --skip_leading_rows. Using these invalid flags would result in a command error and no data load, so it does not meet the requirement.
Trap 3: --schema --header
The --schema flag expects a comma-separated list of column definitions, so it does not auto-detect the schema. The --header flag is not a valid bq load flag; the correct flag to skip a header row is --skip_leading_rows. Using these would either cause an error or require you to manually specify the schema, which contradicts the requirement for automatic detection.
- A
--autodetect --header=true
Why it fails: --autodetect is correct, but --header=true is not a recognized flag in the bq load command. BigQuery uses --skip_leading_rows to skip header rows. Without that flag, the header row would be treated as data, potentially causing type mismatches or extra rows. So this combination would fail to skip the header as required.
- B
--infer_schema --skip_rows=1
Why it fails: Neither --infer_schema nor --skip_rows is a valid bq load flag. BigQuery's schema inference is enabled with --autodetect, and header skipping is done with --skip_leading_rows. Using these invalid flags would result in a command error and no data load, so it does not meet the requirement.
- C
--autodetect --skip_leading_rows=1
The --autodetect flag tells BigQuery to infer the schema from the data, and --skip_leading_rows=1 tells it to ignore the first row, which is the header. Together, these flags allow a seamless load of CSV files with headers into a new table. This is the standard approach for ad-hoc loads when you do not want to define a schema manually.
- D
--schema --header
Why it fails: The --schema flag expects a comma-separated list of column definitions, so it does not auto-detect the schema. The --header flag is not a valid bq load flag; the correct flag to skip a header row is --skip_leading_rows. Using these would either cause an error or require you to manually specify the schema, which contradicts the requirement for automatic detection.