• LATERAL VIEW 语法


    LATERAL VIEW 使用语法

    原文链接: https://www.deeplearn.me/2892.html

                select
                    a.id, 
                    b.son_order_path
                from f_jz_change_order_top_son a 
                LATERAL VIEW explode(split(son_order_path, ',')) b as son_order_path

    FROM 子句可以有多个 LATERAL VIEW 子句。 后续的 LATERAL VIEWS 可以引用出现在 LATERAL VIEW 左侧的任何表格中的列。

    如下所示:

    SELECT * FROM exampleTable
    LATERAL VIEW explode(col1) myTable1 AS myCol1
    LATERAL VIEW explode(myCol1) myTable2 AS myCol2;

    上面的示例 sql 中后面一个直接饮用之前的输出结果作为输入,假设有以下数据表:

    Array<int> col1 Array<string> col2
    [1, 2] [a”, “b”, “c”]
    [3, 4] [d”, “e”, “f”]

    查询语句

    SELECT myCol1, col2 FROM baseTable
    LATERAL VIEW explode(col1) myTable1 AS myCol1;

    将会生成:

    int mycol1 Array<string> col2
    1 [a”, “b”, “c”]
    2 [a”, “b”, “c”]
    3 [d”, “e”, “f”]
    4 [d”, “e”, “f”]

    值会分开。

  • 相关阅读:
    活动安排问题
    完美字符串
    Codeforces Round #696 (Div. 2) 解题报告
    Codeforces 1459D
    Codeforces 25D
    POJ 1847
    LightOJ 1074
    POJ 3159
    POJ 1511
    POJ 1502
  • 原文地址:https://www.cnblogs.com/sakura3/p/11845113.html
Copyright © 2020-2023  润新知