英文:
Netezza to snowflake Replace, Trim, XML function conversion
问题
,trim(trailing ',' from replace(replace (XMLserialize(XMLagg(XMLElement('X',date(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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论