Associate Data Practitioner free question 1 / 10 · Domain 1: Data Preparation and Ingestion
You load a CSV file into BigQuery with autodetect enabled, no explicit schema, and no skip_leading_rows setting. The first row is name,city and the following rows are Alice,Tokyo and Bob,Osaka, so every field in the file is a string. How does BigQuery treat the first row?
- It is loaded as an ordinary data row in the destination table
- It is used as the column names and left out of the data
- The load is rejected because type inference fails
- It is not used for column names, and the load skips it
Show the answer and explanation
Answer: A
Why this is correct
The "CSV header" part of the schema auto-detection page says that BigQuery infers a header by comparing the first row with the other rows, and that for a file whose header row and data fields are all strings, "BigQuery won't automatically detect that the first row is a header. Use the --skip_leading_rows option to skip the header row. Otherwise, the header is imported as data." In this scenario every field is a string and skip_leading_rows is not set, so name,city is imported as one more data row.
Why the other options are wrong
"It is used as the column names and left out of the data" … This is what happens when the first row is made of strings and the later rows contain another type, such as numbers. Here every field is a string, so the first row looks no different from the rest and is not recognized as a header.
"It is not used for column names, and the load skips it" … Skipping rows is controlled by the skip_leading_rows option, which was not set in this scenario. Auto-detection decides only whether the first row is a header; the page names skip_leading_rows as the way to skip it.
"The load is rejected because type inference fails" … A column of strings is a perfectly valid thing to load. Failing to tell a header from data does not mean type inference has failed, so the load does not fail for that reason.
Key point
Header-like text is not enough. If every row is a string, you cannot rely on header auto-detection. State the number of rows to skip with skip_leading_rows, and provide an explicit schema when you need the column names to be reliable.