<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Pentaho 技術專欄 彙整 - 歐立威科技</title>
	<atom:link href="https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/</link>
	<description>歐立威科技 Omniwaresoft｜全方位企業級開源軟體解決方案</description>
	<lastBuildDate>Tue, 27 Jan 2026 09:48:04 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.4</generator>

<image>
	<url>https://www.omniwaresoft.com.tw/wp-content/uploads/2022/12/android-icon-192x192-1.png</url>
	<title>Pentaho 技術專欄 彙整 - 歐立威科技</title>
	<link>https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">242464019</site>	<item>
		<title>Pentaho VS Apache Hop：選擇最佳 ETL 工具的關鍵考量</title>
		<link>https://www.omniwaresoft.com.tw/techcolumn/pentaho-vs-apache-hop/</link>
		
		<dc:creator><![CDATA[gladdis siew]]></dc:creator>
		<pubDate>Tue, 01 Jul 2025 03:20:12 +0000</pubDate>
				<category><![CDATA[Pentaho 技術專欄]]></category>
		<category><![CDATA[技術專欄]]></category>
		<category><![CDATA[Pentaho]]></category>
		<guid isPermaLink="false">https://www.omniwaresoft.com.tw/?p=44783</guid>

					<description><![CDATA[在數據驅動的時代，企業對於高效、靈活的資料整合工具需求日益增加。Kettle 和 Apache Hop 作為兩款重要的開源 ETL（Extract, Transform, Load）工具，在資料工程領域扮演著關鍵角色。它們不僅體現了開源社群的創新精神，也反映了資料處理技術的演進趨勢。]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading"><strong>背景介紹</strong></h2>



<p>Kettle 和 Apache Hop 作為兩款重要的開源 ETL（Extract，Transform，Load）工具，在資料工程領域扮演著關鍵角色。<span style="background-image: linear-gradient(transparent 60%, rgba(252, 185, 0, 0.5) 60%)" class="sme-highlighter">它們不僅體現了開源社群的創新精神，也反映了資料處理技術的演進趨勢。</span></p>



<h3 class="wp-block-heading"><strong>Kettle 的起源與發展</strong></h3>



<p>Kettle 最初由比利時開發者 Matt Casters 於 2001 年開發，並於 2005 年以 LGPL 授權方式開源。2006 年，Kettle 被 Pentaho 收購，並更名為 Pentaho Data Integration（PDI），成為其商業智慧平台的重要組件。2015 年，Hitachi Data Systems 宣布收購 Pentaho，並將其整合至自家先進分析軟體中，以強化物聯網（IoT）和大數據分析的市場領導地位。</p>



<h3 class="wp-block-heading"><strong>Apache Hop 的誕生與演進</strong></h3>



<p>2019 年，原 Kettle 開發團隊成員啟動了 Apache Hop（Hop Orchestration Platform）專案，作為 Kettle 的分支，重新設計資料整合平台以滿足現代資料工程的需求。Apache Hop 採用模組化架構，強調元資料驅動，並提供直覺式圖形化介面，使資料工程師能更高效地設計、執行和監控資料流程。2021 年，Apache Hop 發布首個正式版本，並於 2022 年初正式成為 Apache 軟體基金會的頂級專案。</p>



<p>這段歷程展現了開源社群在資料整合領域的持續創新，也為企業選擇 ETL 工具提供了更多元、現代化的選項。</p>



<p>然而，深入實作後會發現，Pentaho 與 Apache Hop 雖理念相近，但在術語與架構設計上仍有不少差異。</p>



<p>為幫助大家釐清這些概念落差，接下來將逐一拆解核心對照。</p>



<h2 class="wp-block-heading"><strong>術語與基礎架構對比</strong></h2>



<h3 class="wp-block-heading"><strong>核心概念對照</strong></h3>



<p>Pentaho 與 Apache Hop 的操作邏輯有許多共通之處，但命名方式大不相同。以下是幾個最常見的概念對照：</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td><strong>PDI（Pentaho）</strong></td><td><strong>Apache Hop</strong></td><td><strong>解釋</strong></td></tr><tr><td>Transformation</td><td>Pipeline</td><td>皆為設計資料處理流程的主要單位，用來串接並執行一連串的轉換步驟。</td></tr><tr><td>Step</td><td>Transform</td><td>流程中的單一步驟，執行資料處理任務，如讀取、轉換、輸出等。</td></tr><tr><td>Job</td><td>Workflow</td><td>控制流程邏輯（如條件判斷、迴圈、任務串接等）的單元。</td></tr><tr><td>Spoon（GUI）</td><td>Hop GUI</td><td>可視化開發介面，協助使用者設計 ETL 任務。</td></tr></tbody></table></figure>



<h2 class="wp-block-heading"><strong>開發介面比較</strong></h2>



<p>左圖為 Pentaho 的 Spoon 介面：使用者透過左側元件選單拖拉 Step 至畫布建立 Transformation，<span style="background-image: linear-gradient(transparent 60%, rgba(252, 185, 0, 0.5) 60%)" class="sme-highlighter">操作方式直覺，適合視覺化建構流程</span>。</p>



<p>右圖為 Apache Hop GUI：使用者透過滑鼠右鍵在畫布上開啟選單後選取 Transform 插入至 Pipeline，<span style="background-image: linear-gradient(transparent 60%, rgba(252, 185, 0, 0.5) 60%)" class="sme-highlighter">操作邏輯更模組化</span>。</p>



<p class="has-text-align-center"><img fetchpriority="high" src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe_eHNF_5malDqI7oseqVWx4umPjomvsePQ2mID7rMc6a6t3GyXv_i3_iiUBV28EIw-YpyyujmafLG6_VuqyiyiP8U91-sNCOn5BTlBbGZb5W_DC7OdLtR1qv0D3J5pnHa5yabyjvThrdl8I7KhNPk?key=8C6v2tbdAt8XX2v-8ic0OA" width="602" height="376"></p>



<p class="has-text-align-center"></p>



<h2 class="wp-block-heading"><strong>執行工具比較</strong></h2>



<p>Pentaho 使用兩個命令列工具分別執行不同流程：</p>



<ul class="wp-block-list">
<li>pan：執行 Transformation</li>



<li>kitchen：執行 Job</li>
</ul>



<p>Apache Hop 則使用單一工具 hop-run，可同時執行 Pipeline 或 Workflow，簡化指令與排程整合。</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><tbody><tr><td class="has-text-align-center" data-align="center"><img width="286" height="307" src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXd_3zRKQyTfLFE34NMat7cqDZq54LZSUo6MbwQDo_-hQcHWfCDFkExG9GSb9uCbojqlt8wHLCs43xQPdN7oRROcnlutCD-yqiXcnriSEAjIuhjxQhdZ1QLdH8GRQgisO3dcPTrjJqopNARd1cPIJAo?key=8C6v2tbdAt8XX2v-8ic0OA"></td><td class="has-text-align-center" data-align="center"><img width="286" height="245" src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcb_nJ6rC98EmfZDTB7FSVh7i5V2F03jE7cktHrFGW5icjJB5MmpM-4CLpJPjdPuSsmAfHNeEmTpW64jyejv8HbJPj3SD2HsSxXkORB9c0RGMtL9j3ao5ELaS7IC3_dTdsh61S1mGC3StiMbAXF5-k?key=8C6v2tbdAt8XX2v-8ic0OA"></td></tr></tbody></table></figure>



<h2 class="wp-block-heading"><strong>遠端伺服器比較</strong></h2>



<h3 class="wp-block-heading"><strong>Pentaho Carte Server</strong></h3>



<ul class="wp-block-list">
<li>提供 HTTP Servlet 接口接收 XML 任務請求，並回傳執行結果。<br></li>
</ul>



<h3 class="wp-block-heading"><strong>Apache Hop Server</strong></h3>



<ul class="wp-block-list">
<li>支援標準 RESTful API（使用 JSON 格式），更易與 Airflow 等自動化平台整合。</li>



<li>可搭配 Run Configurations 指定任務執行位置（如本機、遠端、Spark 等）並提供 UI 監控介面。</li>
</ul>



<p>雖然 Hop Server 架構更現代化，但實際操作邏輯上與 Carte Server 相近，對熟悉 PDI 的使用者而言轉換門檻不高。</p>



<h2 class="wp-block-heading"><strong>專案管理與版本控管功能</strong></h2>



<h3 class="wp-block-heading"><strong>Pentaho：Repository 架構</strong></h3>



<ul class="wp-block-list">
<li>集中儲存 Transformation / Job</li>



<li>支援權限設定與版本管理（企業版）</li>
</ul>



<h3 class="wp-block-heading"><strong>Apache Hop：開放式儲存結構</strong></h3>



<ul class="wp-block-list">
<li>支援 Git 儲存與版本控制</li>



<li>元資料可放在 S3 等雲端平台</li>



<li>結構清晰，利於 DevOps 流程與 CI/CD 整合</li>
</ul>



<p>*適合需要跨環境佈署、敏捷協作的資料工程團隊</p>



<h2 class="wp-block-heading"><strong>成功案例：Pentaho 資料遷移</strong></h2>



<p><strong>情境</strong>：某大型銀行每日在其核心 OLTP（Online Transaction Processing）系統中產生大量交易紀錄，例如轉帳、提款、存款與繳費等。這些交易資料需要每日準時依照排程，自動搬移到 Greenplum 數據倉儲系統，以支援內部的財務報表、客戶行為分析、風險控管及其他商業決策用途。</p>



<p>為了確保資料處理流程穩定、透明且具備高可靠性，此解決方案不僅僅完成資料搬移，<span style="background-image: linear-gradient(transparent 60%, rgba(252, 185, 0, 0.5) 60%)" class="sme-highlighter">更強調資料檢核機制與異常處理能力</span>，以保證：</p>



<ul class="wp-block-list">
<li>不重複搬資料（No duplication）</li>



<li>不漏搬資料（No data loss）</li>



<li>不誤搬資料（No corruption）</li>
</ul>



<p><strong>解決方案：Airflow + Pentaho PDI</strong></p>



<ul class="wp-block-list">
<li><strong>Airflow</strong>：排程、重試控制與任務監控</li>



<li><strong>PDI</strong>：資料抽取、轉換與目標資料庫寫入</li>
</ul>



<p>下圖說明了 Airflow 與 Pentaho 之間的資料遷移流程</p>



<p><strong>圖表說明: </strong>​</p>



<p>Airflow 觸發排程（對應一個 Pentaho job），Pentaho 擷取來源資料並計算筆數後，根據客戶需求進行寫入（如 update/insert 或 truncate/insert）。寫入完成後再計算目標端筆數，最後由 Airflow 驗證兩邊筆數是否一致，以判斷是否成功。</p>



<figure class="wp-block-image"><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcXGHePhVSGCB1_2l1o2QGK-PEYv0Gr8H_mHXvX1YKgc2eqKFEgJ0Pj-XYy44D4AYgsF8GYjjILo7iGKkZswgkNQPUVp51UU6L1ALw1fZC5nIDFjgKS7cpNByHSDB-ZcyhwTP7y0ZFeiKov0_O2Ow?key=8C6v2tbdAt8XX2v-8ic0OA" alt=""/></figure>



<p>註：虛線箭頭代表資料流向（Data Flow）</p>



<p>透過 Airflow 與 Pentaho 的整合，不僅實現了自動化、穩定且可監控的資料搬移流程，更確保了資料的一致性與完整性，為企業後續的數據分析與決策提供了可靠基礎。</p>



<p><span style="background-image: linear-gradient(transparent 60%, rgba(252, 185, 0, 0.5) 60%)" class="sme-highlighter">推薦閱讀：</span><a href="https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/pentaho-etl-practices-table-input-and-output/" target="_blank" rel="noreferrer noopener">Pentaho ETL 實作技巧：SQL 動態內容引用 Table input &amp; Execute SQL scripts</a></p>



<iframe width="560" height="315" src="https://www.youtube.com/embed/MbJgNJUPU5g?si=Y6n6Ozb2CT2j5wKI" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>



<p><strong>文章參考資料</strong></p>



<p>[1] <a href="https://kettle.bleuel.com/2015/02/14/some-historic-cornerstones-of-kettle-pentaho/?utm_source=chatgpt.com" target="_blank" rel="noreferrer noopener">kettle背景</a></p>



<p>[2] <a href="https://www.youtube.com/watch?v=6mZFXoi-fnM" target="_blank" rel="noreferrer noopener">Pentaho VS Hop-ETL 圖形化開發工具的新戰場</a></p>



<p>[3] <a href="https://hop.apache.org/tech-manual/latest/hop-vs-kettle/index.html" target="_blank" rel="noreferrer noopener">Hop vs Kettle</a></p>



<p>[4] <a href="https://www.omniwaresoft.com.tw/product-news/pentaho-news/pentaho-ee-ec-edition/" target="_blank" rel="noreferrer noopener">Pentaho 企業與社群版本的開源優勢</a></p>



<p>[5] <a href="https://hop.apache.org/manual/latest/index.html" target="_blank" rel="noreferrer noopener">Hop 官方文件</a></p>



<p>[6] <a href="https://docs.hitachivantara.com/r/en-us/pentaho-data-integration-and-analytics/10.2.x/mk-95pdia003/pdi-transformation-steps/avro-output" target="_blank" rel="noreferrer noopener">Pentaho 官方文件</a></p>



<p>想了解更多資訊，<a href="https://www.omniwaresoft.com.tw/contact/" target="_blank" rel="noreferrer noopener">歡迎聯絡我們</a>，或是 <a href="https://page.line.me/870pcqyh?oat__id=4761625&amp;openQrModal=true" target="_blank" rel="noreferrer noopener">加入歐立威 Line 好友！</a></p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">44783</post-id>	</item>
		<item>
		<title>Pentaho ETL 實作技巧：無共通欄位資料合併 Merge join &#038; Multiway merge join</title>
		<link>https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/pentaho-merge-join-and-mulitiway-merge-join-practices/</link>
		
		<dc:creator><![CDATA[Omni]]></dc:creator>
		<pubDate>Fri, 17 Nov 2023 10:21:37 +0000</pubDate>
				<category><![CDATA[Pentaho 技術專欄]]></category>
		<category><![CDATA[ETL]]></category>
		<category><![CDATA[Pentaho]]></category>
		<guid isPermaLink="false">https://www.omniwaresoft.com.tw/?p=38517</guid>

					<description><![CDATA[對於使用 Pentaho (或者類似產品Kettle / Hop) 這類 ETL 工具的開發人員來說，總有一些藏在角落、鮮為人知的方便功能。筆者在此將講解有關 Pentaho 流程中， Merge join 與Multiway merge join 的資料合併做法。]]></description>
										<content:encoded><![CDATA[</p>
<p>


<p>對於使用 Pentaho (或者類似產品 Kettle / Hop) 這類 ETL 工具的開發人員來說，總有一些藏在角落、鮮為人知的方便功能。<br>筆者在此將講解有關 Pentaho 流程中，Merge join 與 Multiway merge join 的資料合併做法。</p>


</p>
<p>


<h2 class="wp-block-heading"><b>資料合併步驟</b></h2>



<p></p>



<p></p>


</p>
<p>


<h2 class="wp-block-heading"><b>Merge join</b></h2>


</p>
<p>


<p><b><i>萬一要合併的兩個資料來源，不屬於同一個資料庫伺服器，甚至不是資料庫來源呢?</i></b></p>


</p>
<p>


</p>
<p><b><i>這時 Merge join 就派上用場了。</i></b></p>
<p>


</p>
<p>


</p>
<p>Merge join 會合併<b>兩個步驟</b>傳遞的資料(包含資料庫來源、檔案來源等)，可選擇 INNER JOIN 或多種 OUTER JOIN。</p>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8A%E5%8D%8811.19.27.png?w=1170&#038;ssl=1" alt="Multiway merge join設定視窗 " style="aspect-ratio:2.909090909090909;width:475px;height:auto"><p></p>
<figcaption>Merge join流程示意圖 </figcaption>
</figure>
<p>


</p>
<p>


</p>
<p class="is-nowrap is-layout-flex wp-container-core-group-is-layout-1 wp-block-group-is-layout-flex">

</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-1 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8B%E5%8D%883.15.01.png?w=1170&#038;ssl=1" alt=""></figure>
<p>

</p>
<p>

</p>
<p>

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p>

</p>
<p>

</p>
<p>Merge join設定視窗</p>
<p>

</p>
<p>

</p>
<ul class="wp-block-list">

<p></p>
<li>設定需合併資料的步驟：<br>&nbsp; &nbsp; First step<br>&nbsp; &nbsp; Second step</li>
<p>

</p>
<p>

</p>
<li>選擇合併方式：<br>&nbsp; &nbsp; INNER, LEFT OUTER,<br>&nbsp; &nbsp; RIGHT OUTER, FULL OUTER</li>
<p>

</p>
<p>

</p>
<li>設定合併關聯鍵：<br>&nbsp; &nbsp; Keys for 1st step:<br>&nbsp; &nbsp; Keys for 2nd step:<br>&nbsp; &nbsp; (可用 Get key fields 快速加入)</li>
<p>

</p>
</ul>
<p>

</p>
<p>

</p>
<p>

</p>
<p>


</p>
<p>


</p>
<h3 class="wp-block-heading"><strong>Multiway merge join</strong></h3>
<p>


</p>
<p>


</p>
<p><strong><em>糟糕，Merge join 只能合併兩個資料來源，但是來源有三個，該怎麼辦</em></strong>？</p>
<p>


</p>
<p>


</p>
<p><strong><em>別急，這裡還有 Multiway merge join 可以幫忙。</em></strong></p>
<p>


</p>
<p>


</p>
<p>步驟 Multiway merge join 會合併<strong>兩個以上步驟</strong>傳遞的資料(包含資料庫來源、檔案來源等)，可選擇 INNER JOIN 或 </p>
<p>


</p>
<p>


</p>
<p>FULL OUTER JOIN。</p>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8A%E5%8D%8811.30.25.png?w=1170&#038;ssl=1" alt="Multiway merge join設定視窗 " style="aspect-ratio:2.909090909090909;width:541px;height:auto"><p></p>
<figcaption>Multiway merge join流程示意圖</figcaption>
</figure>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" height="352" width="1024" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8A%E5%8D%8811.34.00.png?resize=1024%2C352&#038;ssl=1" alt="Multiway merge join設定視窗 " style="aspect-ratio:2.909090909090909;width:549px;height:auto"><p></p>
<figcaption>Multiway merge join設定視窗</figcaption>
</figure>
<p>


</p>
<p>


</p>
<ul class="wp-block-list">

<p></p>
<li>設定輸入步驟：Input Step（n）<br>※ 欄位數量隨連結步驟而增減</li>
<p>

</p>
<p>

</p>
<li>設定合併關聯鍵：Join Keys<br>※ 必須點選 Select Keys 按鈕、開啟小視窗填寫關聯鍵名稱</li>
<p>

</p>
<p>

</p>
<li>選擇合併方式：Join Type: （INNER 或 FULL OUTER）</li>
<p>

</p>
</ul>
<p>


</p>
<p>


</p>
<h4 class="wp-block-heading"><strong>「常值膠帶」與「序列膠帶」</strong></h4>
<p>


</p>
<p>


</p>
<p><strong><em>看過標準的 join 步驟，可能有人會問：每次都要設定共通欄位，有沒有更便利的方法?</em></strong></p>
<p>


</p>
<p>


</p>
<p><strong><em>方法有，而且步驟連起來就可以。</em></strong></p>
<p>


</p>
<p>


</p>
<p>情境：兩股資料來源、資料<strong>欄位組成相同</strong></p>
<p>


</p>
<p>


</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-2 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8B%E5%8D%883.29.59-1.png?w=1170&#038;ssl=1" alt="" style="aspect-ratio:1.2594142259414225;width:425px;height:auto"></figure>
<p>

</p>
<p>

</p>
<p>

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p>

</p>
<p>

</p>
<ul class="wp-block-list">

<p></p>
<li>資料來源A (左側ABC字樣)</li>
<p>

</p>
<p>

</p>
<li>資料來源B (右側JKL字樣)</li>
<p>

</p>
<p>

</p>
<li>兩個來源都由欄位 name, score 組成</li>
<p>

</p>
</ul>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>預期結果：<br>合併資料、每列資料呈現所有資料來源欄位</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>


</p>
<p>


</p>
<p>「常值膠帶」：利用 Add constants 步驟追加<strong>固定常值</strong>，合併多股來源資料</p>
<p>


</p>
<p>


</p>
<p>※ 注意：資料合併順序受<strong>資料來源步驟建立順序</strong>影響，可後續追加 Sort rows 步驟重新排序</p>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" height="680" width="1024" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8A%E5%8D%8811.52.33.png?resize=1024%2C680&#038;ssl=1" alt="序列膠帶" style="aspect-ratio:1.5058823529411764;width:528px;height:auto"></figure>
<p>


</p>
<p>


</p>
<p>「序列膠帶」：利用 Add sequence 步驟<strong>追加固定序列</strong>，合併多股來源資料</p>
<p>


</p>
<p>


</p>
<p>※ 注意：資料合併順序受<strong>資料來源步驟建立順序</strong>影響，可後續追加 Sort rows 步驟重新排序</p>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" height="680" width="1024" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8A%E5%8D%8811.53.22.png?resize=1024%2C680&#038;ssl=1" alt="" style="aspect-ratio:1.5058823529411764;width:537px;height:auto"></figure>
<p>


</p>
<p>


<h2 class="wp-block-heading"><strong>無共通欄位情境處理</strong></h2>


</p>
<p>


<p><strong><em>看過前面的介紹，資料合併動作都在「有共通欄位」的前提下完成。如果有兩股以上、沒有共通欄位的資料載入 Pentaho，如何實現欄位合併？</em></strong><br><strong><em><br>那就自己製造共通欄位！</em></strong></p>


</p>
<p>


</p>
<h3 class="wp-block-heading"><strong>「常值雙面膠」：配合 join 一 對多合併</strong></h3>
<p>


</p>
<p>


</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-6 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p>情境：兩股資料來源、<strong>資料量不同</strong>、沒有共通欄位可以對照</p>
<p>

</p>
<p>

</p>
<p class="is-layout-constrained wp-block-group-is-layout-constrained">

</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-3 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8B%E5%8D%884.23.39.png?w=1170&#038;ssl=1" alt=""></figure>
<p>

</p>
<p>

</p>
<p>

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p>

</p>
<p>

</p>
<ul class="wp-block-list">

<p></p>
<li>資料來源A：欄位 group</li>
<p>

</p>
<p>

</p>
<li>資料來源B：欄位 name, score</li>
<p>

</p>
</ul>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-5 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-4 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8B%E5%8D%884.28.34.png?w=1170&#038;ssl=1" alt="" style="aspect-ratio:2.239130434782609;width:413px;height:auto"></figure>
<p>

</p>
<p>

</p>
<p>

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p>

</p>
<p>

</p>
<p>預期結果：合併資料、每列資料呈現所有資料來源欄位</p>
<p>

</p>
<p>

</p>
<ul class="wp-block-list">

<p></p>
<li>合併資料：欄位 group, name, score</li>
<p>

</p>
</ul>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>

</p>
<p>


</p>
<p>


</p>
<p>利用 Add constants 步驟添加相同內容欄位，配合 Merge join 步驟指定新欄位、完成合併</p>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" height="448" width="1024" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8A%E5%8D%8811.56.48.png?resize=1024%2C448&#038;ssl=1" alt="Add constants步驟添加相同內容欄位，配合Merge join步驟指定新欄位、完成合併 " style="aspect-ratio:2.2857142857142856;width:594px;height:auto"></figure>
<p>


</p>
<p>


</p>
<p>


</p>
<p>


</p>
<p>※ 如果來源超過兩項，可改用 Multiway merge join 步驟執行合併</p>
<p>


</p>
<p>


</p>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" height="583" width="1024" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8B%E5%8D%881.35.32.png?resize=1024%2C583&#038;ssl=1" alt="Multiway merge join" style="aspect-ratio:1.7564322469982847;width:607px;height:auto"></figure>
<p>


</p>
<p>


</p>
<h3 class="wp-block-heading"><strong>「序列雙面膠」：配合 join 多對多合併</strong></h3>
<p>


</p>
<p>


</p>
<p>情境：兩股資料來源、<strong>資料量相同</strong>、沒有共通欄位可以對照</p>
<p>


</p>
<p>


</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-7 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8B%E5%8D%884.08.01.png?w=1170&#038;ssl=1" alt=""></figure>
<p>

</p>
<p>

</p>
<p>

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p>

</p>
<p>

</p>
<ul class="wp-block-list">

<p></p>
<li>資料來源A (左)：欄位 group</li>
<p>

</p>
<p>

</p>
<li>資料來源B (右)：欄位 name, score</li>
<p>

</p>
</ul>
<p>

</p>
<p>

</p>
<p>


</p>
<p>


</p>
<p class="is-layout-flex wp-container-core-columns-is-layout-8 wp-block-columns-is-layout-flex">

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<figure><img data-recalc-dims="1" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8B%E5%8D%884.10.05-1.png?w=1170&#038;ssl=1" alt=""></figure>
<p>

</p>
<p>

</p>
<p>

</p>
<p class="is-layout-flow wp-block-column-is-layout-flow">

</p>
<p>預期結果：合併資料、每列資料呈現所有資料來源欄位</p>
<p>

</p>
<p>

</p>
<p>


</p>
<p>


</p>
<p>


</p>
<p>


</p>
<p>利用 Add sequence 步驟添加序列，配合 Merge join 步驟指定新欄位、完成合併</p>
<p>


</p>
<p>


</p>
<p>


</p>
<p>


</p>
<figure><img data-recalc-dims="1" height="482" width="1024" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-14-%E4%B8%8B%E5%8D%881.39.26.png?resize=1024%2C482&#038;ssl=1" alt="" style="aspect-ratio:2.12448132780083;width:598px;height:auto"></figure>
<p>


</p>
<p>


</p>
<p>


</p>
<p>


</p>
<p>※ 如果來源超過兩項，可改用 Multiway merge join 步驟執行合併</p>
<p>


</p>
<p>


<p></p>


</p>
<p>


<p class="has-text-align-center"></p>


</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">38517</post-id>	</item>
		<item>
		<title>Pentaho ETL 實作技巧：SQL 動態內容引用 Table input &#038; Execute SQL scripts</title>
		<link>https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/pentaho-etl-practices-table-input-and-output/</link>
		
		<dc:creator><![CDATA[Omni]]></dc:creator>
		<pubDate>Fri, 17 Nov 2023 10:09:34 +0000</pubDate>
				<category><![CDATA[Pentaho 技術專欄]]></category>
		<category><![CDATA[ETL]]></category>
		<category><![CDATA[Pentaho]]></category>
		<guid isPermaLink="false">https://www.omniwaresoft.com.tw/?p=38598</guid>

					<description><![CDATA[儘管 Table input 和 Execute SQL script 兩者都支援填寫 SQL 語句，但固定條件值的頻繁調整卻會降低 ETL 流程效率。為此，Pentaho 允許將 SQL 語句設定為「動態內容」，使流程轉為更靈活的函式結構，並在 SQL 查詢中引入「動態內容」，本文將對此做法進行詳細說明。]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="38598" class="elementor elementor-38598" data-elementor-post-type="post">
						<section data-particle_enable="false" data-particle-mobile-disabled="false" class="elementor-section elementor-top-section elementor-element elementor-element-51ac6536 elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="51ac6536" data-element_type="section">
						<div class="elementor-container elementor-column-gap-thegem"><div class="elementor-row">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-72dc5add" data-id="72dc5add" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-5d9dc496 flex-horizontal-align-default flex-horizontal-align-tablet-default flex-horizontal-align-mobile-default flex-vertical-align-default flex-vertical-align-tablet-default flex-vertical-align-mobile-default elementor-widget elementor-widget-text-editor" data-id="5d9dc496" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
												<div class="elementor-text-editor elementor-clearfix">
						<p><span style="text-transform: initial;">對於使用 Pentaho（或者類似產品 Kettle / Hop）這類 ETL 工具的開發人員來說，總有一些藏在角落、鮮為人知的方便功能。</span></p>
<p><span style="text-transform: initial;">在此講解有關 Pentaho 流程中，使用 Table input 與 Execute SQL scripts 兩種流程步驟的動態內容引用。</span></p>
<p><strong style="color: #3c3950; font-size: 30px; letter-spacing: 0.05em; text-transform: capitalize;">什麼是動態內容?</strong></p>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph {"align":"left"} --></p>
<p data-start="32" data-end="231">在 Pentaho 的各項流程步驟中，雖然 Table Input 與 Execute SQL Script 都可以直接填寫 SQL 語句，但固定條件值往往需要 ETL 流程設計者手動調整，這不僅降低效率，也增加出錯風險。若將 SQL 語句設定為「動態內容」，流程就能轉換為函式（function）結構，取代人工調整，並可透過使用者輸入或上游步驟查詢的資料獲得結果，大幅提升效率並減少錯誤發生！</p>
<p> </p>
<p data-start="233" data-end="308">由於不同資料庫產品的特性各異，Pentaho 提供了兩種方式將「動態內容」引入 SQL 查詢中。本文將以變數與參數來區分，並詳細說明各種引入方法。</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading --></p>
<h2><strong>定義「變數」與「參數」</strong></h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>在進入操作說明之前，為避免 Pentaho 介面上的名詞造成混淆，本文先釐清在 Pentaho 應用範圍內，「變數」與「參數」的差異：</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3><strong>變數 (variables)</strong></h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>通過流程步驟 Set variables 與 Get variables 載入的 SQL 動態內容，稱為「變數」。</p>
<p>「變數」可以在 Transformation / Job 流程的屬性 (Properties) 設定中，利用「Parameters」區域進行定義（如欄位名稱、預設值、欄位說明等）</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38601,"width":"344px","height":"auto","aspectRatio":"1.5566502463054188","sizeSlug":"full","linkDestination":"none"} --></p>
<figure><img data-recalc-dims="1" style="aspect-ratio: 1.5566502463054188; width: 344px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-16-%E4%B8%8B%E5%8D%885.03.28.png?w=1170&#038;ssl=1" alt="properties" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph {"align":"center"} --></p>
<p>※在畫面空白處可用滑鼠右鍵（或左鍵連續點擊）點選「Properties…」選項進入屬性設定（上圖紅框處），選擇「Parameters」區域即可定義「變數」（下圖）</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38602,"width":"496px","height":"auto","aspectRatio":"3.9844357976653697","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="257" width="1024" style="aspect-ratio: 3.9844357976653697; width: 496px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-16-%E4%B8%8B%E5%8D%885.08.21.png?resize=1024%2C257&#038;ssl=1" alt="transformation properties" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>「變數」的利用方法有二：</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":true} --></p>
<ol>
<li style="list-style-type: none;">
<ol><!-- wp:list-item --></ol>
</li>
</ol>
<ol>
<li style="list-style-type: none;">
<ol>
<li>呼叫 Transformation / Job 流程時指定內容</li>
</ol>
</li>
</ol>
<p><!-- /wp:list-item --></p>
<p><!-- wp:list-item --></p>
<ol>
<li style="list-style-type: none;">
<ol>
<li>利用流程步驟 Set variables 與 Get variables 指定流程中產生的目標內容</li>
</ol>
</li>
</ol>
<p><!-- /wp:list-item --></p>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>受到 Pentaho 當中 Transformation 流程特性<a href="https://stackoverflow.com/a/72445978" target="_blank" rel="noopener">[1]</a>影響，所有步驟「幾乎同時執行」，當一個 Transformation 設定「變數」後，該流程無法使用「變數」，必須透過 Job 流程傳送到另一個 Transformation，才能利用先前設定的「變數」。</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38603,"width":"431px","height":"auto","aspectRatio":"2.1777777777777776","sizeSlug":"full","linkDestination":"none"} --></p>
<figure><img data-recalc-dims="1" style="aspect-ratio: 2.1777777777777776; width: 431px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-16-%E4%B8%8B%E5%8D%885.28.44.png?w=1170&#038;ssl=1" alt="motice" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph {"align":"center"} --></p>
<p>※Set variables 步驟確認離開時，會出現提示：同一 Transformation 內無法使用新增「變數」</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3><strong>參數（parameters</strong>）</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>通過 Transformation 流程中繼資料欄位 (fields) 取用的 SQL 動態內容，稱為「參數」；「參數」出現在 Spoon 執行流程後、執行結果（Execution Results）的 Preview data 頁籤：</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38604,"width":"495px","height":"auto","aspectRatio":"1.5398496240601505","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="665" width="1024" style="aspect-ratio: 1.5398496240601505; width: 495px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-16-%E4%B8%8B%E5%8D%885.55.54.png?resize=1024%2C665&#038;ssl=1" alt="transformation parameter" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph {"align":"center"} --></p>
<p>※ （圖A）Pentaho 流程執行後，下方的執行結果可選 Preview data 查看不同步驟的「參數」呈現</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>和「變數」不同的是，「參數」可以直接在同一 Transformation 當中進行利用，由於「參數」本質仍是 ETL 流程的中繼資料，因此經過其它步驟，內容仍會因為篩選而變化（如 Select values、Filter rows）或者遺失（如 Table input）。</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38606,"width":"500px","height":"auto","aspectRatio":"1.5398496240601505","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="665" width="1024" style="aspect-ratio: 1.5398496240601505; width: 500px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-16-%E4%B8%8B%E5%8D%885.58.50-1.png?resize=1024%2C665&#038;ssl=1" alt="execution results" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph {"align":"center"} --></p>
<p>※ （圖B） 相對於圖 A，「參數」經過流程步驟 Select values，欄位可能減少或更換名稱</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38607,"width":"462px","height":"auto","aspectRatio":"1.5036710719530102","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="681" width="1024" style="aspect-ratio: 1.5036710719530102; width: 462px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-16-%E4%B8%8B%E5%8D%886.15.46.png?resize=1024%2C681&#038;ssl=1" alt="Filter row" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph {"align":"center"} --></p>
<p> （圖C） 相對於圖 A，「參數」經過流程步驟 Filter rows，受到篩選條件影響、產生資料列數量變化</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38608,"width":"464px","height":"auto","aspectRatio":"1.532934131736527","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="668" width="1024" style="aspect-ratio: 1.532934131736527; width: 464px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-16-%E4%B8%8B%E5%8D%886.18.03.png?resize=1024%2C668&#038;ssl=1" alt="execution results" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph {"align":"center"} --></p>
<p>※ （圖D）相對於圖 A，「參數」經過流程步驟 Execute SQL scripts，由於該項步驟不輸出內容，故不會變化</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38611,"width":"450px","height":"auto","aspectRatio":"1.5375375375375375","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="666" width="1024" style="aspect-ratio: 1.5375375375375375; width: 450px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8A%E5%8D%889.49.24.png?resize=1024%2C666&#038;ssl=1" alt="execution results" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph {"align":"center"} --></p>
<p>※  （圖E）相對於圖 A，「參數」經過流程步驟 Table input，由於該項步驟必定輸出內容，故內容被步驟輸出替代</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3><strong>「變數」文字替代</strong></h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>變數文字替代（Variable substitution）需要在 SQL 語法中填寫 ${variable} 標記<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Variables" target="_blank" rel="noopener">[2]</a>，括號內名稱自訂，以流程屬性定義為主，且字串內容必須追加單引號；之所以叫做「文字替代」，是因為動態內容會直接替代變數標記，才送出語法執行。</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"align":"center","id":38612,"width":"493px","height":"auto","aspectRatio":"1.2864321608040201","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="796" width="1024" style="aspect-ratio: 1.2864321608040201; width: 493px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8A%E5%8D%889.51.30.png?resize=1024%2C796&#038;ssl=1" alt="table input" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:list --></p>
<ul>
<li style="list-style-type: none;">
<ul><!-- wp:list-item --></ul>
</li>
</ul>
<ul>
<li style="list-style-type: none;">
<ul>
<li>勾選選項「Replace variables in script?」啟用變數文字替代<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Table_Input" target="_blank" rel="noopener">[3]</a></li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- wp:list-item --></p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>SQL 語法動態內容位置填寫「${variable}」標記（字串內容必須添加單引號，數值、布林值除外）</li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- /wp:list --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4><strong>Execute SQL script 變數文字替代方法</strong></h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:image {"align":"center","id":38613,"width":"517px","height":"auto","aspectRatio":"1.3247089262613196","sizeSlug":"large","linkDestination":"none"} --></p>
<figure><img loading="lazy" data-recalc-dims="1" height="773" width="1024" style="aspect-ratio: 1.3247089262613196; width: 517px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8A%E5%8D%889.54.26.png?resize=1024%2C773&#038;ssl=1" alt="execute SQL script" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:list --></p>
<ul>
<li style="list-style-type: none;">
<ul><!-- wp:list-item --></ul>
</li>
</ul>
<ul>
<li style="list-style-type: none;">
<ul>
<li>勾選選項「Variable substitution」啟用變數文字替代<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Execute_SQL_Script" target="_blank" rel="noopener">[4]</a></li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- wp:list-item --></p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>SQL語法動態內容位置填寫「${variable}」標記（字串內容必須添加單引號，數值、布林值除外）</li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- /wp:list --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3><strong>「參數」綁定</strong></h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>相對於變數文字替代，參數綁定（Bind parameters）只要在SQL語法中填寫「?」標記即可，不過需要「參數」的數量、順序，必須與語法結構保持一致。</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>以效能角度比較，變數文字替代產生的SQL語法，儘管架構相同，資料庫掃描語法時，卻因為動態內容「一字之差」，視為不同的查詢，每次查詢便重做執行計畫，屬於美中不足；</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>參數綁定產生的 SQL 語法不同，語法、動態內容分開送出，資料庫掃描後，即可套用首次掃描的執行計畫，才引入動態內容，大幅增進查詢效能。實際設計流程時，流程步驟 Table input 與 Execute SQL script 對「參數」的影響也有所不同：<br />前者會傳回查詢結果、替代「參數」欄位，後者則保持原樣，「參數」可以繼續利用<a href="https://stackoverflow.com/a/51297306" target="_blank" rel="noopener">[5]</a>。</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4><strong>Table input 參數綁定方法</strong></h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:image {"align":"center","id":38614,"width":"493px","height":"auto","aspectRatio":"1.2884615384615385","sizeSlug":"full","linkDestination":"none"} --></p>
<figure><img data-recalc-dims="1" style="aspect-ratio: 1.2884615384615385; width: 493px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8A%E5%8D%889.57.01.png?w=1170&#038;ssl=1" alt="Table input 綁定方法" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:list --></p>
<ul>
<li style="list-style-type: none;">
<ul><!-- wp:list-item --></ul>
</li>
</ul>
<ul>
<li style="list-style-type: none;">
<ul>
<li>屬性「Insert data from step」選擇流程上一步驟，啟用參數綁定<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Table_Input#Example" target="_blank" rel="noopener">[6]</a></li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- wp:list-item --></p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>勾選選項「Execute for each row?」確保動態內容通過「資料列逐一輸入」執行</li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- wp:list-item --></p>
<ul>
<li style="list-style-type: none;">
<ul>
<li>SQL語法動態內容位置填寫「?」標記即可<!-- wp:list -->
<ul>
<li style="list-style-type: none;">
<ul><!-- wp:list-item --></ul>
</li>
</ul>
<ul>
<li style="list-style-type: none;">
<ul>
<li>注意：由於參數綁定對數量、順序要求，上一步驟應使用Select values進行欄位排序、複製與重新命名</li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- /wp:list --></p>
</li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- /wp:list --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4><strong>Execute SQL script參數綁定方法</strong></h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:image {"align":"center","id":38615,"width":"472px","height":"auto","aspectRatio":"1.3361823361823362","sizeSlug":"full","linkDestination":"none"} --></p>
<figure><img data-recalc-dims="1" style="aspect-ratio: 1.3361823361823362; width: 472px; height: auto;" src="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2023/11/%E6%88%AA%E5%9C%96-2023-11-17-%E4%B8%8A%E5%8D%889.59.11.png?w=1170&#038;ssl=1" alt="execute SQL script" /></figure>
<p><!-- /wp:image --></p>
<p><!-- wp:list --></p>
<ul>
<li style="list-style-type: none;">
<ul><!-- wp:list-item --></ul>
</li>
</ul>
<ul>
<li style="list-style-type: none;">
<ul>
<li>先後勾選選項「Execute for each row?」以及「Bind parameters?」，啟用參數綁定<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Execute_SQL_Script" target="_blank" rel="noopener">[7]</a>（必須勾選「Execute for each row?」，選項「Bind parameters?」才能操作）</li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- /wp:list --></p>
<p><!-- wp:list --></p>
<ul>
<li style="list-style-type: none;">
<ul><!-- wp:list-item --></ul>
</li>
</ul>
<ul>
<li style="list-style-type: none;">
<ul>
<li>SQL語法動態內容位置填寫 ? 標記即可，參數可在左下角”Parameters」表格填寫（須按照標記順序；欄位可重複填寫）</li>
</ul>
</li>
</ul>
<p><!-- /wp:list-item --></p>
<p><!-- /wp:list --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3><strong>「參數」綁定SQL語法的限制</strong></h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>利用參數綁定執行 SQL 腳本時，可能遭遇下面的狀況：</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4><strong>腳本存在多段分號間隔語法</strong></h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>儘管參數綁定可以增進查詢效能，但不代表可以處理結構複雜的腳本。<br />如果有一段SQL腳本具有下面的結構：</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p>“</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>UPDATE… SET… WHERE &lt;columnA&gt; = </em><strong><em>?</em></strong><em> AND &lt;columnB&gt; = </em><strong><em>?</em></strong><em> ;</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>SELECT… FROM… WHERE &lt;columnA&gt; = </em><strong><em>?</em></strong><em> AND &lt;columnB&gt; = </em><strong><em>?</em></strong><em> ;</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p>“</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>按照前述解說，參數可能按照「ABAB」格式做綁定、順利完成作業，然而實際執行流程後，Pentaho 可能會回覆異常訊息：</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>“</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>&lt;data type&gt;：Unable to set value on prepared statement on index 4.</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>欄位索引超過許可範圍：3，欄位數：2。</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>“</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>或者</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>“</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>Error setting value #1 &lt;data type&gt; on prepared statement</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>欄位索引超過許可範圍：1，欄位數：0。</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph {"textColor":"vivid-red"} --></p>
<p><em>“</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>這是因為 Execute SQL scripts 步驟只會執行分號間隔最後一段語法，如果<strong>指派參數數量超過最後一段語法指定數量</strong>，或者<strong>最後一段語法沒有指定參數</strong>，就會出現上述異常訊息。</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4><strong>腳本需要利用暫存表 (temp table)</strong></h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>腳本內容在 Pentaho 執行時，可能遭遇效能較差，需要利用暫存表的情形。需要注意的是，前述 Transformation 流程特性當中，不只所有步驟「幾乎同時執行」，而且是各個步驟「執行完畢即釋放資源」。</p>
<p>因此，不僅建置暫存表、查詢暫存表的語法無法寫在同一步驟，即使分開執行，由於ETL步驟的工作階段(session)完成後馬上結束，暫存表建立完成的當下，也會馬上被消滅<a href="https://stackoverflow.com/a/22183458" target="_blank" rel="noopener">[8]</a>。</p>
<p>推薦閲讀：<a href="https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/pentaho-merge-join-and-mulitiway-merge-join-practices/" target="_blank" rel="noopener">Pentaho ETL 實作技巧：無共通欄位資料合併 Merge join &amp; Multiway merge join</a></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading --></p>
<h2><strong>參考資料</strong></h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>[1] StackOverflow問答 <a href="https://stackoverflow.com/a/72445978" target="_blank" rel="noopener">&#8220;Am I using switch/case wrong here to control?&#8221;</a>，2022-05-30</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>[2] Pentaho官方文件 <a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Variables" target="_blank" rel="noopener">&#8220;Variables &#8211; Hitachi Vantara Lumada and Pentaho Documentation&#8221;</a>，2021-10-08</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>[3] Pentaho官方文件 <a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Table_Input" target="_blank" rel="noopener">&#8220;Table Input &#8211; Hitachi Vantara Lumada and Pentaho Documentation&#8221;</a>，<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Table_Input#Options" target="_blank" rel="noopener">Options段落</a>，2021-10-08</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>[4] Pentaho官方文件 <a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Execute_SQL_Script" target="_blank" rel="noopener">&#8220;Execute SQL Script &#8211; Hitachi Vantara Lumada and Pentaho Documentation&#8221;</a>，<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Execute_SQL_Script#Options">Options段落</a>，2021-10-08</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>[5] StackOverflow問答 <a href="https://stackoverflow.com/a/51297306" target="_blank" rel="noopener">&#8220;Pentaho Transformation &#8220;Execute SQL Statements&#8221; vs &#8220;Table Input&#8221; step&#8221;</a>，2018-07-12</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>[6] 同[3]，<a href="https://help.hitachivantara.com/Documentation/Pentaho/Data_Integration_and_Analytics/8.3/Products/Table_Input#Example" target="_blank" rel="noopener">Example段落</a></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>[7] 同[4]</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>[8] StackOverflow問答 <a href="https://stackoverflow.com/a/22183458" target="_blank" rel="noopener">&#8220;How to create a Temporary Table using (Select * into ##temp from table) syntax(For MS SQL) using Pentaho data integration&#8221;</a>，2014-03-04</p>
<hr />
<p><!-- /wp:paragraph --></p>							</div>
										</div>
				</div>
					</div>
		</div>
					</div></div>
		</section>
				<section data-particle_enable="false" data-particle-mobile-disabled="false" class="elementor-section elementor-top-section elementor-element elementor-element-8e4e1ab elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="8e4e1ab" data-element_type="section">
						<div class="elementor-container elementor-column-gap-thegem"><div class="elementor-row">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-674c0ee" data-id="674c0ee" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-9bd21b5 flex-horizontal-align-default flex-horizontal-align-tablet-default flex-horizontal-align-mobile-default flex-vertical-align-default flex-vertical-align-tablet-default flex-vertical-align-mobile-default elementor-widget elementor-widget-html" data-id="9bd21b5" data-element_type="widget" data-widget_type="html.default">
				<div class="elementor-widget-container">
					<div style="text-align: left;">加入歐立威 LINE 好友，了解更多產品資訊<BR><BR>
  <a href="https://lin.ee/VCvhQSK" style="display: inline-block;" target="_blank"> 
    <img data-recalc-dims="1" width="1170" src="https://i0.wp.com/scdn.line-apps.com/n/line_add_friends/btn/zh-Hant.png?fit=1170%2C36&#038;ssl=1" alt="加入好友" height="36" border="0">
  </a>
</div>				</div>
				</div>
					</div>
		</div>
					</div></div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">38598</post-id>	</item>
		<item>
		<title>Pentaho Community Edition</title>
		<link>https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/pentaho-community-edition/</link>
		
		<dc:creator><![CDATA[Omni]]></dc:creator>
		<pubDate>Thu, 01 Feb 2018 08:38:01 +0000</pubDate>
				<category><![CDATA[Pentaho 技術專欄]]></category>
		<category><![CDATA[技術專欄]]></category>
		<category><![CDATA[Pentaho]]></category>
		<category><![CDATA[Pentaho Community Edition]]></category>
		<guid isPermaLink="false">https://goodpoint-studio.com/?p=12918</guid>

					<description><![CDATA[Pentaho Community Ed...]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="12918" class="elementor elementor-12918" data-elementor-post-type="post">
						<section data-particle_enable="false" data-particle-mobile-disabled="false" class="elementor-section elementor-top-section elementor-element elementor-element-65e8ed6a elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="65e8ed6a" data-element_type="section">
						<div class="elementor-container elementor-column-gap-thegem"><div class="elementor-row">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4582a7ff" data-id="4582a7ff" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-4ccfae4a flex-horizontal-align-default flex-horizontal-align-tablet-default flex-horizontal-align-mobile-default flex-vertical-align-default flex-vertical-align-tablet-default flex-vertical-align-mobile-default elementor-widget elementor-widget-text-editor" data-id="4ccfae4a" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
												<div class="elementor-text-editor elementor-clearfix">
						<p></p>
<p>Pentaho Community Edition 為開源商業智慧軟體，旨在提供用戶資料分析流程整合服務，減少資料從各種來源萃取-轉換-載入 (Extract-Transform-Load, ETL) 到目標儲存設備，以及進一步資料探勘與報表呈現，所需的時間與人力。</p>
<p></p>
<p></p>
<p><br />以上所提的服務與對應的專案套件整理如下：</p>
<p></p>
<p></p>
<ol class="wp-block-list">
<li>資料ETL (Kettle or Pentaho Data Integration, PDI)</li>
<li>資料即時分析 (Mondrian)</li>
<li>資料報表呈現 (Reporting)</li>
<li>資料探勘 (WEKA)</li>
<li>Plugin 製作 (Sparkl)</li>
</ol>
<p></p>
<p></p>
<p></p>
<p></p>
<p>本操作說明手冊主要是針對 <strong>Kettle</strong> 進行講解，也就是 Pentaho 所提供的ETL工具。說明如何透過此工具介接不同資料源，進行所需的資料轉換，最後匯出到目標儲存設備。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<h2 class="wp-block-heading">下載與安裝 Kettle</h2>
<p></p>
<p></p>
<p></p>
<p></p>
<p>進入 Kettle 介紹網頁，前往 Download Section 下載，下載檔案在作業系統都可使用。<br />下載並解壓縮後，解壓縮後的檔案無需另外的安裝程序，但執行前須確認是否有安裝 Java，若無 Kettle 會無法開啟。<br />雖然 Kettle 在所有作業系統都可使用，但會因為作業系統使啟動方式不同，故下面分別對 Mac/Windows/Linux 說明啟動方式。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<ol class="wp-block-list">
<li>Mac用戶：點擊 Data Integration.app 檔案開啟 Kettle</li>
<li>Windows用戶：點擊sh 檔案開啟 Kettle</li>
<li>Linux用戶：進入 Terminal 中，前往 Kettle 的路徑，並鍵入 sh spoon.sh 開啟 Kettle </li>
</ol>
<p></p>
<p></p>
<p></p>
<p></p>
<h2 class="wp-block-heading">基本概念</h2>
<p></p>
<p></p>
<p></p>
<p></p>
<p>Kettle 的ETL程序主要可靠拖曳達成，其介面如下圖所示。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter is-resized"><img loading="lazy" data-recalc-dims="1" class="wp-image-12921" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition1-300x96.png?resize=363%2C116" alt="Pentaho Community Edition1" width="363" height="116" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition1.png?resize=300%2C96&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition1.png?resize=1024%2C327&amp;ssl=1 1024w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition1.png?resize=768%2C245&amp;ssl=1 768w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition1.png?resize=1536%2C490&amp;ssl=1 1536w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition1.png?w=1636&amp;ssl=1 1636w" sizes="(max-width: 363px) 100vw, 363px" /></figure>
<p></p>
<p></p>
<p></p>
<p></p>
<p>可看到左側有Transformations 與 Jobs、Design 與 View。左側為流程設計區域。<br />Transformations 與 Jobs 的差別如下:</p>
<p></p>
<p></p>
<ul class="wp-block-list">
<li>Transformations：控制資料從資料源的轉換與搬動。且在 Transformations 中的步驟可是平行執行。</li>
<li>Jobs：控制整體 ETL 流程，通常包含多個 Transformations。且在 Jobs 中的步驟是循序執行。</li>
</ul>
<p></p>
<p></p>
<p></p>
<p></p>
<p>Design 與 View 的差別如下:</p>
<p></p>
<p></p>
<ul class="wp-block-list">
<li>Design：包含可設定的步驟 (Step)。</li>
<li>View：包含目前設定 Transformation 或 Job 的步驟與資料庫連線資訊。</li>
</ul>
<p></p>
<p></p>
<p></p>
<p></p>
<h2 class="wp-block-heading">建立第一個轉換與工作流程</h2>
<p></p>
<p></p>
<p>接下來就開始試著建立第一個 Transformation 與 Job 。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<h2 class="wp-block-heading">第一個轉換</h2>
<p></p>
<p></p>
<p>在第一個 Transformation 中，我們要在 Kettle 中產生資料，並驗證資料，最後在加入序列碼 (Sequence)。<br />首先，點上方功能列的 File，再點擊 New，選擇 Transformation，以新增一個新的 Transformation，如下圖所示。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter is-resized"><img loading="lazy" data-recalc-dims="1" class="wp-image-12920" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition2-300x46.png?resize=387%2C59" alt="Pentaho Community Edition2" width="387" height="59" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition2.png?resize=300%2C46&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition2.png?resize=1024%2C156&amp;ssl=1 1024w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition2.png?resize=768%2C117&amp;ssl=1 768w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition2.png?w=1244&amp;ssl=1 1244w" sizes="(max-width: 387px) 100vw, 387px" /></figure>
<p></p>
<p></p>
<p><br />接下來，在右方的 Design中，拖曳 Input中的 Generate Rows 圖示到設計區域，結果如下圖所示。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img loading="lazy" data-recalc-dims="1" height="202" width="300" class="wp-image-12919" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition3-300x202.png?resize=300%2C202" alt="Pentaho Community Edition3" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition3.png?resize=300%2C202&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition3.png?resize=768%2C516&amp;ssl=1 768w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition3.png?w=842&amp;ssl=1 842w" sizes="(max-width: 300px) 100vw, 300px" /></figure>
<p></p>
<p></p>
<p><br /><br /></p>
<p></p>
<p></p>
<p>對於設計區域的步驟點擊左鍵後，可看到四個按鈕。最左邊的圖示可設定步驟的前一步，最右邊的圖示可設定步驟的下一步。第二個圖示是編輯步驟 (Edit Step)。第三個圖示是其他可對此步驟的操作。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p><br /><br />首先編輯 Generate Rows，設定要產生的資料型態與格式。Limit為欲產生的資料筆數。點擊 Fields中的空白欄位後，可建立變數名稱、型態、欲產生值與其他格式。例子如下圖所示，注意日期格式。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img loading="lazy" data-recalc-dims="1" height="140" width="300" class="wp-image-12927" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition5-300x140.png?resize=300%2C140" alt="Pentaho Community Edition5" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition5.png?resize=300%2C140&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition5.png?resize=1024%2C479&amp;ssl=1 1024w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition5.png?resize=768%2C359&amp;ssl=1 768w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition5.png?resize=1536%2C718&amp;ssl=1 1536w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition5.png?w=1566&amp;ssl=1 1566w" sizes="(max-width: 300px) 100vw, 300px" /></figure>
<p></p>
<p></p>
<p><br /><br />接下來，加入 Checksum 資料驗證步驟。在 Design，拖曳在 Transformation 中的 Add a checksum 的圖示到設計區域。將資料來源設定為 Generate Rows。</p>
<p></p>
<p></p>
<p><br />編輯此步驟，設定範例如下圖。其中 Get Field 可直接全選前步驟的欄位。並設定 Result field ，也就是欄位的名稱。 Compatibility Mode 是使與較舊版本相容，可見 <a href="http://wiki.pentaho.com/display/EAI/Add+a+checksum" target="_blank" rel="noopener">說明</a>。最後點擊 Help 旁的空白部分，以完成設定 (介面無顯示，應為 Bug)。</p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img loading="lazy" data-recalc-dims="1" height="276" width="300" class="wp-image-12926" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition6-300x276.png?resize=300%2C276" alt="Pentaho Community Edition" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition6.png?resize=300%2C276&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition6.png?w=728&amp;ssl=1 728w" sizes="(max-width: 300px) 100vw, 300px" /></figure>
<p></p>
<p></p>
<p><br /><br />最後，加入 Add sequence 新增序列號。在右方的 Design中，拖曳在 Transformation 中的 Add sequence 圖示到設計區域。設定資料來源為 Add a checksum，編輯此步驟，主要設定 Name of value (欄位名稱) 即可。<br />以上步驟都設定好後，就可以點選執行，如下圖所示。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img loading="lazy" data-recalc-dims="1" height="97" width="300" class="wp-image-12925" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition7-300x97.png?resize=300%2C97" alt="Pentaho Community Edition" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition7.png?resize=300%2C97&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition7.png?w=688&amp;ssl=1 688w" sizes="(max-width: 300px) 100vw, 300px" /></figure>
<p></p>
<p></p>
<p><br /><br />若無設定錯誤，點擊 Add sequence 後，下方的 Execution Results中的 Preview data應如下圖所示。最後將此 Transformation 另存新檔，以利設定下面的 Job。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img loading="lazy" data-recalc-dims="1" height="85" width="300" class="wp-image-12924" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition8-300x85.png?resize=300%2C85" alt="Pentaho Community Edition" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition8.png?resize=300%2C85&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition8.png?resize=1024%2C290&amp;ssl=1 1024w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition8.png?resize=768%2C218&amp;ssl=1 768w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition8.png?w=1370&amp;ssl=1 1370w" sizes="(max-width: 300px) 100vw, 300px" /></figure>
<p></p>
<p></p>
<h6 class="wp-block-heading"> </h6>
<p></p>
<p></p>
<h2 class="wp-block-heading">第一個工作流程</h2>
<p></p>
<p></p>
<p>在第一個 job 中，我們要將上面的 Transformation 再進一步包裝。首先新增一個新的 job。(File -&gt; New-&gt;job)<br />在 Design ，拖曳在 General 中的 START 到設計區域，編輯此步驟可以制定排程，如下圖所示。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img loading="lazy" data-recalc-dims="1" height="225" width="300" class="wp-image-12923" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition9-300x225.png?resize=300%2C225" alt="Pentaho Community Edition" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition9.png?resize=300%2C225&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition9.png?w=704&amp;ssl=1 704w" sizes="(max-width: 300px) 100vw, 300px" /></figure>
<p></p>
<p></p>
<p><br /><br />接著再拖曳在 General 中的 Transformation 到設計區域，並編輯此步驟，主要是 Transformation filename 要指定上面所設定的 Transformation 檔案的路徑。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img loading="lazy" data-recalc-dims="1" height="83" width="300" class="wp-image-12922" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/02/Pentaho-Community-Edition10-300x83.png?resize=300%2C83" alt="Pentaho Community Edition" srcset="https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition10.png?resize=300%2C83&amp;ssl=1 300w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition10.png?resize=1024%2C284&amp;ssl=1 1024w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition10.png?resize=768%2C213&amp;ssl=1 768w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition10.png?resize=1536%2C426&amp;ssl=1 1536w, https://i0.wp.com/www.omniwaresoft.com.tw/wp-content/uploads/2018/02/Pentaho-Community-Edition10.png?w=1960&amp;ssl=1 1960w" sizes="(max-width: 300px) 100vw, 300px" /></figure>
<p></p>
<p></p>
<p><br /><br />最後再拖曳 General 中的 SUCCESS 到設計區域，作為 Job 的結束點。點選執行，以執行此 Job。</p>
<p> </p>
<p>想了解更多資訊，<a href="https://www.omniwaresoft.com.tw/contact/" target="_blank" rel="noreferrer noopener">歡迎聯絡我們</a>，或是 <a href="https://page.line.me/870pcqyh?oat__id=4761625&amp;openQrModal=true" target="_blank" rel="noreferrer noopener">加入歐立威 Line 好友！</a></p>
<p></p>							</div>
										</div>
				</div>
					</div>
		</div>
					</div></div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">12918</post-id>	</item>
		<item>
		<title>PENTAHO DATA LINEAGE 與第三方工具之應用</title>
		<link>https://www.omniwaresoft.com.tw/techcolumn/pentaho-techcolumn/pentaho-data-lineage-and-third-party-tools-application/</link>
		
		<dc:creator><![CDATA[Omni]]></dc:creator>
		<pubDate>Thu, 25 Jan 2018 09:46:36 +0000</pubDate>
				<category><![CDATA[Pentaho 技術專欄]]></category>
		<category><![CDATA[技術專欄]]></category>
		<category><![CDATA[Pentaho]]></category>
		<guid isPermaLink="false">https://goodpoint-studio.com/?p=12900</guid>

					<description><![CDATA[June 10, 2016 by&#038;nbs...]]></description>
										<content:encoded><![CDATA[		<div data-elementor-type="wp-post" data-elementor-id="12900" class="elementor elementor-12900" data-elementor-post-type="post">
						<section data-particle_enable="false" data-particle-mobile-disabled="false" class="elementor-section elementor-top-section elementor-element elementor-element-504f6cde elementor-section-boxed elementor-section-height-default elementor-section-height-default" data-id="504f6cde" data-element_type="section">
						<div class="elementor-container elementor-column-gap-thegem"><div class="elementor-row">
					<div class="elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-45a60bed" data-id="45a60bed" data-element_type="column">
			<div class="elementor-widget-wrap elementor-element-populated">
						<div class="elementor-element elementor-element-437d7b1 flex-horizontal-align-default flex-horizontal-align-tablet-default flex-horizontal-align-mobile-default flex-vertical-align-default flex-vertical-align-tablet-default flex-vertical-align-mobile-default elementor-widget elementor-widget-text-editor" data-id="437d7b1" data-element_type="widget" data-widget_type="text-editor.default">
				<div class="elementor-widget-container">
												<div class="elementor-text-editor elementor-clearfix">
						<p></p>
<p class="has-text-align-right">June 10, 2016 by&nbsp;Jens Bleuel</p>
<p></p>
<p></p>
<p>本文將介紹如何使用PDI與第三方工具，如yED – 一個免費桌面應用程序用來生成圖表與查看特定數據。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<figure class="wp-block-image aligncenter"><img data-recalc-dims="1" src="https://i0.wp.com/104.154.39.219/wp-content/uploads/2018/01/pentaho%E8%88%87%E7%AC%AC%E4%B8%89%E6%96%B9%E6%87%89%E7%94%A8%E5%9C%96%E7%89%87.png?w=1170" alt="pentaho 與第三方應用圖片" class="wp-image-13906"></figure>
<p></p>
<p></p>
<p></p>
<p></p>
<p>經由PDI工具Pentaho為您提供視覺化數據操作並從中挖掘重要數據。從資料源到應用程式，使用第三方工具包括Meta Integration Technology (MITI) 與 yEd。</p>
<p></p>
<p></p>
<p></p>
<p></p>
<p><br>一旦Lineage啟用，PDI每次運行一個轉換作業時會生成一個GraphML文件。然後，您可以使用yED查看資料的樹狀圖。此功能可以幫助Data Lineage與Impact Analysis：</p>
<p></p>
<p></p>
<p></p>
<p></p>
<ul class="wp-block-list">
<li>Data Lineage: 提供發現數據流的一連串轉換與工作的關係</li>
<li>Impact Analysis: 了解資料的使用狀況與管理資料變化或評估&nbsp;</li>
</ul>
<p></p>
<p></p>
<p></p>
<p></p>
<h2 class="wp-block-heading" style="font-size:24px"><strong>為了更好地展示Data Lineage與Impact Analysis，這裡有一些範例：</strong></h2>
<p></p>
<p></p>
<h3 class="wp-block-heading" style="font-size:18px">As an ETL Developer:</h3>
<p></p>
<p></p>
<ul class="wp-block-list">
<li>資料源有變化，例如如其中的添加欄位、刪除欄位和重新命名，哪些部分會在ETL過程？</li>
<li>我需要從目標系統獲得更多信息，例如報告。什麼來源可以提供這些額外的信息？</li>
</ul>
<p></p>
<p></p>
<p></p>
<p></p>
<h3 class="wp-block-heading" style="font-size:18px">As a Report/Business User:</h3>
<p></p>
<p></p>
<ul class="wp-block-list">
<li>我的資料準確嗎？</li>
<li>我需要一個特定報告，其中包括從一個資料來源的特定信息。例如，是否有包括銷售和性別欄位的任何資料來源？是否有包括銷售額和郵政編碼欄位？</li>
</ul>
<p></p>
<p></p>
<p></p>
<p></p>
<h3 class="wp-block-heading" style="font-size:18px">As a Troubleshooting Operator:</h3>
<p></p>
<p></p>
<ul class="wp-block-list">
<li>報告中的數字是錯誤的。什麼樣的作業流程可以幫助我確定這些數字是從哪裡來的？</li>
<li>作業沒有成功完成。報告中的哪些表格會受到影響？</li>
</ul>
<p></p>
<p></p>
<p></p>
<p></p>
<h3 class="wp-block-heading" style="font-size:18px">As an Administrator:</h3>
<p></p>
<p></p>
<ul class="wp-block-list">
<li>我想要ETL過程當中使用的外資料來源、表格、欄位與資料庫的報告</li>
<li>為確保符合標準，我想驗證字串轉換是否符合規定</li>
<li>對於第三方工具，我想彈性匯出所蒐集到Data Lineage的信息</li>
</ul>
<p></p>							</div>
										</div>
				</div>
					</div>
		</div>
					</div></div>
		</section>
				</div>
		]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">12900</post-id>	</item>
	</channel>
</rss>
