sparksql中行转列

进入sparksql

beeline -u "jdbc:hive2://172.16.12.46:10015" -n spark -p spark -d org.apache.hive.jdbc.HiveDriver --color=true --silent=false --fastConnect=false --verbose=true

执行查询

select x.data_number,concat_ws(',',collect_list(cast(x.data_day_max as string))),
    concat_ws(',',collect_list(cast(x.data_day_hour as string)))
      from
          (select data_number,data_day_max,data_day_hour
          from jt.data_day where data_type='SCT' and data_version in ('SCTS301','SCTS302') and
          data_number in ('SCTS301-D','SCTS302-D') and data_day_date='2013-11-01'
          order by data_day_hour) x group by data_number;

sparksql中行转列_第1张图片

若要去重将collect_list换成collect_set

转载于:https://www.cnblogs.com/zeppelin/p/6124751.html

你可能感兴趣的:(sparksql中行转列)