鲲鹏社区首页
中文
注册
我要评分
文档获取效率
文档正确性
内容完整性
文档易理解
在线提单
论坛求助

执行Spark引擎业务

Spark算子下推使用spark-sql命令来执行。

本次任务示例使用tpch的1T数据的非分区表作为测试表,测试sql为tpch-sql6。

相关的表信息如表1所示。

表1 相关表信息

表名

表格式

总数

占用空间

lineitem

orc

5999989709

169.6 G

具体步骤如下。

  1. 运行spark-sql命令。
    1
    spark-sql --num-executors 10 --executor-cores 6 --driver-class-path "/usr/local/spark-plugin-jar/*" --jars "/usr/local/spark-plugin-jar/*" --conf "spark.executor.extraClassPath=./*"
    

  2. 执行sql6语句。
    select
    sum(l_extendedprice * l_discount) as revenue
    from
    tpch_flat_orc_1000.lineitem
    where
    l_shipdate >= '1993-01-01'
    and l_shipdate < '1994-01-01'
    and l_discount between 0.06 - 0.01 and 0.06 + 0.01
    and l_quantity < 25;

    执行任务时会打印下推的信息,如下所示。

    ndp.NdpPushDown: Selectivity: 0.09795918367346941
    ndp.NdpPushDown: Push down with [PushDownInfo(ListBuffer(FilterExeInfo((((((((isnotnull(l_quantity#5) AND isnotnull(l_discount#7)) AND isnotnull(l_shipdate#11)) AND (cast(l_shipdate#11 as date) >= 8401)) AND (cast(l_shipdate#11 as date) < 8766)) AND (l_discount#7 >= 0.05)) AND (l_discount#7 <= 0.07)) AND (l_quantity#5 < 25.0)),List(l_quantity#5, l_extendedprice#6, l_discount#7, l_shipdate#11))),ListBuffer(AggExeInfo(List(sum((l_extendedprice#6 * l_discount#7))),List(),List(sum#36))),None,Map(ceph1 -> ceph1, ceph2 -> ceph2, ceph3 -> ceph3))]

    包含了下推的选择率以及算子信息。

    spark-sql命令参数信息如表2所示。

    表2 算子下推的参数含义

    参数

    推荐值

    含义

    --num-executors

    10

    启动的执行器数量,默认值为2。

    --executor-cores

    6

    每个执行器使用的CPU核数,默认值为1。

    --driver-class-path

    "/usr/local/spark-plugin-jar/*"

    传递给驱动程序的额外Jar包的路径。

    --jars

    "/usr/local/spark-plugin-jar/*"

    驱动程序和执行器类路径中要包含的Jar包。

    --conf

    "spark.executor.extraClassPath=./*"

    配置Spark参数。