HUE sql 脚本关键字搜索在 case 语句中返回错误值

问题描述 投票:0回答:0

嗨,我有一个脚本来查找关键字,但它似乎只有在关键字两侧都是数字时才有效。如何无论两边是什么都可以搜索关键字?

例如,以下值返回以下值,而分别期望 LOY、NCA 和 NCA。

FLO010-120-600PTS-LOYAL-S-C_010523 = Test    when upper(field1) like upper('%\_LOY\_%') then 'LOY'
CNV008-120-800-NCA-S-A_170423 = unknown      when upper(field1) like upper('%\_NCA\_%') then 'NCA'
DFG_House_10_back_on_80_NCA_20230525 = NCA   when upper(field1) like upper('%\_NCA\_%') then 'NCA'

脚本是:

  case 
  when upper(field1) like upper('%\_F\_%\_LOY\_%') then 'F'
  when upper(field1) like upper('%\_F\_%_LPS\_%') then 'F'
  when upper(field1) like upper('%_F_%_NCA\_%') then 'F'
  when upper(field1) like upper('%\_F\_%\_NRS\_%') then 'F'
  when upper(field1) like upper('%\_F_%\_NRS\_%') then 'F'
  when upper(field1) like upper('%\_F\_%\_SOW\_%') then 'F'
  when upper(field1) like upper('%\_NCA\_%') then 'NCA'
  when upper(field1) like upper('%\_LPS\_%') then 'LPS'
  when upper(field1) like upper('%\_NRS\_%') then 'NRS'
  when upper(field1) like upper('%\_LAPSED\_%') then 'LPS'
  when upper(field1) like upper('%\_SOW\_%') then 'SOW'
  when upper(field1) like upper('%\_LOY\_%') then 'LOY'
  when upper(field1) like upper('%\_F\_%') then 'F'
  when upper(field1) like upper('%\_T\_%') then 'Test'
  else 'unknown'
hive sql-like hue
© www.soinside.com 2019 - 2024. All rights reserved.