数据湖探索 DLI-Spark 2.4.x与Spark 3.3.x版本在SQL队列的差异对比:histogram_numeric函数的返回值的类型不同

时间:2025-02-27 14:33:51

histogram_numeric函数的返回值的类型不同

  • 说明:

    Spark SQL中的histogram_numeric函数返回一个结构体数组(x,y),不同版本的引擎x的类型不同。

    • Spark2.4.x:Spark 3.2或更早版本中,x为double类型。
    • Spark3.3.x:x类型等于函数输入值的类型。
  • 升级引擎版本后是否对作业有影响:

    有影响,涉及相关用法需要适配。

  • 示例代码

    准备数据:

    create table test_histogram_numeric(val int);
    INSERT INTO test_histogram_numeric VALUES(1),(5),(8),(6),(7),(9),(8),(9);

    执行sql:

    select histogram_numeric(val,3) from test_histogram_numeric;
    • Spark 2.4.5
      [{"x":1.0,"y":1.0},{"x":5.5,"y":2.0},{"x":8.200000000000001,"y":5.0}]
    • Spark 3.3.1
      [{"x":1,"y":1.0},{"x":5,"y":2.0},{"x":8,"y":5.0}]
support.huaweicloud.com/bulletin-dli/dli_bulletin_0015.html