当我将重复记录类型的输入字段传递给Bigquery UDF时,它会一直说未找到输入字段。
这是我的2行数据:
{"name":"cynthia", "Persons":[ { "name":"john","age":1},{"name":"jane","age":2} ]}
{"name":"jim","Persons":[ { "name":"mary","age":1},{"name":"joe","age":2} ]}
这是数据的架构:
[ { “名称”: “名称”, “类型”: “串”},
{"name":"Persons","mode":"repeated","type":"RECORD",
"fields":
[
{"name": "name","type": "STRING"},
{"name": "age","type": "INTEGER"}
]
}
这是查询:
SELECT
name,maxts
FROM
js
(
//input table
[dw_test.clokTest_bag],
//input columns
name, Persons,
//output schema
"[
{name: 'name', type:'string'},
{name: 'maxts', type:'string'}
]",
//function
"function(r, emit)
{
emit({name: r.name, maxts: '2'});
}"
)
LIMIT 10
尝试运行查询时遇到错误:
错误:5.3 - 15.6:未定义的输入字段人员 职位编号:ord2-us-dc:job_IPGQQEOo6NHGUsoVvhqLZ8pVLMQ
有人请帮忙吗?
谢谢。
答案 0 :(得分:5)
在输入列列表中,直接列出叶字段:
//input columns
name, Persons.name, Persons.age,
当您在UDF中获取记录时,它们仍将以正确的结构显示。