我有两张桌子:
create table a (
`1` array<string>);
create table b (
`1` array<int>);
Run Code Online (Sandbox Code Playgroud)
我想把表格放在表格b中(表格b为空):
insert into table b
select * from a;
Run Code Online (Sandbox Code Playgroud)
这样做时我收到以下错误:
FAILED: SemanticException [Error 10044]: Line 1:18 Cannot insert into
target table because column number/types are different 'b': Cannot
convert column 0 from array<string> to array<int>.
Run Code Online (Sandbox Code Playgroud)
如果字段只是类型string和字段,我不会得到这个错误int.
有没有办法用数组进行转换?
我想将时间戳转换1490198341.705为日期20170323和小时11(GMT + 8:00).有什么功能可以解决这个问题吗?
我的Java应用程序在mapper上运行,并使用Qubole API创建子进程.应用程序存储子qubole queryIDs.我需要在退出之前拦截kill信号并关闭子进程.hadoop job -kill jobId和yarn application -kill applicationId命令以SIGKILL方式查杀,我不知道如何拦截关机.是否有可能以某种方式拦截作业终止或配置hadoop以给予应用程序机会优雅地关闭?
应用程序在本地运行时使用ShutdownHook成功拦截关闭,而不是在映射器容器中并且能够杀死它的子进程.
请建议如何在mapper中运行时拦截关机,或者我做错了什么?
我现在有 hive 脚本 custsales.hql 我想从 hive cli 运行它
hive (pract5)> run /user/training/hdfs_location/custsales.hql
Run Code Online (Sandbox Code Playgroud)
但它不执行。请指导。我知道我们可以从命令行运行它
$ hive -f /home/training/local_location/custsales.hql
Run Code Online (Sandbox Code Playgroud)
但这不是我的要求。
我正在尝试使用OpenCSVSerde以及一些整数和日期列创建一个表。但是列将转换为String。这是预期的结果吗?解决方法是,在此步骤之后进行显式类型转换(这会使完整的运行变慢)
hive> create external table if not exists response(response_id int,lead_id int,creat_date date ) ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.OpenCSVSerde' WITH SERDEPROPERTIES ('quoteChar' = '"', 'separatorChar' = '\,', 'serialization.encoding'='UTF-8', 'escapeChar' = '~') location '/prod/hive/db/response' TBLPROPERTIES ("serialization.null.format"="");
OK
Time taken: 0.396 seconds
hive> describe formatted response;
OK
# col_name data_type comment
response_id string from deserializer
lead_id string from deserializer
creat_date string from deserializer
Run Code Online (Sandbox Code Playgroud)
解释将数据类型更改为字符串的源代码。
我试图在我的查询中清除 'null',但是运行它时仍然出错,一直告诉我 'cannot cast'' to bigint,有什么办法可以解决它?
我的查询
select m.app, m.hour,m.user_id,
m.avg_minutes_watched, n.userid, n.watched_mins, n.active FROM
(SELECT app,
substr(hour,1,8) hour,
CAST(COALESCE(json_extract_scalar(json, '$.user_id'), '-999999') as BigInt) user_id,
CAST(COALESCE(json_extract_scalar(json, '$.playback_time'), '-999999') as BigInt) /60000 avg_minutes_watched
FROM prod
WHERE event_type = 'user_session_complete' AND hour > '20180331' and hour < '20180501')m
left join
(select userid, watched/60000 watched_mins,
(case when watched/60000 >= 2 then 'active' else 'not_active' end) active from est where realdate > '2018-03-31' and realdate < '2018-05-01') n
on m.user_id = n.userid
order by …Run Code Online (Sandbox Code Playgroud) 我有一个包含 JSON 数组的列,如下所示:
{data=[{"name":"col1","min":0,"max":32,"avg":29},
{"name":"col2","min":1,"max":35,"avg":21},
{"name":"col3","min":4,"max":56,"avg":34}]}
Run Code Online (Sandbox Code Playgroud)
我正在尝试解析数组并根据条件提取特定值。例如
"min"其中的值"name"="col1":0
"avg"其中的值"name"="col3":34
有人有解决办法吗?
想要从Hive / SQL中的数组中删除空值
例如:数组转换为字符串值后为['1',null],则仅应为'1'。
拆分数组我正在使用以下:
concat_ws( ",", array_val)
this gives : 1,null
required output : 1
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助!
我非常确定像 STRUCT 这样的复杂类型不能是分区列的类型。但我不确定所有原始类型是否都有效。我读了很多文档但没有找到任何东西。
我有两个 pyspark 数据框:
一是:
name start end
bob 1 3
john 5 8
Run Code Online (Sandbox Code Playgroud)
第二个是:
day outcome
1 a
2 c
3 d
4 a
5 e
6 c
7 u
8 l
Run Code Online (Sandbox Code Playgroud)
我需要每个人的连续日结果,例如
bob acd
john ecul
Run Code Online (Sandbox Code Playgroud)
在 pyspark 中可以这样做吗?