2016-04-06 13 views
0

私はこのスプリットハイブエディタ内の区切り文字に基づいて、列<code>india</code>に<code>'|'</code>と<code>korea</code></p> <p>に基づいて<code>'india|koria'</code>のような文字列を分割するクエリを作成する方法

select 
    SUBSTRING('India|Korea', 1, position('|' in 'India|Korea') - 1) as first, 
    SUBSTRING('India|Korea', position(',' in 'India|Korea') + 1)as second 

を試してみましたが、私は得ますエラー:

error while compiling statement: failed: parseexceptio : cannot recognize input near 'in' '' India|Korea'' ')' in expression specification

誰の助けですか?前もって感謝します。

注:ハイブエディタでこのクエリを実行しています。

+0

私は '位置は」利用できないと思うあなたのロジックのために、しかし、instr()を使用し、position()を使用していませんハイブエディタで。文字列中の特定の文字の位置を見つけるための置換え? –

答えて

0

最近のバージョンのハイブサポートでは、substring_index()がサポートされていると思います。ハイブに分割UDFを試してみてください

select substring('India|Korea', 1, instr('India|Korea', '|') - 1) as first, 
     substring('India|Korea', instr('India|Korea', '|') + 1) as second 
+0

ありがとうございました。それは働いている。私はその「instr」機能を探していました。 –

関連する問題