首页 \ 问答 \ 如何实现HiveQL错误处理(how to achieve HiveQL error handling)

如何实现HiveQL错误处理(how to achieve HiveQL error handling)

我在一个hql文件中有多个查询(比方说10,每个查询以;结尾),我从shell脚本运行。

当中间的查询失败时(例如查询#5),5之后的查询不执行,并且hive作业完成。

即使查询5失败,我如何进行错误处理以确保从6到10的查询运行?


I have multiple queries in a hql file (say 10, every query ending with ;) which I am running from a shell script.

When a query in between fails (say query #5), the queries after 5 do not execute, and the hive job is completed.

How can I do error handling to make sure that queries from 6 to 10 run even though query 5 fails?


原文:https://stackoverflow.com/questions/44227777
更新时间:2023-05-09 14:05

最满意答案

要登录,您需要知道要POST的 数据 (id,密码,会话cookie等),以及POST所需的URL地址

此信息通常都包含在登录表单中,我将在下面解释执行此操作所需的步骤:

第1步 :登录时需要输入的ID密码应该是表单的输入。 因此,只需右键单击您在ID中键入的区域,然后选择Inspect Element (假设您在Chrome上)。 在那里,您将能够检查输入和表格的属性。

第2步 :密切调查表格并记录所有输入字段(包括隐藏字段)。 您需要知道所有字段的namevalue 。 您还需要知道表单请求是在GET还是POST进行的,以及表单的action值。

第3步 :现在让我们来看看有趣的部分。 使用以下代码段向服务器发出请求并检索所需内容。

Connection.Response loginRes = Jsoup.connect(loginUrl)
                               .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36"
                               .data("login", yourID
                                     "haslo", yourPassword)
                               .cookies(response.cookies()) //this is the same cookie you used for url2!
                               .method(Method.POST)
                               .execute();
  • loginUrl是请求地址,在您的情况下将是"http://www.klt.net.pl/index.php?a=logowanie"
  • userAgent告诉服务器您的浏览器详细信息。
  • data是您在表单中放置所有输入字段的名称和值对的位置。
  • cookies是您放置cookie的地方,您需要检查您的请求是否需要服务器接受cookie,这可以在“cookies”部分的网络选项卡中查看。 在您的情况下,它与用于url2的cookie相同。
  • method指定您的请求方法。

检索到的loginRes对象将包含您需要的所有信息,html,cookie和所有内容。

成功登录后,请确保将cookie值存储在Map对象中,如下所示:

Map<String, String> cookies;
cookies.putAll(loginRes.cookies());

然后确保在以后的所有请求中将此cookies传递给cookie参数,如下所示:

Connection.Response otherRes = Jsoup.connect(otherUrl).cookies(cookies)....

这将确保维护您的登录会话,并确保服务器知道您是经过身份验证的用户。

----------------更新------------

从doInBackground任务的开头声明Map cookie。 然后在您提出每个请求后存储所有COOKIES 。 所以:

cookies = response.cookies();
cookies.putAll(loginRes.cookies();
cookies.putAll(otherRes.cookies();

To login you need to know what data to POST (id, password, session cookie and etc...), and the url address you need to POST to.

This information is generally all contained in the login form, I'll explain the steps required to do this below:

Step 1: The ID and password that you need to enter to login should be inputs of a form. So simply right-click the area where you type in your ID and select Inspect Element (assuming you are on Chrome). There you will be able to inspect the property of the inputs and the form.

Step 2: Closely investigate the form and keep record of ALL INPUT FIELDS (including hidden fields). You need to know the name and value of all fields. You also need to know if the form request is made in GET or POST and the action value for the form.

Step 3: Now let's get to the fun part. Use the following code snippet to make your request to the server and retrieve the desired content.

Connection.Response loginRes = Jsoup.connect(loginUrl)
                               .userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36"
                               .data("login", yourID
                                     "haslo", yourPassword)
                               .cookies(response.cookies()) //this is the same cookie you used for url2!
                               .method(Method.POST)
                               .execute();
  • loginUrl is the request address, which in your case would be "http://www.klt.net.pl/index.php?a=logowanie".
  • userAgent tells the server your browser details.
  • data is where you put your name&value pairs of all input fields in the form.
  • cookies is where you put your cookies, you need to check if your request requires cookies to be accepted by the server, this can be checked in the network tab under "cookies" section. In your case, its the same cookie used for url2.
  • method specifies your request method.

The retrieved loginRes object will contain all the info you need, the html, cookies and everything.

After you've successfully logged in, make sure you store the cookie value in a Map object like below:

Map<String, String> cookies;
cookies.putAll(loginRes.cookies());

And then make sure to pass this cookies to the cookies parameter in all future requests, like below:

Connection.Response otherRes = Jsoup.connect(otherUrl).cookies(cookies)....

This will ensure that your login session is maintained and the server knows you are authenticated user.

----------------update------------

Declare Map cookie from the beginning of the doInBackground task. Then store ALL COOKIES after you make every request. So:

cookies = response.cookies();
cookies.putAll(loginRes.cookies();
cookies.putAll(otherRes.cookies();

相关问答

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。