{"id":1304,"date":"2023-03-19T08:06:15","date_gmt":"2023-03-19T00:06:15","guid":{"rendered":"http:\/\/viplao.com\/?p=1304"},"modified":"2023-03-19T08:06:16","modified_gmt":"2023-03-19T00:06:16","slug":"%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91","status":"publish","type":"post","link":"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/","title":{"rendered":"\u3010\u8fd0\u7ef4\u5de5\u5177\u3011Flink SQL \u4e8b\u4ef6\u65f6\u95f4\u4e0b\u6570\u636e\u4e71\u5e8f\u4e22\u6570\u8e29\u5751"},"content":{"rendered":"\n<p>\u672c\u6587\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/p>\n\n\n\n<ul>\n<li><strong>\u300c1.\u672c\u6b21\u8e29\u5751\u7684\u5e94\u7528\u573a\u666f\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300c2.\u5e94\u7528\u573a\u666f\u4e2d\u53d1\u751f\u7684\u4e22\u6570\u6545\u969c\u5206\u6790\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300c3.\u5f85\u4fee\u590d\u7684\u6545\u969c\u70b9\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300c4.\u4e22\u6570\u6545\u969c\u89e3\u51b3\u65b9\u6848\u53ca\u539f\u7406\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300c5.\u603b\u7ed3\u300d<\/strong><\/li>\n<\/ul>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_71 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">\u6587\u7ae0\u76ee\u5f55<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF\" title=\"\u5e94\u7528\u573a\u666f\">\u5e94\u7528\u573a\u666f<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E4%B8%A2%E6%95%B0%E6%95%85%E9%9A%9C%E5%88%86%E6%9E%90\" title=\"\u4e22\u6570\u6545\u969c\u5206\u6790\">\u4e22\u6570\u6545\u969c\u5206\u6790<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E5%BE%85%E4%BF%AE%E5%A4%8D%E7%9A%84%E6%95%85%E9%9A%9C%E7%82%B9\" title=\"\u5f85\u4fee\u590d\u7684\u6545\u969c\u70b9\">\u5f85\u4fee\u590d\u7684\u6545\u969c\u70b9<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E4%BB%A5%E5%8F%8A%E5%8E%9F%E7%90%86\" title=\"\u89e3\u51b3\u65b9\u6848\u4ee5\u53ca\u539f\u7406\">\u89e3\u51b3\u65b9\u6848\u4ee5\u53ca\u539f\u7406<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E4%B8%A2%E6%95%B0%E6%95%85%E9%9A%9C%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\" title=\"\u4e22\u6570\u6545\u969c\u89e3\u51b3\u65b9\u6848\">\u4e22\u6570\u6545\u969c\u89e3\u51b3\u65b9\u6848<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%8E%9F%E7%90%86\" title=\"\u89e3\u51b3\u65b9\u6848\u539f\u7406\">\u89e3\u51b3\u65b9\u6848\u539f\u7406<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E8%BE%93%E5%85%A5%E6%95%B0%E6%8D%AE%E6%A0%B7%E4%BE%8B\" title=\"\u8f93\u5165\u6570\u636e\u6837\u4f8b\">\u8f93\u5165\u6570\u636e\u6837\u4f8b<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E8%BE%93%E5%87%BA%E6%95%B0%E6%8D%AE%E6%A0%B7%E4%BE%8B\" title=\"\u8f93\u51fa\u6570\u636e\u6837\u4f8b\">\u8f93\u51fa\u6570\u636e\u6837\u4f8b<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E6%80%BB%E7%BB%93\" title=\"\u603b\u7ed3\">\u603b\u7ed3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99\" title=\"\u5b66\u4e60\u8d44\u6599\">\u5b66\u4e60\u8d44\u6599<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/#flink\" title=\"flink\">flink<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%BA%94%E7%94%A8%E5%9C%BA%E6%99%AF\"><\/span><strong>\u5e94\u7528\u573a\u666f<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u5e94\u7528\u573a\u666f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ul>\n<li><strong>\u300cflink \u4efb\u52a1 A\u300d<\/strong>&nbsp;\u4ee5<strong>\u300c\u5904\u7406\u65f6\u95f4\u300d<\/strong>\u8bed\u4e49\u505a\u8fc7\u6ee4\u4ea7\u51fa\u65b0\u589e xx \u660e\u7ec6\u6570\u636e\u81f3&nbsp;<strong>\u300cKafka Y\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300cflink \u4efb\u52a1 B\u300d<\/strong>&nbsp;\u4ee5<strong>\u300c\u4e8b\u4ef6\u65f6\u95f4\u300d<\/strong>\u8bed\u4e49\u6d88\u8d39&nbsp;<strong>\u300cKafka Y\u300d<\/strong>&nbsp;\u505a\u7a97\u53e3\u805a\u5408\u64cd\u4f5c\u4ea7\u51fa\u5206\u949f\u7ea7\u522b\u805a\u5408\u6307\u6807\u81f3&nbsp;<strong>\u300cKafka Z\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300cKafka Z\u300d<\/strong>&nbsp;\u5b9e\u65f6\u5bfc\u5165\u81f3&nbsp;<strong>\u300cDruid\u300d<\/strong>&nbsp;\u4ee5\u505a\u5373\u65f6 OLAP \u5206\u6790\uff0c\u5e76\u4e14\u5c55\u793a\u5728 BI \u5e94\u7528\u770b\u677f<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic3.zhimg.com\/80\/v2-58886d1e3e4050aa550960f73f206dbe_720w.webp\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%B8%A2%E6%95%B0%E6%95%85%E9%9A%9C%E5%88%86%E6%9E%90\"><\/span><strong>\u4e22\u6570\u6545\u969c\u5206\u6790<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u7b80\u8981\u4ecb\u7ecd\u4e0b\u8fd9\u6b21\u751f\u4ea7\u4e2d\u6545\u969c\u573a\u666f\u3002\u6574\u6761\u6545\u969c\u8ffd\u8e2a\u94fe\u8def\u5982\u4e0b\uff1a<\/p>\n\n\n\n<p>\u6545\u969c\u4e00\uff1a<\/p>\n\n\n\n<ul>\n<li>\u6536\u5230\u62a5\u8b66\u53cd\u9988&nbsp;<strong>\u300cflink \u4efb\u52a1 A\u300d<\/strong>&nbsp;\u5165\u53e3\u6d41\u91cf\u4e3a 0<\/li>\n\n\n\n<li>\u5b9a\u4f4d&nbsp;<strong>\u300cflink \u4efb\u52a1 A\u300d<\/strong>&nbsp;\u4e2d\u67d0\u4e2a\u7b97\u5b50\u7684\u6545\u969c\u5bfc\u81f4\u6574\u4e2a job \u5361\u4f4f<\/li>\n\n\n\n<li>\u5bfc\u81f4\u6b64&nbsp;<strong>\u300cflink \u4efb\u52a1 A\u300d<\/strong>&nbsp;\u4e0a\u6e38&nbsp;<strong>\u300ckafka X\u300d<\/strong>&nbsp;\u79ef\u538b\u4e86\u5927\u91cf\u6570\u636e<\/li>\n\n\n\n<li>\u91cd\u542f&nbsp;<strong>\u300cflink \u4efb\u52a1 A\u300d<\/strong>\u540e\uff0c\u6d88\u8d39\u5927\u91cf\u79ef\u538b\u5728\u4e0a\u6e38&nbsp;<strong>\u300ckafka X\u300d<\/strong>&nbsp;\u6570\u636e\u5b8c\u6210\uff0c\u4efb\u52a1\u6062\u590d\u6b63\u5e38<\/li>\n<\/ul>\n\n\n\n<p>\u6545\u969c\u4e00\u4ece\u800c\u5f15\u53d1\u4e0b\u6e38\u7684\u6545\u969c\u4e8c\uff1a<\/p>\n\n\n\n<ul>\n<li>\u7531\u4e8e&nbsp;<strong>\u300cflink \u4efb\u52a1 A\u300d<\/strong>&nbsp;\u4f7f\u7528\u4e86<strong>\u300c\u5904\u7406\u65f6\u95f4\u300d<\/strong>\u8bed\u4e49\u5904\u7406\u6570\u636e\uff0c\u5e76\u4e14\u6709\u8fc7\u6ee4\u548c keyBy \u5206\u6876\u7a97\u53e3\u903b\u8f91\uff0c\u5728\u91cd\u542f\u540e\u6d88\u8d39\u5927\u91cf\u79ef\u538b\u5728\u4e0a\u6e38\u7684\u6570\u636e\u65f6\uff0c\u5bfc\u81f4 sink rebalance \u540e\u4ea7\u51fa\u5230\u4e0b\u6e38&nbsp;<strong>\u300ckafka Y\u300d<\/strong>&nbsp;\u5404\u4e2a\u5206\u533a\u6570\u636e\u4e2d\u7684 server_timestamp \u662f\u4e71\u5e8f\u7684<\/li>\n\n\n\n<li>\u4e0b\u6e38&nbsp;<strong>\u300cflink \u4efb\u52a1 B\u300d<\/strong>&nbsp;\u5728\u6d88\u8d39&nbsp;<strong>\u300cKafka Y\u300d<\/strong>&nbsp;\u65f6\u4f7f\u7528\u4e86<strong>\u300c\u4e8b\u4ef6\u65f6\u95f4\u300d<\/strong>\u8bed\u4e49\u5904\u7406\u6570\u636e\uff0c\u5e76\u4e14\u4f7f\u7528\u4e86\u6570\u636e\u4e2d\u7684 server_timestamp \u4f5c\u4e3a<strong>\u300c\u4e8b\u4ef6\u65f6\u95f4\u300d<\/strong>\u65f6\u95f4\u6233<\/li>\n\n\n\n<li><strong>\u300cflink \u4efb\u52a1 B\u300d<\/strong>&nbsp;\u6d88\u8d39\u4e86\u4e71\u5e8f\u5f88\u4e25\u91cd\u7684\u6570\u636e\u4e4b\u540e\uff0c\u5bfc\u81f4\u5728\u7a97\u53e3\u805a\u5408\u8ba1\u7b97\u65f6\u4e22\u5931\u4e86\u5927\u91cf\u6570\u636e<\/li>\n\n\n\n<li>\u6700\u7ec8\u5c55\u793a\u5728 BI \u5e94\u7528\u4e2d\u7684\u62a5\u8868\u6709\u4e22\u5931\u6570\u636e\u7684\u60c5\u51b5<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/pic1.zhimg.com\/80\/v2-57796154ecf8e206fddc13075221db4c_720w.webp\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%BE%85%E4%BF%AE%E5%A4%8D%E7%9A%84%E6%95%85%E9%9A%9C%E7%82%B9\"><\/span><strong>\u5f85\u4fee\u590d\u7684\u6545\u969c\u70b9<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul>\n<li>1.<strong>\u300cflink \u4efb\u52a1 A\u300d<\/strong>&nbsp;\u7684\u7a33\u5b9a\u6027\u6545\u969c\uff0c\u8fd9\u90e8\u5206\u89e3\u51b3\u65b9\u6848\u6682\u4e0d\u5728\u672c\u6587\u4e2d\u4ecb\u7ecd<\/li>\n\n\n\n<li>2.<strong>\u300cflink \u4efb\u52a1 B\u300d<\/strong>&nbsp;\u6d88\u8d39\u4e0a\u6e38\u4e71\u5e8f\u4e22\u6570\u6545\u969c\uff0c\u89e3\u51b3\u65b9\u6848\u5728\u4e0b\u6587\u4ecb\u7ecd<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E4%BB%A5%E5%8F%8A%E5%8E%9F%E7%90%86\"><\/span><strong>\u89e3\u51b3\u65b9\u6848\u4ee5\u53ca\u539f\u7406<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E4%B8%A2%E6%95%B0%E6%95%85%E9%9A%9C%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\"><\/span><strong>\u4e22\u6570\u6545\u969c\u89e3\u51b3\u65b9\u6848<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u89e3\u51b3\u65b9\u6848\u662f\u4ee5\u4e0b\u6e38&nbsp;<strong>\u300cflink \u4efb\u52a1 B\u300d<\/strong>&nbsp;\u4f5c\u4e3a\u5207\u5165\u70b9\uff0c\u76f4\u63a5\u7ed9\u51fa&nbsp;<strong>\u300cflink \u4efb\u52a1 B\u300d<\/strong>&nbsp;\u7684 sql \u4ee3\u7801\u89e3\u51b3\u65b9\u6848\uff0cjava code \u4e5f\u53ef\u4ee5\u6309\u7167\u8fd9\u4e2a\u65b9\u6848\u5b9e\u73b0\uff0c\u5176\u672c\u8d28\u539f\u7406\u76f8\u540c\u3002\u4e0b\u6587\u8fdb\u884c\u539f\u7406\u89e3\u91ca\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SELECT\n  to_unix_timestamp(server_timestamp \/ bucket) AS timestamp, -- format \u6210\u539f\u6709\u7684\u4e8b\u4ef6\u65f6\u95f4\u6233\n  count(id) as id_cnt,\n  sum(duration) as duration_sum\nFROM\n  source_table\nGROUP BY\n  TUMBLE(proctime, INTERVAL '1' MINUTE),\n  server_timestamp \/ bucket -- \u6839\u636e\u4e8b\u4ef6\u65f6\u95f4\u5206\u6876\u8ba1\u7b97\uff0c\u5c06\u76f8\u540c\u8303\u56f4\uff08\u6bd4\u5982 1 \u5206\u949f\uff09\u4e8b\u4ef6\u65f6\u95f4\u7684\u6570\u636e\u5206\u5230\u4e00\u4e2a\u6876\u5185\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E5%8E%9F%E7%90%86\"><\/span><strong>\u89e3\u51b3\u65b9\u6848\u539f\u7406<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u9996\u5148\u660e\u786e\u4e00\u4e2a\u65e0\u6cd5\u907f\u514d\u7684\u95ee\u9898\uff0c\u5728\u4e0d\u8003\u8651 watermark \u5141\u8bb8\u5ef6\u8fdf\u8bbe\u7f6e\u7279\u522b\u5927\u7684\u60c5\u51b5\u4e0b\uff0c\u53ea\u8981\u4e0a\u6e38\u4f7f\u7528\u5230\u4e86\u5904\u7406\u65f6\u95f4\u8bed\u4e49\uff0c\u4e0b\u6e38\u4f7f\u7528\u4e8b\u4ef6\u65f6\u95f4\u8bed\u4e49\uff0c\u4e00\u65e6\u4e0a\u6e38\u53d1\u751f\u6545\u969c\u91cd\u542f\u5e76\u5728\u77ed\u65f6\u95f4\u5185\u6d88\u8d39\u5927\u91cf\u6570\u636e\uff0c\u5c31\u4e0d\u53ef\u907f\u514d\u7684\u4f1a\u51fa\u73b0\u4e0a\u8ff0\u9519\u8bef\u4ee5\u53ca\u6545\u969c\u3002<\/p>\n\n\n\n<p>\u5728\u4e0b\u6e38\u6d88\u8d39\u65b9\u4ecd\u7136\u9700\u8981\u5c06\u5bf9\u5e94\u4e8b\u4ef6\u65f6\u95f4\u6233\u7684\u6570\u636e\u5c55\u793a\u5728 BI \u5e73\u53f0\u62a5\u8868\u4e2d\u3001\u5e76\u4e14\u5168\u94fe\u8def\u65f6\u95f4\u8bed\u4e49\u90fd\u4e3a\u5904\u7406\u65f6\u95f4\u4fdd\u969c\u4e0d\u4e22\u6570\u7684\u524d\u63d0\u4e0b\u3002\u89e3\u51b3\u65b9\u6848\u5c31\u662f\u5728\u805a\u5408\u5e76\u6700\u7ec8\u4ea7\u51fa\u5bf9\u5e94\u4e8b\u4ef6\u65f6\u95f4\u6233\u7684\u6570\u636e\u3002<\/p>\n\n\n\n<p>\u6700\u540e\u7684\u65b9\u6848\u5982\u4e0b\uff1a\u6574\u6761\u94fe\u8def\u5168\u90e8\u4e3a\u5904\u7406\u65f6\u95f4\u8bed\u4e49\uff0c\u7a97\u53e3\u8ba1\u7b97\u4e5f\u4f7f\u7528\u5904\u7406\u65f6\u95f4\uff0c\u4f46\u662f\u4ea7\u51fa\u6570\u636e\u4e2d\u7684\u65f6\u95f4\u6233\u5168\u90e8\u4e3a\u4e8b\u4ef6\u65f6\u95f4\u6233\u3002\u5728\u51fa\u73b0\u6545\u969c\u7684\u573a\u666f\u4e0b\uff0c\u4e00\u5206\u949f\u7684\u7a97\u53e3\u5185\u7684\u6570\u636e\u7684\u4e8b\u4ef6\u65f6\u95f4\u6233\u53ef\u80fd\u76f8\u5dee\u51e0\u4e2a\u5c0f\u65f6\uff0c\u4f46\u5728\u6700\u7ec8\u7a97\u53e3\u805a\u5408\u65f6\u53ef\u4ee5\u6839\u636e\u4e8b\u4ef6\u65f6\u95f4\u6233\u5212\u5206\u5230\u5bf9\u5e94\u7684\u4e8b\u4ef6\u65f6\u95f4\u7a97\u53e3\u5185\uff0c\u4e0b\u6e38 BI \u5e94\u7528\u5c55\u793a\u65f6\u4f7f\u7528\u6b64\u4e8b\u4ef6\u65f6\u95f4\u6233\u5373\u53ef\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\">\n<p>\u275d\u6ce8\u610f\uff1asql \u4e2d\u7684 bucket \u9700\u8981\u6839\u636e\u5177\u4f53\u4f7f\u7528\u573a\u666f\u8fdb\u884c\u8bbe\u7f6e\uff0c\u5982\u679c\u8bbe\u7f6e\u8fc7\u4e8e\u5c0f\uff0c\u6bd4\u5982\u975e\u6545\u969c\u573a\u666f\u4e0b\u6309\u7167\u5904\u7406\u65f6\u95f4\u5f00 1 \u5206\u949f\u7684\u7a97\u53e3\uff0cbucket \u8bbe\u4e3a 60000\uff081 \u5206\u949f\uff09\uff0c\u90a3\u4e48\u6781\u6709\u53ef\u80fd\uff0c\u8fd9\u4e2a\u65f6\u95f4\u7a97\u53e3\u4e2d\u6240\u6709\u6570\u636e\u7684 server_timestamp \u90fd\u96c6\u4e2d\u5728\u67d0\u4e24\u5206\u949f\u5185\uff0c\u90a3\u4e48\u8fd9\u4e9b\u6570\u636e\u5c31\u4f1a\u88ab\u5206\u5230\u4e24\u4e2a\u6876\uff08bucket\uff09\u5185\uff0c\u5219\u4f1a\u5bfc\u81f4\u4e25\u91cd\u7684\u6570\u636e\u503e\u659c\u3002<br>\u275e<\/p>\n<\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%BE%93%E5%85%A5%E6%95%B0%E6%8D%AE%E6%A0%B7%E4%BE%8B\"><\/span><strong>\u8f93\u5165\u6570\u636e\u6837\u4f8b<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u6a21\u62df\u4e0a\u8ff0\u6545\u969c\uff0c<strong>\u300cflink B\u300d<\/strong>&nbsp;\u7684\u4efb\u52a1\u67d0\u4e00\u4e2a\u7a97\u53e3\u5185\u7684\u6570\u636e\u8f93\u5165\u5982\u4e0b\uff08server_timestamp, id, duration\uff09\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>2020\/9\/01 21:14:38<\/td><td>1<\/td><td>300<\/td><\/tr><tr><td>2020\/9\/01 21:14:50<\/td><td>1<\/td><td>500<\/td><\/tr><tr><td>2020\/9\/01 21:25:38<\/td><td>2<\/td><td>600<\/td><\/tr><tr><td>2020\/9\/01 21:25:38<\/td><td>3<\/td><td>900<\/td><\/tr><tr><td>2020\/9\/01 21:25:38<\/td><td>2<\/td><td>800<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%BE%93%E5%87%BA%E6%95%B0%E6%8D%AE%E6%A0%B7%E4%BE%8B\"><\/span><strong>\u8f93\u51fa\u6570\u636e\u6837\u4f8b<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>\u6309\u7167\u4e0a\u8ff0\u89e3\u51b3\u65b9\u6848\u4e2d\u7684 sql \u5904\u7406\u8fc7\u540e\uff0c\u8f93\u51fa\u6570\u636e\u5982\u4e0b(timestamp, id<em>cnt, duration_<\/em>sum)\uff0c\u5219\u53ef\u4ee5\u89e3\u51b3\u6b64\u7c7b\u578b\u4e22\u6570\u6545\u969c\u3002<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>2020\/9\/01 21:14:00<\/td><td>2<\/td><td>900<\/td><\/tr><tr><td>2020\/9\/01 21:25:00<\/td><td>3<\/td><td>2300<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E6%80%BB%E7%BB%93\"><\/span><strong>\u603b\u7ed3<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>\u672c\u6587\u5206\u6790\u4e86\u5728 flink \u5e94\u7528\u4e2d\uff1a<\/p>\n\n\n\n<ul>\n<li><strong>\u300c\u4e0a\u6e38\u4f7f\u7528\u5904\u7406\u65f6\u95f4\u8bed\u4e49\u7684 flink \u4efb\u52a1\u51fa\u73b0\u6545\u969c\u3001\u91cd\u542f\u6d88\u8d39\u5927\u91cf\u79ef\u538b\u6570\u636e\u5e76\u4ea7\u51fa\u81f3\u4e0b\u6e38\u6570\u636e\u4e71\u5e8f\u7279\u522b\u4e25\u91cd\u65f6\uff0c\u4e0b\u6e38\u4f7f\u7528\u4e8b\u4ef6\u65f6\u95f4\u8bed\u4e49\u65f6\u9047\u5230\u7684\u5927\u91cf\u4e22\u6570\u95ee\u9898\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300c\u4ee5\u6574\u6761\u94fe\u8def\u4e3a\u5904\u7406\u65f6\u95f4\u8bed\u4e49\u7684\u524d\u63d0\u4e0b\uff0c\u4ea7\u51fa\u7684\u6570\u636e\u65f6\u95f4\u6233\u4e3a\u4e8b\u4ef6\u65f6\u95f4\u6233\u89e3\u51b3\u4e0a\u8ff0\u95ee\u9898\u300d<\/strong><\/li>\n\n\n\n<li><strong>\u300c\u4ee5 sql \u4ee3\u7801\u7ed9\u51fa\u4e86\u4e22\u6570\u6545\u969c\u89e3\u51b3\u65b9\u6848\u6837\u4f8b\u300d<\/strong><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%96%99\"><\/span><strong>\u5b66\u4e60\u8d44\u6599<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"flink\"><\/span><strong>flink<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ul>\n<li><a href=\"https:\/\/link.zhihu.com\/?target=https%3A\/\/github.com\/flink-china\/flink-training-course\/blob\/master\/README.md\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/github.com\/flink-china\/flink-training-course\/blob\/master\/README.md<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/link.zhihu.com\/?target=https%3A\/\/ververica.cn\/developers-resources\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/ververica.cn\/developers-resources\/<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/link.zhihu.com\/?target=https%3A\/\/space.bilibili.com\/33807709\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/space.bilibili.com\/3380<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a \u5e94\u7528\u573a\u666f \u5e94\u7528\u573a\u666f\u5982\u4e0b\uff1a \u4e22\u6570\u6545\u969c\u5206\u6790 \u7b80\u8981\u4ecb\u7ecd\u4e0b\u8fd9\u6b21\u751f\u4ea7\u4e2d\u6545\u969c\u573a\u666f\u3002\u6574\u6761\u6545&hellip; <a href=\"http:\/\/viplao.com\/index.php\/2023\/03\/19\/%e3%80%90%e8%bf%90%e7%bb%b4%e5%b7%a5%e5%85%b7%e3%80%91flink-sql-%e4%ba%8b%e4%bb%b6%e6%97%b6%e9%97%b4%e4%b8%8b%e6%95%b0%e6%8d%ae%e4%b9%b1%e5%ba%8f%e4%b8%a2%e6%95%b0%e8%b8%a9%e5%9d%91\/\" class=\"more-link read-more\" rel=\"bookmark\">\u7ee7\u7eed\u9605\u8bfb <span class=\"screen-reader-text\">\u3010\u8fd0\u7ef4\u5de5\u5177\u3011Flink SQL \u4e8b\u4ef6\u65f6\u95f4\u4e0b\u6570\u636e\u4e71\u5e8f\u4e22\u6570\u8e29\u5751<\/span><i class=\"fa fa-arrow-right\"><\/i><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[25],"views":1049,"_links":{"self":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/1304"}],"collection":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/comments?post=1304"}],"version-history":[{"count":1,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/1304\/revisions"}],"predecessor-version":[{"id":1305,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/posts\/1304\/revisions\/1305"}],"wp:attachment":[{"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/media?parent=1304"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/categories?post=1304"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/viplao.com\/index.php\/wp-json\/wp\/v2\/tags?post=1304"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}