zoukankan      html  css  js  c++  java
  • 《Programming Hive》读书笔记(两)Hive基础知识


    《Programming Hive》读书笔记(两)Hive基础知识

    第一遍读是浏览。建立知识索引,由于有些知识不一定能用到,知道就好。感兴趣的部分能够多研究。

    以后用的时候再具体看。并结合其它资料一起。



    Chapter 3.Data Types and File Formats

    原始数据类型和集合数据类型

    Select出来的数据,列与列之间的分隔符能够指定


    Chapter 4.HiveQL:Data Definition

    创建数据库,创建和修改表,分区的操作


    Chapter 5.HiveQL:Data Manipulation

    1 载入数据和导出数据,应该从本地和HDFS都能够。

    2 创建表和将查询结果插入到表中

    Chapter 6.HiveQL:Queries select的各种语法,join,cluster by等

    Where支持正則表達式like,rlike

    JOIN:On条件不支持不等号,不支持OR

    1 先join再where,会依据join过滤一批数据,然后依据where过滤一批

    2 The partition filters are ignored for OUTER JOINTS. However, usingsuch filter predicates in ON clauses for inner joins does work! 

    在outer join中。在on里面写分区条件是无用的。假设想通过分区条件加高速度,能够通过子查询再join的方法。

    Inner join,left outer join,right outerjoin,left semi join(in的作用,但貌似高版本号的hive支持in子查询)

    hive >SELECT *FROM stocksJOIN dividends

    > WHEREstock.symbol= dividends.symboland stock.symbol='AAPL';

    Hive里面,这条sql会先算笛卡尔积的再依据where过滤。

    In Hive,this query computes the full Cartesianproduct before applying the WHERE

    clause. Itcould take a very long time to finish. When the property hive.mapred.modeis

    set to strict, Hive prevents users from inadvertentlyissuing a Cartesian product query.

    两个表join,假设当中一个较小。能够通过map-side-join的方法加高速度。

    只是这样的优化不支持right-join和full-join。

    Hive does not support theoptimization for right- and full-outer joins.

    优化:满足一定条件,设置相应的參数开启。

    The ORDER BY clause is familiar from other SQL dialects. It performs atotal orderingof

    the query result set.This means that all the data is passed through a single reducer,

    which may take an unacceptablylong time to execute for larger data sets.

    Order by的排序是全局的,最后所有数据通过一个reducer来排序。

    Because ORDER BY can result in excessively long run times, Hive willrequire a LIMIT

    clause with ORDER BY if the property hive.mapred.mode is set to strict. Bydefault, it is

    set to nonstrict.(注意事项)

    sort by的排序是局部的

    DISTRIBUTEBY controls how map output isdivided among reducers.

    DISTRIBUTEBY能够指定map输出之后怎样分配到各个reducer中。

    一般是某个字段同样放在同一个reducer中,有点像groupby的思想。

    常常跟sort by一起用(DISTRIBUTEBY放前面)。达到先分组再内部排序的效果。

    Cluster by相等于distribute by加上sort by的效果。

    额外资料:

    http://www.cnblogs.com/ggjucheng/archive/2013/01/03/2843243.html

    cast(valueAS TYPE)

    强制性转换时,得注意转换后的值。看看是否达到你所须要的效果。

    Queries from sample data

    随机抽取数据

    部分未不懂。先无论。

    BlockSampling

    Input Pruningfor Bucket Tables

    Union all合并两个表



    本文作者:linger

    本文链接:http://blog.csdn.net/lingerlanlan/article/details/41153799


    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    Scrapy+Scrapy-redis+Scrapyd+Gerapy 分布式爬虫框架整合
    centos7 安装软件指南
    Kafka--消费者
    Kafka--生产者
    Kafka--初识Kafka
    Kafka--Kafka简述
    NetWork--记一次Http和TLS抓包
    JVM--a == (a = b)基于栈的解释器执行过程
    Java容器--Queue
    Idea--使用Idea调试设置
  • 原文地址:https://www.cnblogs.com/mengfanrong/p/4621774.html
Copyright © 2011-2022 走看看