{"id":61437,"date":"2024-10-13T11:06:39","date_gmt":"2024-10-13T03:06:39","guid":{"rendered":"https:\/\/server.hk\/cnblog\/61437\/"},"modified":"2024-10-13T11:06:39","modified_gmt":"2024-10-13T03:06:39","slug":"flink-sql%e9%80%9a%e9%81%8ehudi-hms-catalog%e8%ae%80%e5%af%abhudi%e4%b8%a6%e5%90%8c%e6%ad%a5hive%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/61437\/","title":{"rendered":"Flink SQL\u901a\u904eHudi HMS Catalog\u8b80\u5bebHudi\u4e26\u540c\u6b65Hive\u8868"},"content":{"rendered":"<h1 id=\"flink-sql%e9%80%9a%e9%81%8ehudi-hms-catalog%e8%ae%80%e5%af%abhudi%e4%b8%a6%e5%90%8c%e6%ad%a5hive%e8%a1%a8-LWlTaHjTOa\">Flink SQL\u901a\u904eHudi HMS Catalog\u8b80\u5bebHudi\u4e26\u540c\u6b65Hive\u8868<\/h1>\n<p>\u5728\u5927\u6578\u64da\u8655\u7406\u7684\u9818\u57df\u4e2d\uff0cApache Flink\u548cApache Hudi\u7684\u7d50\u5408\u70ba\u6578\u64da\u7ba1\u7406\u63d0\u4f9b\u4e86\u5f37\u5927\u7684\u89e3\u6c7a\u65b9\u6848\u3002Flink SQL\u4f5c\u70ba\u4e00\u7a2e\u9ad8\u6548\u7684\u6d41\u8655\u7406\u5f15\u64ce\uff0c\u80fd\u5920\u901a\u904eHudi HMS Catalog\u4f86\u8b80\u53d6\u548c\u5beb\u5165Hudi\u6578\u64da\uff0c\u4e26\u4e14\u80fd\u5920\u8207Hive\u8868\u9032\u884c\u540c\u6b65\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u4e00\u904e\u7a0b\u7684\u5177\u9ad4\u6b65\u9a5f\u548c\u6280\u8853\u7d30\u7bc0\u3002<\/p>\n<h2 id=\"apache-hudi%e7%b0%a1%e4%bb%8b-LWlTaHjTOa\">Apache Hudi\u7c21\u4ecb<\/h2>\n<p>Apache Hudi\uff08Hadoop Upserts Deletes and Incrementals\uff09\u662f\u4e00\u500b\u958b\u6e90\u6578\u64da\u6e56\u89e3\u6c7a\u65b9\u6848\uff0c\u65e8\u5728\u652f\u6301\u9ad8\u6548\u7684\u6578\u64da\u5beb\u5165\u548c\u67e5\u8a62\u3002Hudi\u5141\u8a31\u7528\u6236\u9032\u884c\u589e\u91cf\u6578\u64da\u66f4\u65b0\u3001\u522a\u9664\u548c\u67e5\u8a62\uff0c\u4e26\u4e14\u80fd\u5920\u8207Apache Hive\u3001Apache Spark\u7b49\u751f\u614b\u7cfb\u7d71\u7121\u7e2b\u96c6\u6210\u3002Hudi\u7684\u4e3b\u8981\u7279\u6027\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u652f\u6301\u589e\u91cf\u5beb\u5165\u548c\u67e5\u8a62<\/li>\n<li>\u9ad8\u6548\u7684\u6578\u64da\u58d3\u7e2e\u548c\u5b58\u5132<\/li>\n<li>\u8207Hive\u7684\u517c\u5bb9\u6027<\/li>\n<\/ul>\n<h2 id=\"flink-sql%e8%88%87hudi%e7%9a%84%e9%9b%86%e6%88%90-LWlTaHjTOa\">Flink SQL\u8207Hudi\u7684\u96c6\u6210<\/h2>\n<p>Flink SQL\u63d0\u4f9b\u4e86\u4e00\u7a2e\u7c21\u55ae\u800c\u5f37\u5927\u7684\u65b9\u5f0f\u4f86\u8655\u7406\u6d41\u6578\u64da\u3002\u901a\u904eHudi HMS Catalog\uff0cFlink SQL\u53ef\u4ee5\u76f4\u63a5\u8b80\u53d6\u548c\u5beb\u5165Hudi\u8868\u3002\u9019\u4e00\u904e\u7a0b\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u5e7e\u500b\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"1-%e9%85%8d%e7%bd%aehudi-hms-catalog-LWlTaHjTOa\">1. \u914d\u7f6eHudi HMS Catalog<\/h3>\n<p>\u9996\u5148\uff0c\u9700\u8981\u5728Flink\u4e2d\u914d\u7f6eHudi HMS Catalog\u3002\u9019\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u65b9\u5f0f\u9032\u884c\uff1a<\/p>\n<pre><code>CREATE CATALOG hudi_catalog WITH (\n    'type' = 'hudi',\n    'default-database' = 'default',\n    'base-path' = 'hdfs:\/\/path\/to\/hudi\/table',\n    'hive-conf-dir' = '\/path\/to\/hive\/conf'\n);<\/code><\/pre>\n<p>\u9019\u6bb5\u4ee3\u78bc\u5275\u5efa\u4e86\u4e00\u500b\u540d\u70ba\u7684Catalog\uff0c\u4e26\u6307\u5b9a\u4e86Hudi\u8868\u7684\u57fa\u672c\u8def\u5f91\u548cHive\u914d\u7f6e\u76ee\u9304\u3002<\/p>\n<h3 id=\"2-%e5%89%b5%e5%bb%bahudi%e8%a1%a8-LWlTaHjTOa\">2. \u5275\u5efaHudi\u8868<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u53ef\u4ee5\u4f7f\u7528Flink SQL\u5275\u5efaHudi\u8868\u3002\u4ee5\u4e0b\u662f\u4e00\u500b\u793a\u4f8b\uff1a<\/p>\n<pre><code>CREATE TABLE hudi_table (\n    id INT,\n    name STRING,\n    age INT,\n    ts TIMESTAMP(3),\n    PRIMARY KEY (id) NOT ENFORCED\n) PARTITIONED BY (dt STRING)\nWITH (\n    'type' = 'hudi',\n    'table.type' = 'MERGE_ON_READ',\n    'hive.sync.enable' = 'true',\n    'hive.sync.database' = 'default',\n    'hive.sync.table' = 'hudi_table'\n);<\/code><\/pre>\n<p>\u9019\u6bb5\u4ee3\u78bc\u5275\u5efa\u4e86\u4e00\u500bHudi\u8868\uff0c\u4e26\u8a2d\u7f6e\u4e86Hive\u540c\u6b65\u7684\u76f8\u95dc\u53c3\u6578\u3002<\/p>\n<h3 id=\"3-%e5%af%ab%e5%85%a5%e6%95%b8%e6%93%9a%e5%88%b0hudi%e8%a1%a8-LWlTaHjTOa\">3. \u5beb\u5165\u6578\u64da\u5230Hudi\u8868<\/h3>\n<p>\u5beb\u5165\u6578\u64da\u5230Hudi\u8868\u53ef\u4ee5\u4f7f\u7528INSERT\u8a9e\u53e5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code>INSERT INTO hudi_table VALUES (1, 'Alice', 30, CURRENT_TIMESTAMP, '2023-10-01');<\/code><\/pre>\n<p>\u9019\u5c07\u4e00\u689d\u65b0\u6578\u64da\u63d2\u5165\u5230Hudi\u8868\u4e2d\u3002<\/p>\n<h3 id=\"4-%e5%be%9ehudi%e8%a1%a8%e8%ae%80%e5%8f%96%e6%95%b8%e6%93%9a-LWlTaHjTOa\">4. \u5f9eHudi\u8868\u8b80\u53d6\u6578\u64da<\/h3>\n<p>\u53ef\u4ee5\u4f7f\u7528SELECT\u8a9e\u53e5\u5f9eHudi\u8868\u4e2d\u8b80\u53d6\u6578\u64da\uff1a<\/p>\n<pre><code>SELECT * FROM hudi_table WHERE dt = '2023-10-01';<\/code><\/pre>\n<p>\u9019\u5c07\u8fd4\u56de\u6307\u5b9a\u65e5\u671f\u7684\u6240\u6709\u6578\u64da\u3002<\/p>\n<h2 id=\"%e5%90%8c%e6%ad%a5hive%e8%a1%a8-LWlTaHjTOa\">\u540c\u6b65Hive\u8868<\/h2>\n<p>Hudi\u7684\u53e6\u4e00\u500b\u91cd\u8981\u7279\u6027\u662f\u80fd\u5920\u8207Hive\u8868\u9032\u884c\u540c\u6b65\u3002\u901a\u904e\u8a2d\u7f6eHive\u540c\u6b65\u53c3\u6578\uff0cHudi\u53ef\u4ee5\u81ea\u52d5\u5c07\u6578\u64da\u540c\u6b65\u5230Hive\u4e2d\u3002\u9019\u6a23\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u5728Hive\u4e2d\u76f4\u63a5\u67e5\u8a62Hudi\u8868\u7684\u6578\u64da\uff0c\u7121\u9700\u984d\u5916\u7684\u6578\u64da\u79fb\u52d5\u6216\u8f49\u63db\u3002<\/p>\n<h3 id=\"hive%e5%90%8c%e6%ad%a5%e9%85%8d%e7%bd%ae-LWlTaHjTOa\">Hive\u540c\u6b65\u914d\u7f6e<\/h3>\n<p>\u5728\u5275\u5efaHudi\u8868\u6642\uff0c\u5df2\u7d93\u8a2d\u7f6e\u4e86Hive\u540c\u6b65\u7684\u76f8\u95dc\u53c3\u6578\u3002\u9019\u4e9b\u53c3\u6578\u5305\u62ec\uff1a<\/p>\n<ul>\n<li><code>hive.sync.enable<\/code>: \u555f\u7528Hive\u540c\u6b65<\/li>\n<li><code>hive.sync.database<\/code>: \u6307\u5b9aHive\u6578\u64da\u5eab<\/li>\n<li><code>hive.sync.table<\/code>: \u6307\u5b9aHive\u8868\u540d<\/li>\n<\/ul>\n<p>\u9019\u6a23\u914d\u7f6e\u5f8c\uff0cHudi\u5c07\u81ea\u52d5\u5c07\u6578\u64da\u540c\u6b65\u5230\u6307\u5b9a\u7684Hive\u8868\u4e2d\uff0c\u4f7f\u7528\u8005\u53ef\u4ee5\u901a\u904eHive\u9032\u884c\u67e5\u8a62\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-LWlTaHjTOa\">\u7e3d\u7d50<\/h2>\n<p>\u901a\u904eApache Flink SQL\u8207Hudi HMS Catalog\u7684\u96c6\u6210\uff0c\u7528\u6236\u53ef\u4ee5\u9ad8\u6548\u5730\u8b80\u53d6\u548c\u5beb\u5165Hudi\u6578\u64da\uff0c\u4e26\u4e14\u80fd\u5920\u8207Hive\u8868\u9032\u884c\u7121\u7e2b\u540c\u6b65\u3002\u9019\u4e00\u904e\u7a0b\u4e0d\u50c5\u7c21\u5316\u4e86\u6578\u64da\u7ba1\u7406\uff0c\u9084\u63d0\u9ad8\u4e86\u6578\u64da\u8655\u7406\u7684\u6548\u7387\u3002\u5c0d\u65bc\u9700\u8981\u8655\u7406\u5927\u91cf\u6578\u64da\u7684\u4f01\u696d\u4f86\u8aaa\uff0c\u9019\u7a2e\u6280\u8853\u7684\u61c9\u7528\u7121\u7591\u662f\u63d0\u5347\u696d\u52d9\u6548\u7387\u7684\u91cd\u8981\u624b\u6bb5\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bc<code><a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a><\/code>\u548c<code><a href=\"https:\/\/server.hk\">\u4e91\u670d\u52a1\u5668<\/a><\/code>\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use Flink SQL with Hudi HMS Catalog for reading and writing Hudi data while synchronizing with Hive tables efficiently.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-61437","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=61437"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61437\/revisions"}],"predecessor-version":[{"id":61438,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/61437\/revisions\/61438"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=61437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=61437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=61437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}