forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
76 lines
7.2 KiB
HTML
76 lines
7.2 KiB
HTML
<a name="dli_02_0308"></a><a name="dli_02_0308"></a>
|
|
|
|
<h1 class="topictitle1">Creating and Submitting a SQL Job</h1>
|
|
<div id="body1602473883610"><div class="section" id="dli_02_0308__section851316282599"><h4 class="sectiontitle">Scenario</h4><p id="dli_02_0308__p18834648103219">This section describes how to submit a SQL job to create a database and table and query data using APIs.</p>
|
|
</div>
|
|
<div class="section" id="dli_02_0308__section13856162971"><h4 class="sectiontitle">Involved APIs</h4><ul id="dli_02_0308__ul1692954084313"><li id="dli_02_0308__li13929164064312"><a href="dli_02_0326.html">Creating an Elastic Resource Pool</a></li><li id="dli_02_0308__li492974014318"><a href="dli_02_0194.html">Creating a Queue</a></li><li id="dli_02_0308__li792924064315"><a href="dli_02_0102.html">Submitting a SQL Job (Recommended)</a></li></ul>
|
|
</div>
|
|
<div class="section" id="dli_02_0308__section2742155213719"><h4 class="sectiontitle">Procedure</h4><ol id="dli_02_0308__ol454620011213"><li id="dli_02_0308__li33424532067">Create an elastic resource pool named <strong id="dli_02_0308__b357614343613">elastic_pool_dli</strong>.<ul id="dli_02_0308__ul12410110912"><li id="dli_02_0308__li11419115919">API<p id="dli_02_0308__p164191891"><a name="dli_02_0308__li11419115919"></a><a name="li11419115919"></a>URI format: POST /v3/{project_id}/elastic-resource-pools</p>
|
|
<ul id="dli_02_0308__ul1241011696"><li id="dli_02_0308__li859113919">Obtain the value of <em id="dli_02_0308__i15513442576">{project_id}</em> by referring to <a href="dli_02_0183.html">Obtaining a Project ID</a>.</li><li id="dli_02_0308__li15516118917">For details about the request parameters, see <a href="dli_02_0326.html">Creating an Elastic Resource Pool</a>.</li></ul>
|
|
</li><li id="dli_02_0308__li12516114916">Example request<ul id="dli_02_0308__ul751915920"><li id="dli_02_0308__li566016160313">Description: Create an elastic resource pool named <strong id="dli_02_0308__b798117422815">elastic_pool_dli</strong> in the project whose ID is <strong id="dli_02_0308__b740210537817">48cc2c48765f481480c7db940d6409d1</strong>.</li><li id="dli_02_0308__li35614911">Example URL: POST https://{endpoint}/v3/48cc2c48765f481480c7db940d6409d1/elastic-resource-pools</li><li id="dli_02_0308__li45411199">Body:<pre class="screen" id="dli_02_0308__screen12372049928">{
|
|
"elastic_resource_pool_name" : "elastic_pool_dli",
|
|
"description" : "test",
|
|
"cidr_in_vpc" : "172.16.0.0/14",
|
|
"charging_mode" : "1",
|
|
"max_cu" : 64,
|
|
"min_cu" : 64
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0308__li151915918">Example response<pre class="screen" id="dli_02_0308__screen75911798">{
|
|
"is_success": true,
|
|
"message": ""
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0308__li1353820471116">Create a queue named <strong id="dli_02_0308__b31838118103">queue1</strong> in the elastic resource pool.<ul id="dli_02_0308__ul25387411111"><li id="dli_02_0308__li3538940114">API<p id="dli_02_0308__p353814419114"><a name="dli_02_0308__li3538940114"></a><a name="li3538940114"></a>URI format: POST /v1.0/{project_id}/queues</p>
|
|
<ul id="dli_02_0308__ul1853810411114"><li id="dli_02_0308__li55381045113">Obtain the value of <em id="dli_02_0308__i64278341103">{project_id}</em> by referring to <a href="dli_02_0183.html">Obtaining a Project ID</a>.</li><li id="dli_02_0308__li35388431118">For details about the request parameters, see <a href="dli_02_0194.html">Creating a Queue</a>.</li></ul>
|
|
</li><li id="dli_02_0308__li7538164171114">Example request<ul id="dli_02_0308__ul125381147119"><li id="dli_02_0308__li1853864171117">Description: Create an elastic resource pool named <strong id="dli_02_0308__b121411747181016">queue1</strong> in the project whose ID is <strong id="dli_02_0308__b614214761014">48cc2c48765f481480c7db940d6409d1</strong>.</li><li id="dli_02_0308__li1053817421112">Example URL: POST https://{<em id="dli_02_0308__i17969151851118">endpoint</em>}/v1.0/48cc2c48765f481480c7db940d6409d1/queues</li><li id="dli_02_0308__li15383461112">Body:<pre class="screen" id="dli_02_0308__screen105384441117">{
|
|
"queue_name": "queue1",
|
|
"queue_type": "sql",
|
|
"description": "test",
|
|
"cu_count": 16,
|
|
"enterprise_project_id": "elastic_pool_dli"
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0308__li753818411110">Example response<pre class="screen" id="dli_02_0308__screen253811441117">{
|
|
"is_success": true,
|
|
"message": ""
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0308__li125211016104016">Submit a SQL job: Create the database <strong id="dli_02_0308__b530682711181">db1</strong>, table <strong id="dli_02_0308__b15902163241816">tb1</strong>, insert data into the table, and query the data.<ul id="dli_02_0308__ul26571210114414"><li id="dli_02_0308__li146576102444">API<p id="dli_02_0308__p10657111019442"><a name="dli_02_0308__li146576102444"></a><a name="li146576102444"></a>URI format: POST /v1.0/{<em id="dli_02_0308__i938127193718">project_id</em>}/jobs/submit-job</p>
|
|
<ul id="dli_02_0308__ul56581107449"><li id="dli_02_0308__li17658191013442">Obtain the value of <em id="dli_02_0308__i10199514293">{project_id}</em> by referring to <a href="dli_02_0183.html">Obtaining a Project ID</a>.</li><li id="dli_02_0308__li3658201018442">For details about the request parameters, see <a href="dli_02_0102.html">Submitting a SQL Job (Recommended)</a>.</li></ul>
|
|
</li><li id="dli_02_0308__li10658410164410">Example request<ul id="dli_02_0308__ul14658161015442"><li id="dli_02_0308__li865851014449">Description: In the project whose ID is <strong id="dli_02_0308__b415014012186">48cc2c48765f481480c7db940d6409d1</strong>, submit a SQL job, create the database <strong id="dli_02_0308__b281430191920">db1</strong> and table <strong id="dli_02_0308__b88805431917">tb1</strong>, insert data into the table, and query the data.</li><li id="dli_02_0308__li6658171074411">Example URL: POST https://{<em id="dli_02_0308__i16945104683715">endpoint</em>}/v1.0/48cc2c48765f481480c7db940d6409d1/jobs/submit-job</li><li id="dli_02_0308__li165811084419">Create a database named <strong id="dli_02_0308__b15571134161216">db1</strong>.<pre class="screen" id="dli_02_0308__screen69155911186">{
|
|
"queue_name": "queue1",
|
|
"sql": "create DATABASE db1"
|
|
}</pre>
|
|
</li><li id="dli_02_0308__li111901328367">Create a table named <strong id="dli_02_0308__b59205143123">tb1</strong>.<pre class="screen" id="dli_02_0308__screen111786239365">{
|
|
"currentdb": "db1",
|
|
"queue_name": "queue1",
|
|
"sql": "create table\n my_table (id int, name string)"
|
|
}</pre>
|
|
</li><li id="dli_02_0308__li18600830383">Insert data into the <strong id="dli_02_0308__b20708102115122">tb1</strong> table.<pre class="screen" id="dli_02_0308__screen11600113193814">{
|
|
"currentdb": "db1",
|
|
"queue_name": "queue1",
|
|
"sql": "insert into tb1 (id, name) values (1, 'Ann'), (2, 'Jane')"
|
|
}</pre>
|
|
</li></ul>
|
|
<ul id="dli_02_0308__ul564812123401"><li id="dli_02_0308__li26481512184014">Query data in the table.<pre class="screen" id="dli_02_0308__screen2648111210404">{
|
|
"currentdb": "db1",
|
|
"queue_name": "queue1",
|
|
"sql": "select * from tb1 limit 10",
|
|
}</pre>
|
|
</li></ul>
|
|
</li><li id="dli_02_0308__li16771130124213">Example response<pre class="screen" id="dli_02_0308__screen1967743034216">{
|
|
"is_success": true,
|
|
"message": ""
|
|
}</pre>
|
|
</li></ul>
|
|
</li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_02_0306.html">Getting Started</a></div>
|
|
</div>
|
|
</div>
|
|
|