列组合
环境:
代码语言:javascript复制Hive: 2.7.7
Oracle SQL Developer
Cloudera JDBC Driver
案例:
代码语言:javascript复制select type '.' type_desc ': ' nameobject as full_name,type,type_desc,nameobject
from tblobj2
limit 10
错误:
1 - 使用 Oracle SQL Developer 执行上述 HQL 语句第一列为 null :
image
解决方案:
代码语言:javascript复制select concat( type ,'.' , type_desc , ': ', nameobject ) as full_name,type,type_desc,nameobject
from tblobj2
limit 10
image
用 || 快捷符号也可以连接字符串或者文本列
代码语言:javascript复制select type || type_desc || nameobject
from tblobj2
limit 10
算术组合
环境:
代码语言:javascript复制Hive: 2.7.7
Oracle SQL Developer
Cloudera JDBC Driver
案例:
代码语言:javascript复制select object_id,schema_id
, object_id schema_id
, object_id-schema_id
,object_id*schema_id
,object_id/schema_id
,object_id % schema_id
, object_id | schema_id
--, object_id & schema_id
, object_id ^ schema_id
, ~schema_id
from tblobj2
limit 10
异常:
- 在运行被注释掉的表达式 object_id & schema_id 时,出现输入 schema_id 的对话框:
image
解决方案:
代码语言:javascript复制select object_id,schema_id
, object_id schema_id
, object_id-schema_id
,object_id*schema_id
,object_id/schema_id
,object_id % schema_id
, object_id | schema_id
, object_id & (schema_id)
, object_id ^ schema_id
, ~schema_id
from tblobj2
limit 10
解决问题的关键在于 object_id & (schema_id)