0

有问题的 Hive 查询片段如下:

group by
  case
    when inte.subId is not null then 'int'
    else 'ext'
  end,
  taskType,
  result
grouping sets(
  (
    case
      when inte.subId is not null then 'int'
      else 'ext'
    end,  -- line 36
    taskType,
    result
  ),  -- line 39
  (
    taskType,
    result
  )
)

日志在第 36 行和第 39 行提示了一些语法错误:

FAILED: ParseException line 36:7 missing ) at ',' near ')'
line 39:3 missing EOF at ',' near ')'

任何的想法?如果您需要我提供更多信息,请随时发表评论。

4

1 回答 1

0

好的,这是@GordonLinoff 在评论中建议的解决方案。基本上,这个想法是使用一个子查询,其中一个新列Category被选为

case 
  when inte.subId is not null then 'int'
  else 'ext'
end as Category

然后,在外部主查询中,组部分很简单

group by Category, Type, Result
grouping sets(
    (Category, Type, Result),
    (Type, Result)
)

至于为什么问题中的语法错误,我们不确定。也许,case不能在grouping sets.

于 2017-05-25T03:03:02.577 回答