

比對兩個表格 (可以是不同的資料庫) 的內容,指出差異處
source link: https://blog.gslin.org/archives/2022/06/26/10765/%e6%af%94%e5%b0%8d%e5%85%a9%e5%80%8b%e8%a1%a8%e6%a0%bc-%e5%8f%af%e4%bb%a5%e6%98%af%e4%b8%8d%e5%90%8c%e7%9a%84%e8%b3%87%e6%96%99%e5%ba%ab-%e7%9a%84%e5%85%a7%e5%ae%b9%ef%bc%8c%e6%8c%87%e5%87%ba/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

比對兩個表格 (可以是不同的資料庫) 的內容,指出差異處
前幾天看到的東西,不確定是不是在 Hacker News 上,反正在 tab 上幾天了... 但還是附上 Hacker News 的連結:「Show HN: Data Diff – compare tables of any size across databases」,專案的位置在 GitHub 上的 datafold/data-diff。
這是用 Python 寫的工具,安裝可以透過 pip 直接裝,所以也可以用 pipx 之類的工具獨立起來跑。
data-diff 會先拆成多個區塊,然後透過 checksum 的機制判斷兩邊的資料是否相同,不同的部份再取 bisection 分開下去找 (或是更多份,在 Technical Explanation 這個段落有寫到)。
在「Common use-cases」這段有提到幾個常見的使用情境,像是在自動化的環境下可以當作異常監控的工具:
Alerting and maintaining data integrity SLOs. You can create and monitor your SLO of e.g. 99.999% data integrity, and alert your team when data is missing.
另外在 troubleshooting 的情境下當然也很有幫助,可以先確認資料是否有問題,以及資料的哪邊出問題:
Debugging complex data pipelines. When data gets lost in pipelines that may span a half-dozen systems, without verifying each intermediate datastore it's extremely difficult to track down where a row got lost.
這個工具讓我想到 Percona Toolkit 裡面的 pt-table-checksum,不過 pt-table-checksum 只能處理 MySQL replication 的情境,data-diff 看起來通用多了:

目前完整測試過的是 MySQL、PostgreSQL 與 Snowflake,其他的有實做但還沒完整測試過。
看起來還在開發 (後面是商業公司 Datafold),但先寫下來,之後如果有用到的時候可以回頭看看進展...
Related
低 Downtime 將 4TB 的 PostgreSQL 9.6 資料庫升級到 13 的故事
前幾天在 Hacker News 首頁上看到的文章,講怎麼把一個 4TB 的 PostgreSQL 從 9.6 升級到 13 的故事:「How we upgraded our 4TB Postgres database (retool.com)」,原文在「How Retool upgraded our 4 TB main application PostgreSQL database」,翻了一下 LinkedIn,這篇文章的作者 Peter Johnston 在 Retool 掛的是 Security Software Engineer,另外他也有在 Hacker News 上的討論出現 (帳號是 mrbabbage),可以搜尋翻翻看他的回覆。 看完文章後發現方法的概念其實不難,主要是要找到對的工具來用。基本的想法是先生出一個 initial dump,然後架構 logical replication,接下來就是處理各種因為在 4TB data 這個…
April 20, 2022In "Computer"
在 PostgreSQL 上直接掛 ML extension
Hacker News 首頁上看到「Show HN: PostgresML, now with analytics and project management (postgresml.org)」這個專案,可以在 PostgreSQL 上面直接掛 extension 跑 ML algorithm:「PostgresML - an end-to-end machine learning solution」,從 GitHub 上可以看到大多數是 Python 的程式碼。 從 GitHub 頁面上面可以看到這個專案還在比較早期的階段: This project is currently a proof of concept. Some important features, which we are currently thinking about or working…
May 3, 2022In "Computer"
curl 的 command line 工具也要支援 JSON 格式了
Daniel Stenberg 在 curl 的 mailing list 上宣佈要支援 JSON 格式:「JSON support」,用法在「JSON awareness in the curl tool」在這邊可以看到,另外在 Hacker News 上的討論「The time might come when we add some JSON specific command line options (curl.se)」也可以翻翻。 討論裡面馬上有提到 HTTPie,這個套件基本上也算是標配了 (而且在各大 distribution 的 package 都有內建,直接裝就可以了),可以看到主要是處理 POST 輸入時的 JSON 部份 (在 Content-Type: application/json 的情境下),HTTP response 輸出的部份一般都還是用 jq…
January 22, 2022In "Computer"
Author Gea-Suan LinPosted on June 26, 2022Categories Computer, Database, MariaDB, Murmuring, MySQL, Network, PostgreSQL, SoftwareTags checksum, data, data-diff, datafold, diff, mlops, mysql, postgresql, snowflake
Leave a Reply
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Notify me of follow-up comments by email.
Notify me of new posts by email.
To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Learn More)
Post navigation
Recommend
-
8
使用 git diff 比對 UTF-16/BIG5 文字檔-黑暗執行緒 同事遇到的茶包。 git diff 時某文字檔被當成二進位檔案無法顯示差異,後來發現是 Unicode 編碼(UTF-16 LE with BOM/UCS-2 LE with BOM)造成,用以下範例重現: type a.txt 可檢視文字內...
-
6
多看兩個來源的整理:Ask Hacker News Weekly 與 Lobsters Daily 之前有訂起來的是「Hacker News Daily」,每天會整理 Hacker News 上的熱門...
-
8
C 語言的兩個笑話 (以及他的惡搞原理) Twitter 上看到兩則 C 語言的笑話: 第一個的 "-0.5"
-
10
Nic Lin's Blog喜歡在地上滾的工程師有個需求是,對一個集合算出所有的數據中,兩個欄位的時間相減,取全部平均花費時間。# == Schema Information # # Table nam...
-
7
晚上跟老同學出去吃飯之後去買 sim 卡(對方要出國),我們又想說好像沒試過 goshare 不然試看看啊,於是在捷運上開始弄 app:掃描文件跟臉部完成手續!不試還好,一試就變成現在這篇文章的內容啦 www 一開始的 goshare…不會騎 Gogoro 的兩...
-
9
這次 OpenSSL 的兩個 CVE 難得在 Hacker News 首頁上看到
-
5
JSON 資料差異比對小工具 2022-07-30 12:24 PM 4 1,448
-
1
這次 Amazon EFS 兩個新推出的項目:Elastic Throughput 與更低的 latency 這次 re:Invent 關於 Amaz...
-
8
SQL 索引欄位是否該包含 OR 比對項目? ...
-
3
使用 OpenAI Embedding 模型比對文字相似性-黑暗執行緒 在 ChatGPT 整合自有資料的 RAG 測試學到不少新東西,其中一個是 Embedding。(嵌入、內嵌,這些翻譯我都覺得怪,...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK