【问题标题】:Creating a partitioned table in hive using a select使用 select 在 hive 中创建分区表
【发布时间】:2018-11-06 21:39:40
【问题描述】:

希望你能帮忙

我正在尝试创建下表,按 dt 分区 - 但每次都会出错,我无法找到正确的方法。

我正在使用 Hive

任何帮助都会很棒:)

谢谢

CREATE TABLE keenek1.ipfr_cf2
AS
SELECT
CASE 
WHEN catreputation = 1 THEN 'Clean Site'
WHEN catreputation = 2 THEN 'Unknown Site'
WHEN catreputation = 3 THEN 'Potentially Dangerous or Affiliated to a dangerous site'
WHEN catreputation = 4 THEN 'Malicious Site'
ELSE 'other'
END as urlcatrating,
dt, hh, count(distinct(emsisdn)) as emsisdncount, sum(bytesdl) as download, sum(bytesul) as upload, count(*) as transactions,
catid, catreputation, catgrpid, serverport, urlsetmatched, urlsetprivate, responderaction, shield_status
FROM udsapp.ipfr
left join keenek1.shield_lookupx on ipfr.emsisdn =  shield_lookupx.emsisdn2
WHERE ipfr.dt = 20181105
GROUP BY dt, hh, catid, catreputation, catgrpid, serverport, urlsetmatched, urlsetprivate, responderaction, shield_status
PARTITIONED BY (dt, string)

错误是: nmismatched input 'PARTITIONED' expecting <EOF>(line 18, pos 0)\n\n== SQL ==\n\nCREATE TABLE keenek1.ipfr_cf2\nAS\nSELECT\nCASE \nWHEN catreputation = 1 THEN 'Clean Site'\nWHEN catreputation = 2 THEN 'Unknown Site'\nWHEN catreputation = 3 THEN 'Potentially Dangerous or Affiliated to a dangerous site'\nWHEN catreputation = 4 THEN 'Malicious Site'\nELSE 'other'\nEND as urlcatrating,\ndt, hh, count(distinct(emsisdn)) as emsisdncount, sum(bytesdl) as download, sum(bytesul) as upload, count(*) as transactions,\ncatid, catreputation, catgrpid, serverport, urlsetmatched, urlsetprivate, responderaction, shield_status\nFROM udsapp.ipfr\nleft join keenek1.shield_lookupx on ipfr.emsisdn = shield_lookupx.emsisdn2\nWHERE ipfr.dt = 20181105\nGROUP BY dt, hh, catid, catreputation, catgrpid, serverport, urlsetmatched, urlsetprivate, responderaction, shield_status\nPARTITIONED BY (dt)\n^^^\n"

【问题讨论】:

  • 如果您发布错误消息会有所帮助
  • 对不起!现在完成

标签: hive hiveql


【解决方案1】:

(dt, string) 替换为(dt string)

【讨论】:

    【解决方案2】:

    进行上述更改后

    您可以进行以下设置

    SET hive.exec.dynamic.partition = true; 
    SET hive.exec.dynamic.partition.mode = nonstrict;
    

    【讨论】:

      猜你喜欢
      • 2019-09-23
      • 2015-11-07
      • 2021-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多