kettle轉換控件的使用與經驗分享

在練習時學習了子建老師的教程,感謝他的無私分享,貼上地址,以示尊重。https://edu.hellobi.com/course/37/play/lesson/669 


使用的kettle版本:7.1


下面是總結的內容


控件的使用:

1."值映射" 也可以擴充一列存放映射後的值;例如可以填寫“目標字段名” 擴充新列存放id的名稱。

2.拼接年和月的時候發現,中間有空格,如2017_ 1,解決辦法:Concat Fields的時候,Trim Type去掉兩端空格,不過可能還是不管用,那就設定一下Format 爲#,搞定。

3.優先使用"Microsoft Excel 輸出" 代替 "Excel輸出" 好處很多,如 時間格式無效;輸出的excel格式效果也不好;可以定義表頭名稱;Stream XSLX data提升性能等。

4.習慣用 "寫日誌" 來調試輸出變量和結果,挺好用的。

5.拖控件可以放到連接線上,然後會提示你"是否要把節點連接拆開嗎" 確定了就可以加在中間了。

6.不管是哪個元件,字段類型如果確定的話還是設定一下吧,否則讓kettle猜有時候會出格式轉換的錯誤,還有Format,沒有特殊格式就設定爲#,減少出問題的可能性,像第2條的情況。

7.“文本文件輸出” 內容TAB有一項叫 "快速存儲(無格式)" 勾上,速度會快很多而且文件體積也會小很多。


8“excel輸入”  選擇目錄多個文件時,通配符的設定,比如文件名列表是這樣的
e1.xlsx
e2.xlsx
e3.xlsx

那通配符應該是 e.*.xlsx 

想要學習更多通配符正則相關的知識可以參見  http://www.dataguru.cn/thread-506092-1-1.html 寫的真好,贊一個。



腳本執行轉換和工作文件:

1)Pan.bat/Pan.sh 用於執行轉換文件


參數:
  /rep            : 資源庫名稱
  /user           : 資源庫用戶名
  /pass           : 資源庫密碼
  /trans          : 要啓動的轉換名稱
  /dir            : 目錄(不要忘了前綴 /)
  /file           : 要啓動的文件名(轉換所在的 XML 文件)
  /level          : 日誌等級 (基本, 詳細, 調試, 行級, 錯誤, 沒有)
  /logfile        : 要寫入的日誌文件
  /listdir        : 列出資源庫裏的目錄
  /listtrans      : 列出指定目錄下的轉換
  /listrep        : 列出可用資源庫
  /exprep         : 將資源庫裏的所有對象導出到 XML 文件中
  /norep          : 不要將日誌寫到資源庫中
  /safemode       : 安全模式下運行: 有額外的檢查
  /version        : 顯示版本,校訂和構建日期
  /param          : Set a named parameter <NAME>=<VALUE>. For example -param:FOO=bar
  /listparam      : List information concerning the defined named parameters in the specified transformation.
  /metrics        : Gather metrics during execution
  /maxloglines    : The maximum number of log lines that are kept internally by Kettle. Set to 0 to keep all rows (default)
  /maxlogtimeout  : The maximum age (in minutes) of a log line while being kept internally by Kettle. Set to 0 to keep all rows indefinitely (default)
  
  
e.g 
F:\Program Files\pdi-ce-7.1.0.0-12\data-integration>Pan /file C:\Users\butin\Desktop\Kettle_Repository\PRACTICE\EXCEL_SINGLE_TEST.ktr
F:\Program Files\pdi-ce-7.1.0.0-12\data-integration>Pan /rep local_repository /user admin /pass admin /dir /practice /trans EXCEL_SINGLE_TEST


需要注意的是:
1.通過資源庫運行轉換時,/trans 後面跟的轉換的名字不要帶後綴.ktr
2.資源庫的數據庫連接需要設置編碼,否則中文會亂碼



  
2)Kitchen.bat/Kitchen.sh 用於執行JOB文件


參數:
  /rep            : Repository name
  /user           : Repository username
  /pass           : Repository password
  /job            : The name of the job to launch
  /dir            : The directory (dont forget the leading /)
  /file           : The filename (Job XML) to launch
  /level          : The logging level (Basic, Detailed, Debug, Rowlevel, Error, Minimal, Nothing)
  /logfile        : The logging file to write to
  /listdir        : List the directories in the repository
  /listjobs       : List the jobs in the specified directory
  /listrep        : List the available repositories
  /norep          : Do not log into the repository
  /version        : show the version, revision and build date
  /param          : Set a named parameter <NAME>=<VALUE>. For example -param:FILE=customers.csv
  /listparam      : List information concerning the defined parameters in the specified job.
  /export         : Exports all linked resources of the specified job. The argument is the name of a ZIP file.
  /custom         : Set a custom plugin specific option as a String value in the job using <NAME>=<Value>, for example: -custom:COLOR=Red
  /maxloglines    : The maximum number of log lines that are kept internally by Kettle. Set to 0 to keep all rows (default)
  /maxlogtimeout  : The maximum age (in minutes) of a log line while being kept internally by Kettle. Set to 0 to keep all rows indefinitely (default)


和Pan類似,看一下參數就知道了。


kettle數據庫連接配置

這個很重要,下面的參數配置上,性能飛起好嘛

“數據庫連接”-選項-命名參數,填上下面的參數,遇到一個問題,添加幾個參數後行不能編輯了,保存了又可以了,是不是kettle做了設定超過幾個就這樣,maybe

//解決亂碼問題
characterEncoding=utf8
//優化性能
useCompression=true
useCursorFetch=true
rewriteBatchedStatements=true
useServerPrepStmts=false





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章