<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>SQL 方言通</title>
    <link>https://sql.silloy.xyz/</link>
    <description>MaxCompute、Hologres、StarRocks、Doris、Hive、Spark SQL、Flink SQL 常用函数写法对照与迁移说明。</description>
    <language>zh-CN</language>
    <item>
      <title>APPROX_COUNT_DISTINCT 近似去重计数</title>
      <link>https://sql.silloy.xyz/functions/approx_count_distinct/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/approx_count_distinct/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>APPROX_COUNT_DISTINCT 用 HyperLogLog 等算法估算去重个数，比 COUNT(DISTINCT) 省内存。Hologres、StarRocks、Doris 和 Spark 同名可用，MaxCompute 叫 APPROX_DISTINCT，Hive 和 Flink 没有内置的近似去重函数，只能用精确的 COUNT(DISTINCT)。</description>
    </item>
    <item>
      <title>ARRAY_CONTAINS 判断数组是否包含元素</title>
      <link>https://sql.silloy.xyz/functions/array_contains/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/array_contains/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>ARRAY_CONTAINS 判断数组中是否有指定元素，七个引擎都同名可用。差异在返回类型和版本：StarRocks 返回 1 或 0 而不是布尔值，Hologres 需要 V1.3.19 及以上版本，并且不支持常量数组。</description>
    </item>
    <item>
      <title>ARRAY_JOIN 数组拼接成字符串</title>
      <link>https://sql.silloy.xyz/functions/array_join/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/array_join/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>ARRAY_JOIN 用分隔符把数组元素拼成字符串，可以用第三个参数替换 NULL 元素，不传时跳过 NULL。MaxCompute、StarRocks、Doris、Spark 和 Flink 同名可用；Hologres 用 ARRAY_TO_STRING；Hive 用 concat_ws，并且只接受字符串数组。</description>
    </item>
    <item>
      <title>CONCAT 字符串拼接</title>
      <link>https://sql.silloy.xyz/functions/concat/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/concat/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>CONCAT 把多个字符串首尾相连。函数名在各引擎都一样，但遇到 NULL 的处理不同：MaxCompute、StarRocks、Doris 和 Flink 只要有一个参数为 NULL 就返回 NULL，Hologres 会直接忽略 NULL。</description>
    </item>
    <item>
      <title>DAYOFWEEK 星期几</title>
      <link>https://sql.silloy.xyz/functions/dayofweek/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/dayofweek/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>DAYOFWEEK 返回日期是星期几。MaxCompute、StarRocks、Doris、Spark 和 Flink 都以周日为 1、周六为 7；Hologres 的 EXTRACT(DOW ...) 以周日为 0，Hive 要用 EXTRACT(dayofweek FROM ...)。需要周一为 1 时，各引擎的写法都要额外换算。</description>
    </item>
    <item>
      <title>DECODE 多值匹配</title>
      <link>https://sql.silloy.xyz/functions/decode/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/decode/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>DECODE(expr, search1, result1, ..., default) 按值匹配返回结果，相当于简单的 CASE 表达式。MaxCompute 和 Spark 3.2 起支持这种写法；Hive 和 Flink 的 DECODE 是按字符集解码二进制，含义完全不同；其他引擎要改写为 CASE。</description>
    </item>
    <item>
      <title>FIRST_VALUE 窗口第一个值</title>
      <link>https://sql.silloy.xyz/functions/first_value/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/first_value/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>FIRST_VALUE 返回窗口中第一行的值。七个引擎都同名可用，差异在“忽略 NULL”的写法：MaxCompute、Doris、Hive 和 Spark 传第二个布尔参数，StarRocks 用 IGNORE NULLS，Hologres 和 Flink 的文档没有对应写法。</description>
    </item>
    <item>
      <title>FROM_JSON 按 schema 解析 JSON</title>
      <link>https://sql.silloy.xyz/functions/from_json/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/from_json/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>FROM_JSON 按指定的 schema 把 JSON 字符串解析成 STRUCT、MAP 或 ARRAY。只有 MaxCompute 和 Spark 同名可用，写法基本一致；StarRocks、Doris 和 Hologres 先转成 JSON 类型再取字段，Hive 和 Flink 只能按路径取值。</description>
    </item>
    <item>
      <title>GETDATE 获取当前时间</title>
      <link>https://sql.silloy.xyz/functions/getdate/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/getdate/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>GETDATE 是 MaxCompute 获取当前日期时间的函数，其他引擎要换成 NOW() 或 CURRENT_TIMESTAMP。迁移时要注意返回类型、精度和时区，以及同一条 SQL 里是否每行返回相同的值。</description>
    </item>
    <item>
      <title>GREATEST 多值取最大</title>
      <link>https://sql.silloy.xyz/functions/greatest/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/greatest/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>GREATEST 返回参数中的最大值。差异主要在 NULL：StarRocks、Doris、Hive 2.0 起和 Flink 只要有一个参数为 NULL 就返回 NULL；MaxCompute 默认和 Spark 会跳过 NULL。同样的 SQL 迁移后可能从有值变成 NULL。LEAST 的规则相同。</description>
    </item>
    <item>
      <title>INSTR 查找子串位置</title>
      <link>https://sql.silloy.xyz/functions/instr/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/instr/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>INSTR 返回子串在字符串中第一次出现的位置，下标从 1 开始，找不到时返回 0。多数引擎同名可用，Hologres 要改用 STRPOS。只有 MaxCompute 支持起始位置和第 N 次出现这两个参数，LOCATE 和 POSITION 的参数顺序与 INSTR 相反。</description>
    </item>
    <item>
      <title>LAST_VALUE 窗口最后一个值</title>
      <link>https://sql.silloy.xyz/functions/last_value/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/last_value/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>LAST_VALUE 返回窗口中最后一行的值。七个引擎都同名可用，差异在“忽略 NULL”的写法：MaxCompute、Doris、Hive 和 Spark 传第二个布尔参数，StarRocks 用 IGNORE NULLS，Hologres 和 Flink 的文档没有对应写法。LAST_VALUE 还要注意默认窗口只到当前行。</description>
    </item>
    <item>
      <title>LENGTH 字符串长度</title>
      <link>https://sql.silloy.xyz/functions/length/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/length/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>LENGTH 在不同引擎中统计的单位不同：StarRocks 和 Doris 的 LENGTH 返回字节数，一个汉字算 3；Hologres、Hive 和 Spark 的 LENGTH 返回字符数。按字符计数时，StarRocks 和 Doris 要改用 CHAR_LENGTH，Flink 也只有 CHAR_LENGTH。</description>
    </item>
    <item>
      <title>MONTHS_BETWEEN 相差月数</title>
      <link>https://sql.silloy.xyz/functions/months_between/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/months_between/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>MONTHS_BETWEEN(end, start) 返回两个日期相差的月数，带小数。MaxCompute、Doris、Hive 和 Spark 同名可用，小数部分都按每月 31 天折算，但对时间部分和舍入的处理不同。StarRocks 的 months_diff 和 Flink 的 TIMESTAMPDIFF 只返回整数月，Flink 的参数顺序还是反的。</description>
    </item>
    <item>
      <title>PERCENTILE_APPROX 近似分位数</title>
      <link>https://sql.silloy.xyz/functions/percentile_approx/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/percentile_approx/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>PERCENTILE_APPROX 计算近似分位数，常用于 P50、P99 这类指标。MaxCompute、StarRocks、Doris、Hive 和 Spark 同名可用，但第三个参数的含义和取值范围不同。Hologres 要用 APPROX_PERCENTILE ... WITHIN GROUP 改写，Flink 较新版本只有精确的 PERCENTILE。</description>
    </item>
    <item>
      <title>POSEXPLODE 带下标展开数组</title>
      <link>https://sql.silloy.xyz/functions/posexplode/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/posexplode/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>POSEXPLODE 把数组展开成多行，同时输出元素在数组中的位置，位置从 0 开始。MaxCompute、Doris、Hive 和 Spark 支持；Hologres、StarRocks 和 Flink 的文档中没有带位置的展开函数，需要另行改写。</description>
    </item>
    <item>
      <title>REGEXP_EXTRACT 正则提取</title>
      <link>https://sql.silloy.xyz/functions/regexp_extract/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/regexp_extract/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>REGEXP_EXTRACT 用正则表达式匹配字符串，返回指定分组的内容。除 Hologres 外都同名可用，但分组参数是否必填、没有匹配时返回空字符串还是 NULL、正则语法和反斜杠转义都有差异。Hologres 要用 REGEXP_MATCH 加数组下标改写。</description>
    </item>
    <item>
      <title>RLIKE 正则匹配判断</title>
      <link>https://sql.silloy.xyz/functions/rlike/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/rlike/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>RLIKE 判断字符串是否匹配正则表达式，只要有一段子串匹配就返回真。MaxCompute、Hive 和 Spark 支持 RLIKE 运算符；StarRocks、Doris 和 Flink 用 REGEXP 函数；Hologres 文档中没有对应的运算符，需要借助 REGEXP_MATCH。各引擎的正则语法和返回类型不同。</description>
    </item>
    <item>
      <title>SIZE 数组和 Map 元素个数</title>
      <link>https://sql.silloy.xyz/functions/size/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/size/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>SIZE 返回数组的元素个数或 Map 的键值对个数。MaxCompute、Hive 和 Spark 同名可用；StarRocks 和 Doris 要按数组、Map 分别用不同函数；Flink 用 CARDINALITY；Hologres 用 ARRAY_LENGTH 并指定维度。</description>
    </item>
    <item>
      <title>SORT_ARRAY 数组排序</title>
      <link>https://sql.silloy.xyz/functions/sort_array/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/sort_array/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>SORT_ARRAY 对数组元素排序。MaxCompute、Hive 和 Spark 用 SORT_ARRAY，Hologres、StarRocks、Doris 和 Flink 用 ARRAY_SORT。NULL 元素放在开头还是末尾、能否降序排列，各引擎不同；Spark 的 sort_array 和 array_sort 对 NULL 的处理也不一样。</description>
    </item>
    <item>
      <title>STR_TO_MAP 字符串转 Map</title>
      <link>https://sql.silloy.xyz/functions/str_to_map/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/str_to_map/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>STR_TO_MAP 用两个分隔符把字符串拆成键值对，返回 Map。除 Hologres 外都同名可用，但默认的键值分隔符不同：MaxCompute 和 Flink 默认是等号，StarRocks、Doris、Hive 和 Spark 默认是冒号。迁移时建议把两个分隔符都写明。</description>
    </item>
    <item>
      <title>SUBSTRING_INDEX 按分隔符截取</title>
      <link>https://sql.silloy.xyz/functions/substring_index/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/substring_index/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>SUBSTRING_INDEX(str, delim, count) 返回第 count 个分隔符之前的部分，count 为负数时从右边数。MaxCompute、StarRocks、Doris、Hive 和 Spark 同名可用，count 为 0 时结果不同；Hologres 和 Flink 没有这个函数。</description>
    </item>
    <item>
      <title>TO_DATE 字符串转日期</title>
      <link>https://sql.silloy.xyz/functions/to_date/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/to_date/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>TO_DATE 在不同引擎里有两种含义：MaxCompute、Hologres、Spark 和 Flink 用它按格式解析字符串；Hive、StarRocks 和 Doris 的 TO_DATE 只取日期部分，不能按格式解析。</description>
    </item>
    <item>
      <title>WEEKOFYEAR 一年中的第几周</title>
      <link>https://sql.silloy.xyz/functions/weekofyear/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/weekofyear/#2026-10-16</guid>
      <pubDate>Thu, 15 Oct 2026 16:00:00 GMT</pubDate>
      <description>WEEKOFYEAR 返回日期在一年中的第几周。多数引擎以周一为一周的开始，并按“第一周至少有 4 天”的规则计算，所以 1 月初可能返回 52 或 53。Hologres 用 EXTRACT(WEEK FROM ...)，返回 DOUBLE PRECISION；Flink 用 WEEK。</description>
    </item>
    <item>
      <title>COALESCE 取第一个非空值</title>
      <link>https://sql.silloy.xyz/functions/coalesce/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/coalesce/#2026-10-14</guid>
      <pubDate>Tue, 13 Oct 2026 16:00:00 GMT</pubDate>
      <description>COALESCE 从左到右返回第一个非 NULL 的参数，全部为 NULL 时返回 NULL。七个引擎都同名可用，差异主要在参数类型要求，以及 MaxCompute 在全部参数为 NULL 常量时会报错。</description>
    </item>
    <item>
      <title>DATE_SUB 日期减天数</title>
      <link>https://sql.silloy.xyz/functions/date_sub/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/date_sub/#2026-10-14</guid>
      <pubDate>Tue, 13 Oct 2026 16:00:00 GMT</pubDate>
      <description>DATE_SUB 从日期中减去若干天。MaxCompute、Hive 和 Spark 直接传天数，StarRocks 和 Doris 要写 INTERVAL，Hologres 和 Flink 没有这个函数。返回类型也不同，StarRocks 返回 DATETIME，MaxCompute 返回 DATE。</description>
    </item>
    <item>
      <title>DATEADD 按单位加减日期</title>
      <link>https://sql.silloy.xyz/functions/dateadd/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/dateadd/#2026-10-14</guid>
      <pubDate>Tue, 13 Oct 2026 16:00:00 GMT</pubDate>
      <description>DATEADD 是 MaxCompute 的写法，可以按年、季、月、天、小时、分钟、秒加减时间，返回类型与输入相同。Hologres 同名可用；StarRocks、Doris 和 Flink 改用 TIMESTAMPADD 或 INTERVAL；Spark 的 dateadd 只能加天数，含义不同。</description>
    </item>
    <item>
      <title>SPLIT_PART 按分隔符取第 N 段</title>
      <link>https://sql.silloy.xyz/functions/split_part/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/split_part/#2026-10-14</guid>
      <pubDate>Tue, 13 Oct 2026 16:00:00 GMT</pubDate>
      <description>SPLIT_PART 按分隔符切分字符串，返回第 N 段，下标从 1 开始。多数引擎同名可用，但下标越界时有的返回空字符串，有的返回 NULL；Hive 要用 split 加数组下标改写，Flink 的 SPLIT_INDEX 下标从 0 开始。</description>
    </item>
    <item>
      <title>TO_CHAR 日期转字符串</title>
      <link>https://sql.silloy.xyz/functions/to_char/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/to_char/#2026-10-14</guid>
      <pubDate>Tue, 13 Oct 2026 16:00:00 GMT</pubDate>
      <description>TO_CHAR 把日期或数值转成字符串。MaxCompute、Hologres 和 Spark 同名可用，其他引擎改用 DATE_FORMAT。最大的坑是格式符：MaxCompute 的 mm 表示月、mi 表示分钟，Java 风格的格式中 MM 才是月、mm 是分钟。</description>
    </item>
    <item>
      <title>ADD_MONTHS 按月加减</title>
      <link>https://sql.silloy.xyz/functions/add_months/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/add_months/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>ADD_MONTHS 给日期加上若干个月。月末日期是主要差异点：1 月 31 日加一个月，StarRocks、Doris 和 Spark 返回 2 月最后一天。返回类型也不同，MaxCompute 返回字符串，StarRocks 返回 DATETIME。</description>
    </item>
    <item>
      <title>ANY_VALUE 取组内任意值</title>
      <link>https://sql.silloy.xyz/functions/any_value/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/any_value/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>ANY_VALUE 从每组中任取一个值，常用于 GROUP BY 时带出不参与分组、但组内都一样的列。结果不确定，各引擎对 NULL 的处理也不同。Hologres、Hive 和 Flink 没有这个函数。</description>
    </item>
    <item>
      <title>COLLECT_LIST 聚合为数组</title>
      <link>https://sql.silloy.xyz/functions/collect_list/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/collect_list/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>COLLECT_LIST 把一组值按原样聚合成数组，保留重复值。MaxCompute、Doris、Hive 和 Spark 同名可用，其他引擎改写为 ARRAY_AGG。各引擎都不保证元素顺序，StarRocks 3.0 起可以在 ARRAY_AGG 中写 ORDER BY。</description>
    </item>
    <item>
      <title>COLLECT_SET 去重聚合为数组</title>
      <link>https://sql.silloy.xyz/functions/collect_set/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/collect_set/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>COLLECT_SET 把一组值去重后聚合成数组。MaxCompute、Doris、Hive 和 Spark 同名可用，Hologres、StarRocks 和 Flink 要改写为 ARRAY_AGG(DISTINCT ...)。各引擎都不保证数组元素的顺序。</description>
    </item>
    <item>
      <title>CONCAT_WS 按分隔符拼接</title>
      <link>https://sql.silloy.xyz/functions/concat_ws/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/concat_ws/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>CONCAT_WS 用指定的分隔符拼接多个字符串或一个字符串数组。多数引擎会跳过 NULL 值，但 MaxCompute 只要有一个参数为 NULL 就返回 NULL。</description>
    </item>
    <item>
      <title>DATE_ADD 日期加减</title>
      <link>https://sql.silloy.xyz/functions/date_add/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/date_add/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>DATE_ADD 给日期加上若干天。函数名相同，但 MaxCompute、Hive 和 Spark 直接传天数，StarRocks 和 Doris 要写 INTERVAL；返回类型也不同，MaxCompute 返回 DATE 并丢掉时间部分。</description>
    </item>
    <item>
      <title>DATE_FORMAT 日期格式化</title>
      <link>https://sql.silloy.xyz/functions/date_format/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/date_format/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>DATE_FORMAT 把日期或时间转换为指定格式的字符串。七个引擎用了四套格式符，同样写 mm，有的表示月，有的表示分钟，迁移时最容易出错。</description>
    </item>
    <item>
      <title>DATEDIFF 日期差</title>
      <link>https://sql.silloy.xyz/functions/datediff/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/datediff/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>DATEDIFF 计算两个日期之间相差多少天。多数引擎都是“结束日期在前”，但 MaxCompute 和 Hologres 支持按小时、分钟等单位计算，StarRocks 和 Doris 只按天计算，Flink 需要改用 TIMESTAMPDIFF。</description>
    </item>
    <item>
      <title>DATETRUNC 日期截断</title>
      <link>https://sql.silloy.xyz/functions/datetrunc/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/datetrunc/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>DATETRUNC 把日期截断到年、月、周等单位的起点，常用于按月汇总。MaxCompute 写 DATETRUNC 且日期在前，其他引擎多为 DATE_TRUNC 且单位在前，Hive 只能用 trunc 截断到月和年。</description>
    </item>
    <item>
      <title>EXPLODE 数组展开为多行</title>
      <link>https://sql.silloy.xyz/functions/explode/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/explode/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>EXPLODE 把数组的每个元素展开成一行，常用于处理多值字段。MaxCompute、Doris、Hive 和 Spark 用 EXPLODE，Hologres 和 StarRocks 用 UNNEST，Flink 用 CROSS JOIN UNNEST。空数组和 NULL 数组的处理是迁移时最容易漏掉的地方。</description>
    </item>
    <item>
      <title>FROM_UNIXTIME 时间戳转日期</title>
      <link>https://sql.silloy.xyz/functions/from_unixtime/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/from_unixtime/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>FROM_UNIXTIME 把以秒为单位的 Unix 时间戳转换为日期时间。各引擎的返回类型、格式参数和时区处理不同，Hologres 需要改用 TO_TIMESTAMP。</description>
    </item>
    <item>
      <title>GET_JSON_OBJECT 提取 JSON 字段</title>
      <link>https://sql.silloy.xyz/functions/get_json_object/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/get_json_object/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>GET_JSON_OBJECT 按 JSON 路径从字符串中取值。各引擎的函数名、返回类型和路径规则差别较大，是迁移时最容易出错的函数之一。</description>
    </item>
    <item>
      <title>IF 条件判断</title>
      <link>https://sql.silloy.xyz/functions/if/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/if/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>IF 在条件为真时返回第二个参数，否则返回第三个参数。七个引擎大多支持 IF，Hologres 需要 V2.1 及以上版本。</description>
    </item>
    <item>
      <title>LAST_DAY 当月最后一天</title>
      <link>https://sql.silloy.xyz/functions/last_day/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/last_day/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>LAST_DAY 返回日期所在月份的最后一天，常用于月末结算和账期计算。多数引擎同名可用，但返回类型不同；MaxCompute 和 StarRocks 还能取季末、年末，Flink 需要用 FLOOR 和 TIMESTAMPADD 组合计算。</description>
    </item>
    <item>
      <title>MAX_BY 取最大值对应的列</title>
      <link>https://sql.silloy.xyz/functions/max_by/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/max_by/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>MAX_BY(x, y) 返回 y 最大的那一行的 x，例如“每个用户最近一次下单的门店”。MaxCompute、Hologres、StarRocks、Doris 和 Spark 都支持；Hive 和 Flink 没有，要用 ROW_NUMBER 窗口函数改写。y 相同时返回哪一行不确定。</description>
    </item>
    <item>
      <title>MAX_PT 取最新分区</title>
      <link>https://sql.silloy.xyz/functions/max_pt/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/max_pt/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>MAX_PT 返回分区表中有数据的最大一级分区，常用于“只读最新一天”。只有阿里云的 MaxCompute 和 Hologres 提供，迁移到其他引擎时必须改写为子查询。</description>
    </item>
    <item>
      <title>NVL 空值替换</title>
      <link>https://sql.silloy.xyz/functions/nvl/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/nvl/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>NVL 在第一个参数为 NULL 时返回第二个参数。MaxCompute、Doris、Hive 和 Spark 可以直接使用，Hologres、StarRocks 和 Flink SQL 需要改写为 COALESCE 或 IFNULL。</description>
    </item>
    <item>
      <title>REGEXP_REPLACE 正则替换</title>
      <link>https://sql.silloy.xyz/functions/regexp_replace/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/regexp_replace/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>REGEXP_REPLACE 用正则表达式查找并替换字符串。最大的差异在 Hologres：它沿用 PostgreSQL 的行为，默认只替换第一处匹配，要加 'g' 才会全部替换。各引擎的正则语法也不完全相同。</description>
    </item>
    <item>
      <title>SPLIT 字符串拆分</title>
      <link>https://sql.silloy.xyz/functions/split/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/split/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>SPLIT 按分隔符把字符串拆成数组。MaxCompute、Hive 和 Spark 的分隔符按正则表达式处理，Doris 要改用 SPLIT_BY_STRING，Hologres 没有 SPLIT，要用 REGEXP_SPLIT_TO_ARRAY。</description>
    </item>
    <item>
      <title>SUBSTR 截取子串</title>
      <link>https://sql.silloy.xyz/functions/substr/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/substr/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>SUBSTR 从指定位置截取字符串。各引擎都从 1 开始计数，负数表示从末尾倒数；起始位置写 0 时，多数引擎返回空字符串。Hologres 的 SUBSTR 需要 orafce 扩展，标准写法是 SUBSTRING。</description>
    </item>
    <item>
      <title>UNIX_TIMESTAMP 日期转时间戳</title>
      <link>https://sql.silloy.xyz/functions/unix_timestamp/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/unix_timestamp/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>UNIX_TIMESTAMP 把日期时间转换为距 1970-01-01 的秒数。各引擎都返回秒，但格式参数的写法、时区处理和超出范围时的结果不同，Hologres 要改用 EXTRACT(EPOCH FROM ...)。</description>
    </item>
    <item>
      <title>WM_CONCAT 分组拼接字符串</title>
      <link>https://sql.silloy.xyz/functions/wm_concat/</link>
      <guid isPermaLink="false">https://sql.silloy.xyz/functions/wm_concat/#2026-10-13</guid>
      <pubDate>Mon, 12 Oct 2026 16:00:00 GMT</pubDate>
      <description>WM_CONCAT 是 MaxCompute 的分组字符串拼接函数，分隔符写在前面。迁到其他引擎时要换函数名，并注意分隔符的位置：Hologres 用 STRING_AGG，StarRocks 和 Doris 用 GROUP_CONCAT，Flink 用 LISTAGG。</description>
    </item>
  </channel>
</rss>
