zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    Sqoop的导入及可能遇到的问题
    Docker搭建MongoDB集群(副本分片)
    微信小程序框架部署:mpvue+typescript
    关系型数据库与非关系型数据库
    PWA 学习笔记(五)
    PWA 学习笔记(四)
    PWA 学习笔记(三)
    PWA学习笔记(二)
    PWA 学习笔记(一)
    部分设计模式对比分析
  • 原文地址:https://www.cnblogs.com/likai198981/p/2989202.html
Copyright © 2011-2022 走看看