• Hive之数据类型Array的使用


    hive (student)> create table if not exists course(
                  > stu_num string comment 'the number of a student',
                  > choose_course array<string> comment 'the choosing course of a student')
                  > row format delimited
                  > fields terminated by ':'
                  > collection items terminated by ',';
    OK
    Time taken: 0.698 seconds
    hive (student)> show tables;
    OK
    course
    student_test
    Time taken: 0.051 seconds
    hive (student)> describe course;
    OK
    stu_num	string	the number of a student
    choose_course	array<string>	the choosing course of a student
    Time taken: 0.139 seconds
    
    hive (student)> load data local inpath '/home/landen/文档/choose_course.txt'
                  > overwrite into table course;
    Copying data from file:/home/landen/文档/choose_course.txt
    Copying file: file:/home/landen/文档/choose_course.txt
    Loading data to table student.course
    Deleted hdfs://localhost:9000/home/landen/UntarFile/hive-0.10.0/user/hive/warehouse/student.db/course
    Table student.course stats: [num_partitions: 0, num_files: 1, num_rows: 0, total_size: 123, raw_data_size: 0]
    OK
    Time taken: 0.788 seconds
    hive (student)> select * from course;
    OK
    1	["English","Chinese","French","Japanese"]
    2	["Chinese","French"]
    3	["Chinese","French","Japanese"]
    4	["Chinese","French","India"]
    5	["Chinese","French","Green"]
    Time taken: 0.231 seconds
    
    hive (student)> select stu_num, choose_course[0] from course;
    Total MapReduce jobs = 1
    Launching Job 1 out of 1
    Number of reduce tasks is set to 0 since there's no reduce operator
    Starting Job = job_201303271617_0011, Tracking URL = http://localhost:50030/jobdetails.jsp?jobid=job_201303271617_0011
    Kill Command = /home/landen/UntarFile/hadoop-1.0.4/libexec/../bin/hadoop job  -kill job_201303271617_0011
    Hadoop job information for Stage-1: number of mappers: 1; number of reducers: 0
    2013-03-29 16:50:04,251 Stage-1 map = 0%,  reduce = 0%
    2013-03-29 16:50:10,313 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 0.78 sec
    2013-03-29 16:50:11,324 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 0.78 sec
    2013-03-29 16:50:12,329 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 0.78 sec
    2013-03-29 16:50:13,334 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 0.78 sec
    2013-03-29 16:50:14,338 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 0.78 sec
    2013-03-29 16:50:15,342 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 0.78 sec
    2013-03-29 16:50:16,346 Stage-1 map = 100%,  reduce = 100%, Cumulative CPU 0.78 sec
    MapReduce Total cumulative CPU time: 780 msec
    Ended Job = job_201303271617_0011
    MapReduce Jobs Launched: 
    Job 0: Map: 1   Cumulative CPU: 0.78 sec   HDFS Read: 388 HDFS Write: 50 SUCCESS
    Total MapReduce CPU Time Spent: 780 msec
    OK
    1	English
    2	Chinese
    3	Chinese
    4	Chinese
    5	Chinese
    Time taken: 22.263 seconds

    choose_course.txt内容如下:
    1:English,Chinese,French,Japanese
    2:Chinese,French
    3:Chinese,French,Japanese
    4:Chinese,French,India
    5:Chinese,French,Green
  • 相关阅读:
    Linq之旅:Linq入门详解(Linq to Objects)(转)
    第四章 禅坐和外相的修行
    第三章 生活就是我们的修行
    第二章 更正我们的知见
    第一章 明了佛陀的教导(宁静的森林水池)
    第二章 取其一半
    你的程序员是在努力工作还是在偷懒?
    给JavaScript初学者的24条最佳实践
    简单理解Socket
    oracle18c linux x86-64 install 杂记
  • 原文地址:https://www.cnblogs.com/likai198981/p/2989202.html
Copyright © 2020-2023  润新知