Hive _ Hive2 新版连接工具 beeline 详解

article/2025/9/28 14:12:17

Hive客户端工具后续将使用Beeline 替代HiveCLI ,并且后续版本也会废弃掉HiveCLI 客户端工具。


BeelineHive新的命令行客户端工具。

Beeline是从 Hive 0.11版本引入的。

 

HiveServer2 支持一个新的命令行Shell,称为Beeline,它是基于SQLLine CLIJDBC客户端。

Beeline支持嵌入模式(embedded mode)和远程模式(remote mode)。在嵌入式模式下,运行嵌入式的Hive(类似Hive CLI),而远程模式可以通过Thrift连接到独立的HiveServer2进程上。从Hive 0.14版本开始,Beeline使用HiveServer2工作时,它也会从HiveServer2输出日志信息到STDERR


下面看下beeline 的常用参数

Usage: java org.apache.hive.cli.beeline.BeeLine -u <database url>               the JDBC URL to connect to-n <username>                   the username to connect as-p <password>                   the password to connect as-d <driver class>               the driver class to use-i <init file>                  script file for initialization-e <query>                      query that should be executed-f <exec file>                  script file that should be executed-w (or) --password-file <password file>  the password file to read password from--hiveconf property=value       Use value for given property--hivevar name=value            hive variable name and valueThis is Hive specific settings in which variablescan be set at session level and referenced in Hivecommands or queries.--color=[true/false]            control whether color is used for display--showHeader=[true/false]       show column names in query results--headerInterval=ROWS;          the interval between which heades are displayed--fastConnect=[true/false]      skip building table/column list for tab-completion--autoCommit=[true/false]       enable/disable automatic transaction commit--verbose=[true/false]          show verbose error messages and debug info--showWarnings=[true/false]     display connection warnings--showNestedErrs=[true/false]   display nested errors--numberFormat=[pattern]        format numbers using DecimalFormat pattern--force=[true/false]            continue running script even after errors--maxWidth=MAXWIDTH             the maximum width of the terminal--maxColumnWidth=MAXCOLWIDTH    the maximum width to use when displaying columns--silent=[true/false]           be more silent--autosave=[true/false]         automatically save preferences--outputformat=[table/vertical/csv2/tsv2/dsv/csv/tsv]  format mode for result displayNote that csv, and tsv are deprecated - use csv2, tsv2 instead--truncateTable=[true/false]    truncate table column when it exceeds length--delimiterForDSV=DELIMITER     specify the delimiter for delimiter-separated values output format (default: |)--isolation=LEVEL               set the transaction isolation level--nullemptystring=[true/false]  set to true to get historic behavior of printing null as empty string--addlocaldriverjar=DRIVERJARNAME Add driver jar file in the beeline client side--addlocaldrivername=DRIVERNAME Add drvier name needs to be supported in the beeline client side--help                          display this message
Beeline version 1.2.1.spark2 by Apache Hive

参数的含义其实在英文中已经给的很明确了,这里我给出中文解释

The Beeline CLI 支持以下命令行参数:    
Option    
Description    
--autoCommit=[true/false] ---进入一个自动提交模式:beeline --autoCommit=true    
--autosave=[true/false]   ---进入一个自动保存模式:beeline --autosave=true    
--color=[true/false]    ---显示用到的颜色:beeline --color=true    
--delimiterForDSV= DELIMITER ---分隔值输出格式的分隔符。默认是“|”字符。    
--fastConnect=[true/false]  ---在连接时,跳过组建表等对象:beeline --fastConnect=false    
--force=[true/false]    ---是否强制运行脚本:beeline--force=true    
--headerInterval=ROWS   ---输出的表间隔格式,默认是100: beeline --headerInterval=50    
--help ---帮助  beeline --help    
--hiveconf property=value  ---设置属性值,以防被hive.conf.restricted.list重置:beeline --hiveconf prop1=value1     
--hivevar name=value   ---设置变量名:beeline --hivevar var1=value1    
--incremental=[true/false]  ---输出增量  
--isolation=LEVEL  ---设置事务隔离级别:beeline --isolation=TRANSACTION_SERIALIZABLE    
--maxColumnWidth=MAXCOLWIDTH ---设置字符串列的最大宽度:beeline --maxColumnWidth=25    
--maxWidth=MAXWIDTH ---设置截断数据的最大宽度:beeline --maxWidth=150    
--nullemptystring=[true/false]  ---打印空字符串:beeline --nullemptystring=false    
--numberFormat=[pattern]     ---数字使用DecimalFormat:beeline --numberFormat="#,###,##0.00"    
--outputformat=[table/vertical/csv/tsv/dsv/csv2/tsv2] ---输出格式:beeline --outputformat=tsv     
--showHeader=[true/false]   ---显示查询结果的列名:beeline --showHeader=false    
--showNestedErrs=[true/false] ---显示嵌套错误:beeline --showNestedErrs=true    
--showWarnings=[true/false] ---显示警告:beeline --showWarnings=true    
--silent=[true/false]  ---减少显示的信息量:beeline --silent=true    
--truncateTable=[true/false] ---是否在客户端截断表的列       
--verbose=[true/false]  ---显示详细错误信息和调试信息:beeline --verbose=true    
-d <driver class>  ---使用一个驱动类:beeline -d driver_class    
-e <query>  ---使用一个查询语句:beeline -e "query_string"    
-f <file>  ---加载一个文件:beeline -f filepath  多个文件用-e file1 -e file2  
-n <username>  ---加载一个用户名:beeline -n valid_user    
-p <password>  ---加载一个密码:beeline -p valid_password    
-u <database URL> ---加载一个JDBC连接字符串:beeline -u db_URL  


参数说明:


这里比较相近的两个参数是 -i 与 -f  其中两个参数的主要区别从字面上就可以很好的区分了


-f 执行SQL文件后就直接退出Beeline客户端,一般编写需要执行的 HQL

-i  执行SQL文件后进行Beeline客户端。一般为初始化的参数设置  hive 中的变量。。 


看下参数说明

 -i <init file>                  script file for initialization
 -f <exec file>                  script file that should be executed


beeline 使用示例:


beeline 的用法基本与 hive-cli 用法相同


下面是一个连接示例

以cloudera-scm 的身份 以jdbc 的方式连接远程的 hiveserver2

beeline -u jdbc:hive2://10.180.0.26:10000


类似hive-cli 的执行脚本功能

nohup beeline 

-u jdbc:hive2://10.180.0.26:10000  -n cloudera-scm 

--color=true --silent=false  

--hivevar p_date=${partitionDate} --hivevar f_date=${fileLocDate} 

-f hdfs_add_partition_dmp_clearlog.hql  >> $logdir/load_${curDate}.log


通过jdbc 连接到beeline 就可以对 hive 进行操作了



我们再来看看看beeline 中除了SQL 操作,还支持什么别的操作。

执行help

!addlocaldriverjar  Add driver jar file in the beeline client side.
!addlocaldrivername Add driver name that needs to be supported in the beelineclient side.
!all                Execute the specified SQL against all the current connections
!autocommit         Set autocommit mode on or off
!batch              Start or execute a batch of statements
!brief              Set verbose mode off
!call               Execute a callable statement
!close              Close the current connection to the database
!closeall           Close all current open connections
!columns            List all the columns for the specified table
!commit             Commit the current transaction (if autocommit is off)
!connect            Open a new connection to the database.
!dbinfo             Give metadata information about the database
!describe           Describe a table
!dropall            Drop all tables in the current database
!exportedkeys       List all the exported keys for the specified table
!go                 Select the current connection
!help               Print a summary of command usage
!history            Display the command history
!importedkeys       List all the imported keys for the specified table
!indexes            List all the indexes for the specified table
!isolation          Set the transaction isolation for this connection
!list               List the current connections
!manual             Display the BeeLine manual
!metadata           Obtain metadata information
!nativesql          Show the native SQL for the specified statement
!nullemptystring    Set to true to get historic behavior of printing null asempty string. Default is false.
!outputformat       Set the output format for displaying results(table,vertical,csv2,dsv,tsv2,xmlattrs,xmlelements, anddeprecated formats(csv, tsv))
!primarykeys        List all the primary keys for the specified table
!procedures         List all the procedures
!properties         Connect to the database specified in the properties file(s)
!quit               Exits the program
!reconnect          Reconnect to the database
!record             Record all output to the specified file
!rehash             Fetch table and column names for command completion
!rollback           Roll back the current transaction (if autocommit is off)
!run                Run a script from the specified file
!save               Save the current variabes and aliases
!scan               Scan for installed JDBC drivers
!script             Start saving a script to a file
!set                Set a beeline variable
!sh                 Execute a shell command
!sql                Execute a SQL command
!tables             List all the tables in the database
!typeinfo           Display the type map for the current connection
!verbose            Set verbose mode onComments, bug reports, and patches go to ???

常用的几个指令:

1、!connect url –连接不同的Hive2服务器  
  
2、!exit –退出shell  
  
3、!help –显示全部命令列表  
  
4、!verbose –显示查询追加的明细  


http://chatgpt.dhexx.cn/article/SP1Gelry.shtml

相关文章

Hive3详细教程(四)beeline的使用

beeline提供了命令行中以简单字符串拼凑的图形形式的表结构&#xff0c;如下图所示&#xff0c;比hive客户端有更好的用户体验度。 配置beeline连接&#xff0c;需要在hadoop的etc/core.site.xml文件中添加以下配置权限代码&#xff1a; <property><name>hadoop.…

Hive CLI和Beeline命令行的基本使用

一、Hive CLI 1.1 Help 使用 hive -H 或者 hive --help 命令可以查看所有命令的帮助&#xff0c;显示如下&#xff1a; usage: hive-d,--define <keyvalue> Variable subsitution to apply to hive commands. e.g. -d AB or --define AB --定义用户自定义变…

【Qt学习】OpenCV帧差法 车辆识别

目录 一&#xff1a;效果展示 二&#xff1a;Qt UI界面设计 三&#xff1a;源码分享 一&#xff1a;效果展示 使用Qt界面实现 点击 线程启动按钮播放视频 同时 左边界面显示原视频 右边界面显示车辆识别视频 初始界面 点击线程启动后&#xff0c;即可车辆识别 框选车辆 二&a…

【车辆识别】基于卷积神经网络yolov3识别车辆和车辆速度附matlab代码

1 简介 近年来,自动驾驶研究,智慧交通建设突飞猛进,车辆检测技术成为业界的研究热点.由于深度卷积神经网络具有一定的旋转与平移不变性等特点,在车辆检测任务中得到广泛应用,其中,YOLOv3(You Only Look Once version 3)算法是目前主要的检测算法之一. 2 部分代码 clearclc​%…

基于深度学习的车牌+车辆识别(YOLOv5和CNN)

yolov5车牌识别+车辆识别 行人识别yolov5和v7对比 订阅专栏获得源码(提供完整代码,无需看下文) 基于深度学习的车牌识别(YOLOv5和CNN) 目录 一、综述 二、车牌检测 一、综述 本篇文章是面向的是小白,想要学习深度学习上的应用,本文中目前应用了YOLO v5和CNN来对车牌进行…

Qt +opencv 通过级联分类器训练的模型进行识别(车辆识别+人脸识别)

有不对的或更好的方法欢迎交流 一些内容可参照这篇文章&#xff1a;https://blog.csdn.net/m0_64596200/article/details/126748697?spm1001.2014.3001.5502 训练好的的模型&#xff1a; 车辆识别模型&#xff1a;https://download.csdn.net/download/m0_64596200/86507302?…

机器学习1:OpenCV4.5.5加载xml进行车辆识别

深度学习准确率高识别效果好&#xff0c;但是对软硬件环境要求高&#xff0c;使用及部署有一定难度&#xff0c;应用受限。相比之下&#xff0c;机器学习效果差一个量级&#xff0c;但是计算量小&#xff0c;计算迅速&#xff0c;部署相对容易&#xff0c;尤其是在一些计算能力…

基于YOLOv5的车辆识别系统

基于YOLOv5的车辆识别系统&#xff08;展示&#xff09; 文章目录 基于YOLOv5的车辆识别系统&#xff08;展示&#xff09;前言车牌识别车型识别 前言 YOLO能实现图像或视频中物体的快速识别&#xff0c;在相同的识别类别范围和识别准确率条件下&#xff0c;YOLO识别速度最快。…

Review of Vehicle Recognition Technology - 车辆识别技术综述

Review of Vehicle Recognition Technology - 车辆识别技术综述 ZHANG Qiang, LI Jiafeng, ZHUO Li Faculty of Information Technology, Beijing University of Technology, Beijing 100124, China 北京工业大学信息学部&#xff0c;北京 100124 Beijing University of Tech…

deeplearning.36车辆识别YOLO算法实践

车辆识别 下载相关资料导入相关包数据集定义YOLO模型细节分类阈值过滤非最大值抑制非最大值抑制函数对所有框进行过滤 测试训练好的yolo模型定义分类、锚框、图像维度加载已经训练好的模型模型的输出转换为边界框过滤锚框实际图像中运行计算图实际预测一下 下载相关资料 下载本…

基于python的transform行人车辆识别

Transformer是一种神经网络体系结构&#xff0c;由于它能够有效地处理顺序数据中的长期依赖性&#xff0c;因此在自然语言处理(NLP)任务中受到欢迎。它还被应用于各种其他任务&#xff0c;包括图像分类、对象检测和语音识别。 在车辆和行人识别方面&#xff0c;transformer可用…

使用Python和docTR提取车辆识别号

VIN&#xff08;车辆识别号&#xff09;是一个17个字符的字符串&#xff0c;由数字和大写字母组成&#xff0c;用作汽车的指纹。 它可以帮助识别任何一辆汽车的寿命&#xff0c;并获得有关它的具体信息。该唯一标识符在制造过程中打印在车辆的某个位置&#xff0c;以便人们在租…

Opencv python之车辆识别项目(附代码)

文章目录 图片车辆识别视频车辆识别 图片车辆识别 根据文章搭建好环境后开始进行做项目link import sys import cv2 from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtGui import QIcon, QPalette, QPixmap, QBrush, QRegExpValidatorclass mainWin(QW…

java opencv 之车辆识别

上篇写了人脸识别&#xff0c;因为人脸识别的训练模型 haarcascade_frontalface_alt.xml 之类的官方已经训练好了可以直接用&#xff0c;但是我们要识别车辆或者其它物体就得训练模型&#xff0c;好在废了一点力 找到了一位大神训练好的模型 核心代码 几乎和人脸识别的差不多 s…

如何开发一个车牌识别,车牌识别系统,车辆识别系统毕业设计毕设作品

开发准备 第1步&#xff1a;准备好百度智能云的账号 第2步&#xff1a;在百度智能云领取对应AI开发的免费资源包 第3步&#xff1a;创建对应的应用&#xff0c;然后获取对应的开发信息&#xff0c;主要是下面几个 AppID&#xff1a;应用列表中 API Key&#xff1a;应用列表…

车辆识别

一&#xff1a;简介 车牌识别系统(Vehicle License Plate Recognition&#xff0c;VLPR) 是指能够检测到受监控路面的车辆并自动提取车辆牌照信息&#xff08;含汉字字符、英文字母、阿拉伯数字及号牌颜色&#xff09;进行处理的技术。车牌识别是现代智能交通系统中的重要组成…

【OpenCV】 车辆识别 运动目标检测

目录 一&#xff1a;车辆识别 运动目标检测 二&#xff1a;车辆识别实现 超详细步骤解析 步骤一&#xff1a;灰度化处理 步骤二&#xff1a;帧差处理 步骤三&#xff1a;二值化处理 步骤四&#xff1a;图像降噪 4-1 腐蚀处理 目的 去除白色噪点 4-2 膨胀处理 目的 把白…

【OpenCV】车辆识别 C++ OpenCV 原理介绍 + 案例实现

目录 前言 一、图像处理 &#x1f4bb;二值化处理 &#x1f4bb;膨胀、腐蚀 &#x1f4bb;开运算、闭运算 二、案例实现 Step1&#xff1a;灰度处理 Step2&#xff1a;对视频进行帧差处理 Step3&#xff1a;二值化处理 Step4&#xff1a;腐蚀处理 Step5&#xff1a…

【OpenCV】车辆识别 目标检测 级联分类器 C++ 案例实现

目录 前言 一、目标检测技术 二、样本采集工作原理 三、创建自己的级联分类器 Step1&#xff1a;准备好样本图像 Step2&#xff1a;环境配置&#xff08;OpenCV win10&#xff09; Step3&#xff1a;设置路径 Step4&#xff1a;实现样本数据采集 Step5&#xff1a;实…

使用华为modelarts进行车辆识别

要求&#xff1a;从图像&#xff08;图3&#xff09;中检测并识别出车辆。车辆检测和识别算法可采用深度学习、BP网络或特征匹配等方法&#xff0c;方法不限。 图5-1待识别图像 原理&#xff1a;ModelArts是面向AI开发者的一站式开发平台&#xff0c;支持自动学习的功能&#…