小编har*_*low的帖子

如何确定 `value.FieldByName(name)` 是否找到该字段?

我试图弄清楚field在下面的示例中找不到时如何停止我的程序的执行。

如果FieldByName(key)返回零值,我如何警告用户未找到该字段?

field := mutable.FieldByName(key)

// need to figure out if the field exists before calling .Type() on it
if field.X == Y {
  log.Fatalf("Unable to find [%s] in Config object", key)
}

switch field.Type().Name() {
}
Run Code Online (Sandbox Code Playgroud)

go

3
推荐指数
1
解决办法
1022
查看次数

如何更改 BigQuery 重复记录的 col 类型

我正在尝试将重复记录的 col 类型从STRING更改为TIMESTAMP。这里有一些来自 BQ 文档的建议(手动更改架构)。但是,我遇到了每个推荐建议的问题。

这是一个示例架构:

{
  'name' => 'id',
  'type' => 'STRING',
  'mode' => 'REQUIRED'
},
{
  'name' => 'name',
  'type' => 'STRING',
  'mode' => 'REQUIRED'
},
// many more fields including nested records and repeated records
{
  'name' => 'locations',
  'type' => 'RECORD',
  'mode' => 'REPEATED',
  'fields' => [
    {
      'name' => 'city',
      'type' => 'STRING',
      'mode' => 'REQUIRED'
    },
    {
      'name' => 'updated_at',
      'type' => 'STRING',   // ** want this as …
Run Code Online (Sandbox Code Playgroud)

google-bigquery

1
推荐指数
1
解决办法
1780
查看次数

标签 统计

go ×1

google-bigquery ×1