<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Kettle on eree's blog</title><link>https://blog.ereebay.me/en/tags/kettle/</link><description>Recent content in Kettle on eree's blog</description><generator>Hugo</generator><language>en</language><copyright>2020-2026 eree&amp;rsquo;s blog</copyright><lastBuildDate>Sat, 23 Mar 2019 12:44:49 +0800</lastBuildDate><atom:link href="https://blog.ereebay.me/en/tags/kettle/index.xml" rel="self" type="application/rss+xml"/><item><title>Getting Started with Kettle</title><link>https://blog.ereebay.me/en/posts/kettle%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B/</link><pubDate>Sat, 23 Mar 2019 12:44:49 +0800</pubDate><guid>https://blog.ereebay.me/en/posts/kettle%E5%85%A5%E9%97%A8%E6%95%99%E7%A8%8B/</guid><description>&lt;h1 id="getting-started-with-kettle"&gt;Getting Started with Kettle&lt;/h1&gt;
&lt;p&gt;Since I was still one credit short in my final semester, I had to take one more course, and looking at the schedule the only option was OLAP — yet another completely unfamiliar subject. Tutorials about Kettle online are scarce, so I gathered some materials and jotted down these notes on the tool this course requires&lt;/p&gt;
&lt;!-- more --&gt;
&lt;h2 id="introduction-to-kettle"&gt;Introduction to Kettle&lt;/h2&gt;
&lt;p&gt;Kettle is an ETL (Extract, Transform and Load) tool for data extraction, transformation, and loading. ETL tools are used very frequently in data warehouse projects, and Kettle can also be applied in the following scenarios:&lt;/p&gt;</description><content:encoded><![CDATA[<h1 id="getting-started-with-kettle">Getting Started with Kettle</h1>
<p>Since I was still one credit short in my final semester, I had to take one more course, and looking at the schedule the only option was OLAP — yet another completely unfamiliar subject. Tutorials about Kettle online are scarce, so I gathered some materials and jotted down these notes on the tool this course requires</p>
<!-- more -->
<h2 id="introduction-to-kettle">Introduction to Kettle</h2>
<p>Kettle is an ETL (Extract, Transform and Load) tool for data extraction, transformation, and loading. ETL tools are used very frequently in data warehouse projects, and Kettle can also be applied in the following scenarios:</p>
<ul>
<li>
<p>Integrating data across different applications or databases</p>
</li>
<li>
<p>Exporting data from a database to text files</p>
</li>
<li>
<p>Loading bulk data into a database</p>
</li>
<li>
<p>Data cleansing</p>
</li>
</ul>
<p>It is also used in projects involving application integration</p>
<p>Kettle is very easy to use: you design what business logic to implement through a graphical interface, with no need to write code; therefore, Kettle is designed in a metadata-oriented way</p>
<p>Kettle supports many input and output formats, including text files, data tables, and both commercial and free database engines. In addition, Kettle&rsquo;s powerful transformation features make it very convenient to manipulate data.</p>
<h2 id="installing-kettle">Installing Kettle</h2>
<p><a href="https://community.hitachivantara.com/docs/DOC-1009855">Download link</a></p>
<p>Since my platform is macOS and there is a bug that prevents it from launching on double-click, I could only extract the archive and then run in the terminal</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">sh spoon.sh
</span></span></code></pre></div><p>to start Spoon</p>
<h2 id="data-transformation---exporting-to-excel">Data Transformation - Exporting to Excel</h2>
<ol>
<li>Connect to the database</li>
<li>Export to Excel</li>
</ol>
<p>First, create a new transformation as shown in the figure below, and set up the database connection.</p>
<p><img loading="lazy" src="/images/kettle/kettle-1.png"></p>
<p><img loading="lazy" src="/images/kettle/kettle-2.png"></p>
<p>Once the database connection is set up, you can configure the input source; here we use a table in the database as the input source</p>
<p><img loading="lazy" src="/images/kettle/kettle-3.png"></p>
<p>With the input source configured, you can click preview to take a look at the data first</p>
<p><img loading="lazy" src="/images/kettle/kettle-4.png"></p>
<p>After setting up the input source, likewise drag the Excel output onto the workspace, but don&rsquo;t rush to configure the output source yet: in the View pane, add a hop to connect the input and output sources</p>
<p><img loading="lazy" src="/images/kettle/kettle-5.png"></p>
<p>This way, when you configure the output source, you can directly fetch and select the fields to export in the Fields tab</p>
<p><img loading="lazy" src="/images/kettle/kettle-6.png"></p>
<p>Finally, click Start to run the transformation</p>
<p><img loading="lazy" src="/images/kettle/kettle-7.png"></p>
<p>Let&rsquo;s take a look at the exported file</p>
<p><img loading="lazy" src="/images/kettle/kettle-8.png"></p>
<h2 id="hello-world">Hello World</h2>
<p>Alright, now that you have learned how transformations work, let&rsquo;s do a Hello World example. I came across this tutorial online and found it pretty good — it lets you get in touch with more of Kettle&rsquo;s features, unlike my very basic walkthrough above.</p>
<p>This Hello World outputs a corresponding greeting for each name in the database and exports the result to a file.</p>
<p>First, set up the input source the same way, but the SQL statement needs a small change: here I selected only their names, ordered by id, limited to the first ten.</p>
<p>Then write a small JavaScript script to automatically add a &ldquo;hello&rdquo;</p>
<p><img loading="lazy" src="/images/kettle/kettle-9.png"></p>
<p>Finally, link the three steps with hops; you can run preview first to check the result</p>
<p><img loading="lazy" src="/images/kettle/kettle-10.png"></p>
<p><img loading="lazy" src="/images/kettle/kettle-11.png"></p>
<p>Then take a look at the result</p>
<p><img loading="lazy" src="/images/kettle/kettle-12.png"></p>
<p>The above only demonstrates the most basic features of data transformation; other, more detailed features can all be found in the Design tab
In short, Kettle&rsquo;s operating logic is steps + hops: a step is an operation you perform, and hops are the links between them.</p>
<h2 id="jobs">Jobs</h2>
<p>The above covered transformations, one of Kettle&rsquo;s core features; now let&rsquo;s introduce another Kettle feature, the job.</p>
<p>A job is essentially an automated workflow: when you need to run multiple transformations or add some logical control conditions, you need a job.</p>
<p>Here, following the earlier Hello World example, we build a simple job that detects when the file does not exist in the folder and then automatically exports data from the database and adds &ldquo;hello&rdquo;.</p>
<p><img loading="lazy" src="/images/kettle/kettle-13.png"></p>
<p>Find the widget shown in the figure above in the toolbar on the right, drag it into the workspace, connect things with hops, and configure it — that&rsquo;s it. The operations are similar to those for creating a transformation; it just combines several of them together</p>
<p>The figure below shows the transformation configuration interface, where you enter the path of the transformation script</p>
<p><img loading="lazy" src="/images/kettle/kettle-14.png"></p>
<h2 id="kitchen-and-pan">Kitchen and Pan</h2>
<p>The kitchen and pan commands are used to execute job and transformation scripts.</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-zsh" data-lang="zsh"><span class="line"><span class="cl">./kitch.sh -file ./scripts/demo.kjb
</span></span><span class="line"><span class="cl">./pan.sh -file ./scripts/demo.ktr
</span></span></code></pre></div><p>From now on, just save the jobs and transformations designed in Spoon and run them directly from the command line — much more convenient.</p>
<p>I&rsquo;ll update these notes whenever I get to use new features.</p>
<h2 id="references">References</h2>
<p><a href="http://www.cnblogs.com/limengqiang/archive/2013/01/16/KettleApply1.html#syzj">The ETL Powerhouse Kettle in Practice, Part 1 [Introduction to Kettle]</a></p>
<p><a href="https://blog.csdn.net/u012637358/article/details/82593492">KETTLE Tutorial</a></p>
<p><a href="https://blog.csdn.net/neweastsun/article/details/38845795">Using Kettle Jobs</a></p>
<p><a href="https://ask.hellobi.com/blog/yuguiyang1990/category/1532">Kettle Tutorials</a></p>
<p><a href="http://www.kettle.net.cn/">Kettle Chinese Community</a></p>
]]></content:encoded></item></channel></rss>