Skip to content

Bigquery: Why civil.Date map Date type field from 2018-09-09 to 0000-00-00? #1164

@richzw

Description

@richzw

With the following codes

	var record []bigquery.Value
	err := it.Next(&record)
	if err == iterator.Done {
		break
	}

	if err != nil {
		fmt.Println("Failed to parse bigquery value")
	}

	fmt.Println(record)

The results are

   [74BkBzTiR 1 2018-09-09]
   [74BkBzTiR 2 2018-09-09]
   [74BkBzTiR 3 2018-09-09]

However, when I use the following struct to map those row data

	var record struct {
		Uid     string    
		Level   int     
		UtcDate civil.Date
	}

	err := it.Next(&record)
	if err == iterator.Done {
		break
	}

	if err != nil {
		fmt.Println("Failed to parse bigquery value")
	}

	fmt.Println(record)

Give results

  {74BkBzTiR 1 0000-00-00}
  {74BkBzTiR 2 0000-00-00}
  {74BkBzTiR 3 0000-00-00}

The date 2018-09-09 map to 0000-00-00.

Is there something wrong with my codes or anything I am missing?

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions