dougaodi8895 2019-06-01 00:22
浏览 68

如何访问bigquery表中列内的数据数组的列名?

I have a structure that holds an array of class objects which I uploaded to my BigQuery table using inferschema. However, I am now trying to iterate through that table and update the values accordingly and I am not able to access the column which holds the array of class objects.

I have already tried to access it using different class names such as:

  • "Reviewers[0].Role"
  • "`Reviewers[0].Role`"
  • "Reviewers_0.Role"
  • "Reviewers(0).Role"

... None of which works

//Models which I'm using for the schema of the tables
type PullRequest struct {   
Reviewers         []*Reviewer  `json:"reviewers"`
}
type Reviewer struct {
    Role   string `json:"role"`
    Status string `json:"status"`
    User   *User  `json:"user"`
}

//Putting sql statements in constant to avoid SQL injection
const (
    prUpdateSQL = "UPDATE %s.%s.%s"
    prSetSQL = "SET %v = '%v'"
    prSetNonEscapeSQL = "%v = %v"
    prSetEscapeSQL = "%v = '%v'"
    prWhereSQL = "WHERE ID = %v"
)

commandstring := fmt.Sprintf(prUpdateSQL+" ", projectID, datasetID, tableName)
for i, r := range pr.Reviewers{
                reviewerString := fmt.Sprintf("Reviewers.%d", i)
                commandstring += fmt.Sprintf(prSetEscapeSQL+", ", reviewerString+".Role", r.Role)
                commandstring += fmt.Sprintf(prSetEscapeSQL+", ", reviewerString+".Status", r.Status)
                commandstring += fmt.Sprintf(prSetEscapeSQL+", ", reviewerString+".User.Name", r.User.Name)
}

I am expecting the results to be able to set the different class objects values in the array to my new value which pr holds. Instead I get this error message:

UPDATE ... SET does not support array modification with [] at [1:914], invalidQuery"

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 @microsoft/fetch-event-source 流式响应问题
    • ¥15 ogg dd trandata 报错
    • ¥15 高缺失率数据如何选择填充方式
    • ¥50 potsgresql15备份问题
    • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
    • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
    • ¥60 pb数据库修改与连接
    • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
    • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
    • ¥20 神经网络Sequential name=sequential, built=False