hive支持sql大全(9-11:复合类型构建操作/复杂类型访问操作/复杂类型长度统计函数)

6Hive Sql 大全-Hive 函数 此外还有很多数学函数: 绝对值函数: abs()、正取余函数: pmod()、正弦函数: sin()、反正弦函数: asin()、余弦函数: cos()、反余弦函数: acos()、positive函数: positive()、negative函数: negative()比如,M是值为{‘f’ -> ‘foo’, ‘b’ -> ‘bar’, ‘all’ -> ‘foobar’}的map类型,那么M[‘all’]将会返回’foobar’说明:将字符串A中的符合java正则表达式B的部分替换为C。 阅读详情
九、复合类型构建操作1. Map类型构建: map
语法: map (key1, value1, key2, value2, …)
说明:根据输入的key和value对构建map类型
举例:
hive> Create table lxw_test as select map('100','tom','200','mary')as t from lxw_dual;
hive> describe lxw_test;
t      map<string,string>
hive> select t from lxw_test;
{"100":"tom","200":"mary"}

2. Struct类型构建: struct
语法: struct(val1, val2, val3, …)
说明:根据输入的参数构建结构体struct类型
举例:
hive> create table lxw_test as select struct('tom','mary','tim')as t from lxw_dual;
hive> describe lxw_test;
t      struct<col1:string,col2:string,col3:string>
hive> select t from lxw_test;
{"col1":"tom","col2":"mary","col3":"tim"}

3. array类型构建: array
语法: array(val1, val2, …)
说明:根据输入的参数构建数组array类型
举例:
hive> create table lxw_test as selectarray("tom","mary","tim") as t from lxw_dual;
hive> describe lxw_test;
t       array<string>
hive> select t from lxw_test;
["tom","mary","tim"]

十、复杂类型访问操作1. array类型访问: A[n]
语法: A[n]
操作类型: A为array类型,n为int类型
说明:返回数组A中的第n个变量值。数组的起始下标为0。比如,A是个值为['foo', 'bar']的数组类型,那么A[0]将返回'foo',而A[1]将返回'bar'
举例:
hive> create table lxw_test as selectarray("tom","mary","tim") as t from lxw_dual;
hive> select t[0],t[1],t[2] from lxw_test;
tom     mary    tim

2. map类型访问: M[key]
语法: M[key]
操作类型: M为map类型,key为map中的key值
说明:返回map类型M中,key值为指定值的value值。比如,M是值为{'f' -> 'foo', 'b'-> 'bar', 'all' -> 'foobar'}的map类型,那么M['all']将会返回'foobar'
举例:
hive> Create table lxw_test as selectmap('100','tom','200','mary') as t from lxw_dual;
hive> select t['200'],t['100'] from lxw_test;
mary    tom

3. struct类型访问: S.x
语法: S.x
操作类型: S为struct类型
说明:返回结构体S中的x字段。比如,对于结构体struct foobar {int foo, int bar},foobar.foo返回结构体中的foo字段
举例:
hive> create table lxw_test as select struct('tom','mary','tim')as t from lxw_dual;
hive> describe lxw_test;
t      struct<col1:string,col2:string,col3:string>
hive> select t.col1,t.col3 from lxw_test;
tom     tim

十一、复杂类型长度统计函数1.    Map类型长度函数: size(Map<K.V>)
语法: size(Map<K.V>)
返回值: int
说明: 返回map类型的长度
举例:
hive> select size(map('100','tom','101','mary')) from lxw_dual;
2

2.    array类型长度函数: size(Array<T>)
语法: size(Array<T>)
返回值: int
说明: 返回array类型的长度
举例:
hive> select size(array('100','101','102','103')) from lxw_dual;
4

3.    类型转换函数
类型转换函数: cast
语法: cast(expr as <type>)
返回值: Expected "=" to follow "type"
说明: 返回array类型的长度
举例:
hive> select cast(1 as bigint) from lxw_dual;
hive复合类型使用 列举了hive中的复合类型的使用,map array struct 立即下载

相关推荐

LTO编译器优化介绍以及开启方法

LTO优化的详细介绍

性感的小君君 4923

sql获取数组长度

需求:获取字符串数组1,2,3,4的长度,当然也可以是其他分隔符1|2|3等 方法:通过自定义函数来实现 /* 获取字符串数组长度 */ if exists (select 1 from sysobjects where id = object_id('Get_StrArrayLength' )) drop Function Get_StrArrayLength...

weixin_30294021的博客 3008

基于AR和SLAM技术的商场智能导视系统技术原理详解

本文针对智慧商场室内导航需求,提出基于AR和SLAM技术的商场智能导视系统技术方案,实现了沉浸式导览体验并促进消费转化,助力商场运营升级。

维小帮定位导航的博客 1243

hive:函数:size(数组字段)获取array长度和 length(字段)获取字符串长度

获取字符串长度:length(字段) 字符串转数组:collect_list 列转行可得到数据,或split()某个字段得到数组 获取数组长度:size(数组字段) 参考sql: set edate=2019-07-21 SET company=***; SET recomrecords=ods.ods_${hiveconf:company_RecomRecords; SET empl...

不花的花和尚的博客 3万+

Bulk / Smart-seq2数据分析一般流程

Bulk RNA-seq(RNA-Seq of bulk samples)是一种RNA-Seq技术应用,它是通过将整个组织或细胞群体的RNA提取并混合,进行高通量测序来分析基因表达的技术。转录本定量结果可以用于后续的差异表达分析和聚类分析。功能注释和富集分析:对差异表达基因进行功能注释和富集分析,以帮助理解差异表达基因的功能和调控网络,从而获得对研究样品的更深入的理解。数据可视化:最后,将聚类分析的结果进行可视化,可以使用常见的数据可视化工具,如ggplot2、Plotly等,来帮助用户更好地理解数据。

weixin_54519672的博客 5350

贝塞尔曲线在机器人路径平滑中的实战应用与优化

本文深入探讨了贝塞尔曲线算法在机器人路径平滑中的核心应用。通过对比G1CBS与G2CBS两种方法,详细阐述了如何实现从切线连续到曲率连续的平滑优化,以满足不同机器人对运动平稳性和效率的需求,并提供了完整的Python代码实现与关键参数调优指南。

weixin_29051811的博客 307

hive支持sql大全

hive操作数据库还是比较方便的,因此才会有hbase与hive整合。下面我们hive的强大功能吧。为了增强阅读性,下面提几个问题:hive支持哪些运算符?hive是否支持左右连接?hive如何截取字符串?hive提供了那些系统函数? 目录 一、关系运算:... 4 1. 等值比较: =. 4 2. 不等值比较: &lt;&gt;. 4 3. 小于比较: &lt;. 4 4. 小于...

soledede 528

WPS中VBA支持库安装全攻略:从报错到一键解决

VBA作为Office生态中广泛使用的宏语言,是办公自动化的重要基础。WPS表格虽然兼容Excel文件格式,但出于技术路线与授权原因,默认并未集成完整的VBA引擎与开发环境,导致用户打开含宏文件时频繁遇到“找不到工程或库”“未找到VBA支持库”等报错。理解VBA支持库包含引擎与IDE两层结构,并掌握系统位数、版本匹配、安全软件拦截等前置条件,是成功部署的关键。通过可靠的安装源与规范流程完成配置后,即可实现在WPS中运行Excel宏、批量处理数据、自定义函数等自动化场景,显著提升报表处理效率。本文围绕WPS中

weixin_31102231的博客 306

Hive获取array数组长度

场景描述有一个表 user_cook_recommed(用户推荐菜谱),用sqoop从MySQL导入Hive中,表中有一个字段为array形式,导入到hive中变为String类型,如 4321,4532,337(string),现在需要获得这个array的长度解决方法由于array传入到hive中变为string,需要先用split方法分解为array,再使用size()函数处理代码示例selec

止鱼 7万+

做量化没有实时数据怎么行?我找到一个超级好用的Python库,速度还贼快!

今天咱们介绍了 pytdx 这个神奇的库,重点包括:✅ 安装 pytdx✅ 连接 TDX 服务器✅ 获取实时行情数据✅ 获取 K 线数据✅ 获取分笔成交数据总之,pytdx 是一个速度快、免费、易用的量化利器,适合 A 股量化交易的同学们使用。如果你还在为数据发愁,赶紧试试吧!🚀顺手再看就是对花姐最大的支持,期待你的关注。

奔跑的蜗牛 5724

使用R语言读取和处理CSV数据集

查看数据集的结构str(data)# 查看数据集的摘要统计信息str()函数将显示数据集的结构信息,包括变量名称、类型和前几行的值。summary()函数将提供数据集的摘要统计信息,如均值、中位数、最小值、最大值等。

CyberGenius的博客 3856

hive和presto的求数组长度函数区别及注意事项

hive和presto的求数组长度函数区别及注意事项

helloxiaozhe的博客 2425

MounRiver Studio(MRS)使用技巧:添加头文件目录;增加代码分组

MounRiver Studio(MRS)使用技巧:添加头文件目录

cheng___yi的博客 1808

hive数据库numeric_hive支持sql大全(收藏版)

本帖最后由 pig2 于 2014-4-13 16:20 编辑hive操作数据库还是比较方便的,因此才会有hbase与hive整合。下面我们hive的强大功能吧。为了增强阅读性,下面提几个问题:hive支持哪些运算符?hive是否支持左右连接?hive如何截取字符串?hive提供了那些系统函数?目录一、关系运算:... 41. 等值比较: =. 42. 不等值比较: <>. 43. 小...

weixin_39650745的博客 367

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain&#39;s apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath(&#39;DeepLearnToolbox&#39;));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand(&#39;state&#39;,0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W&#39;); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand(&#39;state&#39;,0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = &#39;sigm&#39;;%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, &#39;Too big error&#39;);```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand(&#39;state&#39;,0)sae = saesetup([784 100]);sae.ae{1}.activation_function = &#39;sigm&#39;;sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)&#39;)% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;;nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, &#39;Too big error&#39;);```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x&#39;,28,28,60000))/255;test_x = double(reshape(test_x&#39;,28,28,10000))/255;train_y = double(train_y&#39;);test_y = double(test_y&#39;);%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you&#39;ll get around 1.2% errorrand(&#39;state&#39;,0)cnn.layers = { struct(&#39;type&#39;, &#39;i&#39;) %input layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 6, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %sub sampling layer struct(&#39;type&#39;, &#39;c&#39;, &#39;outputmaps&#39;, 12, &#39;kernelsize&#39;, 5) %convolution layer struct(&#39;type&#39;, &#39;s&#39;, &#39;scale&#39;, 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, &#39;Too big error&#39;);```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, &#39;Too big error&#39;);%% ex2 neural net with L2 weight decayrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex3 neural net with dropoutrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex4 neural net with sigmoid activation functionrand(&#39;state&#39;,0)nn = nnsetup([784 100 10]);nn.activation_function = &#39;sigm&#39;; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex5 plotting functionalityrand(&#39;state&#39;,0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = &#39;softmax&#39;; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand(&#39;state&#39;,0)nn = nnsetup([784 20 10]); nn.output = &#39;softmax&#39;; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, &#39;Too big error&#39;);```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

hive支持sql大全(收藏版)

hive操作数据库还是比较方便的,因此才会有hbase与hive整合。下面我们hive的强大功能吧。为了增强阅读性,下面提几个问题: hive支持哪些运算符? hive是否支持左右连接? hive如何截取字符串? hive提供了那些系统函数? 目录 一、关系运算:... 4 1. 等值比较: =. 4 2. 不

huanghai的专栏 1503

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

【Hive】 九、 复杂数据类型:ARRAY / MAP / STRUCT 与嵌套展开

系统讲解 Hive 三种复合数据类型(ARRAY / MAP / STRUCT)的定义、访问语法、嵌套用法,以及配套的 UDTF 函数(explode / posexplode / LATERAL VIEW)与 Spark 3.0+ 的 CROSS JOIN UNNEST 标准语法对比

qq_46126258的博客 794

hive内置操作符与函数

第一部分:关系运算 Hive支持的关系运算符 •常见的关系运算符 •等值比较: = •不等值比较: •小于比较: •小于等于比较: •大于比较: > •大于等于比较: >= •空值判断: IS NULL •非空判断: IS NOT NULL •LIKE比较: LIKE •JAVA的LIKE操作: RLIKE •REGEXP操作: REGEXP •等

发展是曲折的但也是前进的 548

hive为什么与hbase整合

1.hive为什么与hbase整合? 2.hive整合hbase的优缺点是什么? 网上很多hive与hbase整合文档,但是为什么要整合,下面给大家对照一下,就能看出其中的原因了。

chang_ge的博客 2318

Hive常见内置函数及其使用

https://blog.youkuaiyun.com/scgaliguodong123_/article/details/46954009 函数分类   HIVE CLI命令 显示当前会话有多少函数可用  SHOW FUNCTIONS; 显示函数的描述信息  DESC FUNCTION concat;   显示函数的扩展描述信息  DESC FUNCTION EXTENDED con...

hellojoy的博客 1977

hive常用函数

函数分类HIVE CLI命令显示当前会话有多少函数可用 SHOWFUNCTIONS;显示函数的描述信息 DESCFUNCTION concat;显示函数的扩展描述信息 DESCFUNCTION EXTENDED concat;简单函数函数的计算粒度为单条记录。 关系运算 数学运算 逻辑运算 数值计算 类型转换 日期函数 条件函数 字符串函数 统计函数聚合函数函数处理的数据粒度为多条记录。 sum(...

十色花的博客 285
上一篇: hive支持sql大全(7-8:字符串函数 /集合统计函数)
下一篇: Windows下用anaconda装python,添加jupyter的kernel以及装包
Octemull
博客等级 码龄10年 4粉丝 1原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值