您可能遇到了 ClickHouse SQL 错误:'There is no supertype for types String, String, Int32'。该错误通常发生在使用 UNION 操作时,子查询中存在不同的数据类型,例如 String 和 Int32。

为了解决此问题,您可以将 PlatformType 转换为字符串类型,以便与 AppIdentifier 的数据类型匹配。以下是修改后的代码:

SELECT min_Ds AS Ds,
       COUNT(DISTINCT appid) AS app_count
FROM (
    SELECT AppIdentifier AS appid,
           min(Ds) AS min_Ds
    FROM log_iMonkey_iOS_overview
    GROUP BY AppIdentifier
    UNION ALL
    SELECT AppIdentifier AS appid,
           min(Ds) AS min_Ds
    FROM log_iMonkey_Android_overview
    GROUP BY AppIdentifier
    UNION ALL
    SELECT CAST(PlatformType AS String) AS appid,
           min(Ds) AS min_Ds
    FROM log_iMonkey_Android_overview
    GROUP BY PlatformType
) subquery

在第三个子查询中,我们使用 CAST(PlatformType AS String) 将 PlatformType 转换为字符串类型。这样,所有三个子查询返回的数据类型就会一致,避免了类型不匹配的错误。

通过这种方法,您就可以成功运行 SQL 查询,并获得想要的结果。

ClickHouse SQL 错误:'There is no supertype for types String, String, Int32' 解决方法

原文地址: https://www.cveoy.top/t/topic/pSkk 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录