有没有一种方法可以解析BigQuery Standard SQL中的XML标记? [英] Is there a way to parse XML tags in BigQuery Standard SQL?

查看:40
本文介绍了有没有一种方法可以解析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来自库,并已加载到您的gcs中帐户

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

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

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