有没有办法在 BigQuery Standard SQL 中解析 XML 标签? [英] Is there a way to parse XML tags in BigQuery Standard SQL?

查看:23
本文介绍了有没有办法在 BigQuery Standard SQL 中解析 XML 标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到这是一个坏使用正则表达式解析 XML/HTML 的想法.另一种建议是使用 XML 解析器.BigQuery 标准 SQL 库中是否存在一个?

I have read that it's a bad idea to parse XML/HTML using regular expressions. The alternative suggestion is to use an XML parser. Does one exist in the BigQuery Standard SQL library?

推荐答案

这里是关于如何像 Elliot 提到的那样在 BigQuery 中使用 Javascript UDF 的文档.

Here is the documentation to how to use Javascript UDFs in BigQuery like Elliot has mentioned.

https://cloud.google.com/bigquery/docs/reference/standard-sql/user-defined-functions

我想 UDF 可能看起来像

I imagine the UDF might look something like

CREATE TEMPORARY FUNCTION XML(x STRING)
RETURNS STRING
  LANGUAGE js AS """
  var data = fromXML(x);
  return data.title;
"""
OPTIONS(
library="gs://<BUCKET_NAME>/from-xml.min.js"
);
SELECT XML(a) FROM UNNEST(["<title>Title of Page</title>"]) as a

from-xml.min.js 来自this 库并加载到您的 gcs 中帐号

Where from-xml.min.js is from this library and loaded into your gcs account

这篇关于有没有办法在 BigQuery Standard SQL 中解析 XML 标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆