r/bigquery • • Jan 23 '22

Problem creating a table using CSV

I'm a beginner at BQ and have been struggling to create a table out of CSV. I'm using the console, added the Schema, then the error happens.

Failed to create table: Error while reading data, error message: Could not parse '2018/12/21' as DATE for field pg_start_dt (position 3) starting at location 0 with message 'Unable to parse'

For the date is there any rules that I need to follow? I couldn't find it anywhere.

0 Upvotes

4 comments sorted by

View all comments

4

u/Financial_Pie_3624 Jan 23 '22

I had the same issue loading the table from the csv. You have two options:

  1. Format the csv column cells with this format YYYY-MM-DD…that’s it, as long as your table data type is date it will work.

  2. Create your table in BigQuery and make sure all columns are STRING data type…then use the PARSE_DATE function to cast the datetime column from string to date. DM me if you need more help.

2

u/buangakun3 Jan 23 '22

Thank you will DM you about it.