zoukankan      html  css  js  c++  java
  • hive 字段名称显示

    首先查看一个sql

    1、首先存在一个数据表tmp

    CREATE  TABLE tmp(
      platform string, 
      channel string, 
      chan_value string, 
      uid string, 
      host int, 
      logtime string, 
      bd_source string, 
      action string, 
      refer string, 
      back_url string, 
      browser string, 
      mobile string, 
      server_ip string, 
      ip string, 
      url string, 
      post string, 
      handle_time string, 
      logday string)

    2、查看这个表的数据

    hive> select * from tmp limit 2;
    OK
    adr    partner    touch.qunar.com    -    4    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117
    adr    partner    touch.qunar.com    -    0    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117
    Time taken: 2.549 seconds, Fetched: 2 row(s)

    这个数据十分不可读,那么就希望能格式化这些数据

    3、set hive.cli.print.header=true; // 打印列名

    hive> select * from tmp limit 2;     
    OK
    platform    channel    chan_value    uid    host    logtime    bd_source    action    refer    back_url    browser    mobile    server_ip    ip    url    post    handle_time    logday
    adr    partner    touch.qunar.com    -    4    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117
    adr    partner    touch.qunar.com    -    0    00:00:05    -    SgTrainStation    http://touch.qunar.com/baiduTrain.jsp?bd_source=alading_webapp        android    mozilla/5.0 (linux; android 4.4.2; hw-huawei p7-l09 build/huaweip7-l09) applewebkit/537.36 (khtml, like gecko) version/4.0 mobile safari/537.36    192.168.24.222    119.0.34.213    /SgTrainStation?keyword=上&_=1416153604205    -    1    20141117
    Time taken: 0.218 seconds, Fetched: 2 row(s)

    上面增加了列名

    4、set hive.cli.print.row.to.vertical=true; // 开启行转列功能, 前提必须开启打印列名功能

    5、set hive.cli.print.row.to.vertical.num=1; // 设置每行显示的列数

    ------------------这两步暂时没有生效,是xml文件设置的问题---------

  • 相关阅读:
    逐级汇总示例(循环逐级累计法).sql
    UdtSsn.cs
    2013届大华股份 软件算法类试题 D卷
    TCP与UDP区别
    浙江大华 研发类试题
    百度面试经历
    Contiki入门学习
    09网易校园招聘笔试题
    (转载)利用webkit抓取动态网页和链接
    2012.9.23 搜狗笔试
  • 原文地址:https://www.cnblogs.com/liqiu/p/4154153.html
Copyright © 2011-2022 走看看