2013-08-07 50 views
0

我跑在treasure-data.com此查詢(HiveQL):如何從HiveQL獲取ngram到PostgreSQL?

SELECT 
    ngrams (
     sentences (
     LOWER(v[ 'text' ]) 
    ) 
     ,1 
     ,100 
    ) 
    FROM 
    item 
    WHERE 
    TD_TIME_RANGE (
     TIME 
     ,"2013-08-06" 
     ,TD_TIME_ADD (
     "2013-08-06" 
     ,"1d" 
    ) 
    ) 

當談到時間,結果轉儲到PostgreSQL的,我得到這個錯誤:

started at 2013-08-06T17:42:52Z 
Hive history file=/mnt/hive/tmp/2851/hive_job_log__1663452325.txt 
finished at 2013-08-06T17:43:27Z 
Exception in thread "main" java.lang.RuntimeException: invalid schema: unexpected '>' but got: <ngram:array<string>,estfrequency:double>> 
    at com.treasure_data.type.spec.TypeSpecs.scanString(TypeSpecs.java:98) 
    at com.treasure_data.type.spec.TypeSpecs.fromString(TypeSpecs.java:72) 
    at com.treasure_data.type.spec.TypeSpecs.fromString(TypeSpecs.java:64) 
    at com.treasure_data.type.spec.TypeSpecs.fromString(TypeSpecs.java:57) 
    at com.treasure_data.hadoop.worker.result.ResultWorker.<init>(ResultWorker.java:59) 
    at com.treasure_data.hadoop.worker.result.ResultWorker.main(ResultWorker.java:154) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at org.apache.hadoop.util.RunJar.main(RunJar.java:208) 

我米猜測我需要以某種方式修改我的選擇語句。

回答

0

爆炸!

SELECT explode(ngrams(sentences(lower(val)), 2, 10)) AS x FROM kafka; 

source