Hive Cube RollUPパケット問題

3130 ワード

質問1:
CubeまたはRollUPを使用する場合、パケット条件>=5個の場合、特殊な問題が発生します
パケット条件個数<=4の場合:(正常に動作し、エラーなし)
 
SELECT
    nvl (wm,'ALL'),
    nvl (product_id, 'ALL'),
    nvl (
      count(
        distinct(
        IF (
          event_id IN ('BS00A003', 'BW00H010'),
          product_id,
          null
        )
        )
      ),
      0
    ) share_commodity_num--       
FROM
    gds.xx                                                        
WHERE
    dt >= '${hivevar:sdate}'
AND dt <= '${hivevar:edate}'
AND length(shop_id) > 1
AND wm is not null
AND wm !='-'
AND category_id_1 is not null and category_id_1 !='-'
AND category_id_2 is not null and category_id_2 !='-'
AND category_id_3 is not null and category_id_3 !='-'
AND category_id_4 is not null and category_id_4 !='-'
GROUP BY
    wm,
    category_id_1,
    category_id_2,
    product_id with cube;
    

グループ化条件個数>=5の場合:(次のエラーが表示されます)
 
SELECT
    nvl (wm,'ALL'),
    nvl (product_id, 'ALL'),
    nvl (
      count(
        distinct(
        IF (
          event_id IN ('BS00A003', 'BW00H010'),
          product_id,
          null
        )
        )
      ),
      0
    ) share_commodity_num--       
FROM
    gds.xx                                                        
WHERE
    dt >= '${hivevar:sdate}'
AND dt <= '${hivevar:edate}'
AND length(shop_id) > 1
AND wm is not null
AND wm !='-'
AND category_id_1 is not null and category_id_1 !='-'
AND category_id_2 is not null and category_id_2 !='-'
AND category_id_3 is not null and category_id_3 !='-'
AND category_id_4 is not null and category_id_4 !='-'
GROUP BY
    wm,
    category_id_1,
    category_id_2,
    category_id_3,
    product_id with cube;
    

Error while compiling statement:FAILED:SemanticException[Error 10210]:Grouping sets aggregations(with rollups or cubes)are not allowed if aggregation function parameters overlap with the aggregation functions columns私が今この問題を解決する方法はsql文の書き方を修正することによって処理することです.サブクエリ(一般的には需要を満たすことができません)またはGrouping Sets(需要を満たすことができますが、組合せ条件が多い)を使用できます.
ケース2:fromのテーブルをテーブル接続で取得する必要がある場合、cubeまたはrollupまたはgroupping setsで問題が発生しても、テーブル接続で得られたテーブルを1つのテンポラリ・テーブルに保存し、クエリー・テンポラリ・テーブルをデータ・ソースとして使用するしかありません.
質問2:
CubeまたはRollUpのパケット条件>=5の場合、集約関数でdistinctを使用できないと次のエラーメッセージが表示されます.
   An additional MR job is introduced since the cardinality of grouping sets is more than hive.new.job.grouping.set.cardinality.
   This functionality is not supported with distincts.Either set hive.new.job.grouping.set.cardinality to a high number (higher than the number of rows per input row due to grouping sets in the query),or rewrite the query to not use distincts. The number of rows per input row due to grouping sets is 32
解決方法:hiveを修正することができます.new.job.grouping.set.cardinality構成、または集約でdistinctを使用しないで解決します.私が今解決している方法はGrouping Setsで解決しています.このエラーはCubeとRollUpの時だけ発生します.Grouping Setsの時はこのエラーはありません.