Netezza 到 Snowflake 的替换,Trim,XML 函数转换

huangapple go评论43阅读模式
英文:

Netezza to snowflake Replace, Trim, XML function conversion

问题

,trim(trailing ',' from replace(replace (XMLserialize(XMLagg(XMLElement('X',date(orderdate))), '','' ),'' ,',') ) as orderdate

英文:

We recently migrated our data servers from Netezza to Snowflake and all SQL queries that were originally running in Netezza need to be translated to be compatible to run in snowflake. I'm not able to translate the following syntax from netezza to snowflake. Can someone please help? Thanks

,trim(trailing ',' from replace(replace (XMLserialize(XMLagg(XMLElement('X',date(orderdate)))), '<X>','' ),'</X>' ,',' )) as orderdate

I tried using REGEX_REPLACE function from snowflake but that didn't work.

答案1

得分: 0

总的来说,在翻译代码时,最好专注于行为,而不是试图逐字逐句地翻译它。

根据代码的编写方式,即生成XML元素、聚合多个元素、替换<X></X>以及移除尾随的,,看起来它正在生成以逗号分隔的日期字符串。

在Snowflake中:

LISTAGG(TO_VARCHAR(orderdate, 'YYYY-MM-DD'), ',') AS orderdate
英文:

In general when translating code it is better to focus on the behavior instead of trying to literally translate it.

Based on how the code is written, i.e. generating XML element, aggregating multiple elements, replacing of <X>, </X> and removal of trailing , it seems it is generating comma-separated string of dates.

In Snowflake:

LISTAGG(TO_VARCHAR(orderdate, 'YYYY-MM-DD'), ',') AS orderdate

huangapple
  • 本文由 发表于 2023年2月10日 04:00:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/75403844.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定