【问题标题】:HIVE Boolean FilterHIVE 布尔过滤器
【发布时间】:2021-09-19 14:15:37
【问题描述】:

我正在尝试使用布尔列过滤 HIVE/IMPALA 中的表,但不知何故我得到“处理语句时出错”

我的查询是这样的select * from schema_name.table_name where boolean_col is TRUE

想知道这种过滤器的正确查询。 TIA

【问题讨论】:

    标签: sql filter hive boolean impala


    【解决方案1】:

    正确的语法是where boolean_col = True

    你不需要额外的比较,直接使用列,它已经是布尔值了:

    select * from schema_name.table_name 
     where boolean_col
    

    若要选择 boolean_col = False 的行,请使用 NOT:

    select * from schema_name.table_name 
     where NOT boolean_col
    

    要检查 NULL 使用 boolean_col is NULL

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多