Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Custom variables in Beeline

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to use custom variables in Beeline. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

1. Purpose of document writing

When users use the hive and beeline commands to execute SQL, there is a need to dynamically specify parameters in the SQL statement. How can this be realized? This article Fayson focuses on how to use custom variables in Beeline. This article applies to the CDH5 version.

Test environment description

1.CM5.15.0 and CDH5.14.2

Use of 2.Beeline custom variables

When using Beeline (a new HiveServer2-based client) on CDH5.x, you need to use the passed variables displayed by the parameters (such as:-- hivevar key=value). The following Fayson illustrates with an example

1. Define a sql file with Hive execution statements in it

[root@cdh03 ~] # more test.sql

Select * from ${TBNAME} limit 10

(can slide left and right)

Here, the table name in the SQL statement is used as a dynamic parameter.

two。 Add a custom parameter to the beeline command line and execute it, passing the table name dynamically

[root@cdh03] # beeline-- hivevar TBNAME=ods_user-u "jdbc:hive2://cdh01.fayson.com:10000"-n testa-p '123 QAZ'-f test.sql

(can slide left and right)

This is how to use custom variables in Beeline shared by the editor. If you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report