{"id":47005,"date":"2023-03-12T04:30:41","date_gmt":"2023-06-12T05:31:46","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/"},"modified":"2024-04-29T18:31:02","modified_gmt":"2024-04-29T10:31:02","slug":"%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/","title":{"rendered":"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8"},"content":{"rendered":"<h1>\u76ee\u6807<\/h1>\n<p>\u7531\u4e8e\u9700\u8981\u63a5\u89e6ksqlDB\uff0c\u56e0\u6b64\u521b\u5efa\u4e86Confluent\u7279\u5236\u7684\u5feb\u901f\u5f00\u59cb\u6307\u5357\uff0c\u5e76\u8bb0\u5f55\u4e86\u76f8\u5173\u5907\u6ce8\u3002\u539f\u59cb\u8d44\u6599\uff1aksqlDB\u5feb\u901f\u5f00\u59cb\u3002<\/p>\n<h1>\u9019\u500b\u4e2d\u6587\u554f\u984c\u8b93\u6211\u5230\u9054\u77ac\u9593\u77ed\u8def,\u4f46\u6211\u6703\u8a66\u8a66\u770b\u3002<\/h1>\n<p>\u76f8\u95dc\u7684Qiita\u6587\u7ae0<\/p>\n<p>1. \u5c1d\u8bd5\u8fdb\u884cksqlDB\u5feb\u901f\u5165\u95e8<br \/>\n2. \u521b\u5efa\u4f7f\u7528ksqlDB\u7684\u6d41\u67e5\u8be2\uff08\u524d\u534a\u90e8\u5206\uff09<br \/>\n3. \u521b\u5efa\u4f7f\u7528ksqlDB\u7684\u6d41\u67e5\u8be2\uff08\u540e\u534a\u90e8\u5206\uff09<br \/>\n4. \u5728Kafka\u4e0a\u5904\u7406MySQL\u8868\u7684\u66f4\u65b0\u4fe1\u606f\uff0c\u4f7f\u7528ksql\u5904\u7406<\/p>\n<h1>\u73af\u5883<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Ubuntu 20.04 (on WSL2)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Confluent Platform Community Edition 6.2.1<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">Kafka\u30af\u30e9\u30b9\u30bf\u30fc\u306f\u6700\u5c0f\u69cb\u6210\u3067\u7a3c\u50cd(*.properties\u306f\u6b86\u3069\u3044\u3058\u3063\u3066\u3044\u306a\u3044)<\/ul>\n<h1>ksqlDB \u5feb\u901f\u5165\u95e8<\/h1>\n<h2>1. \u83b7\u53d6 Confluent \u5e73\u53f0<\/h2>\n<p>\u5ffd\u7565\u4e0d\u8ba1\u3002<\/p>\n<h2>2. \u542f\u52a8 ksqlDB \u7684\u670d\u52a1\u5668<\/h2>\n<p>\u5728\u542f\u52a8ksqlDB\u670d\u52a1\u5668\u4e4b\u524d\uff0c\u5148\u542f\u52a8zookeeper\u548cbroker\u3002\u7531\u4e8e\u6ca1\u6709\u4f7f\u7528Docker\uff0c\u6240\u4ee5\u76f4\u63a5\u4f7f\u7528\u547d\u4ee4\u8fdb\u884c\u542f\u52a8\u3002\u6ca1\u6709\u5bf9ksql-server.properties\u8fdb\u884c\u4efb\u4f55\u7279\u6b8a\u66f4\u6539\u3002\u6267\u884c\u547d\u4ee4\uff1abin\/ksql-server-start etc\/ksqldb\/ksql-server.properties\u3002<\/p>\n<pre class=\"post-pre\"><code>...\r\n[2021-10-19 14:38:38,630] INFO Waiting until monitored service is ready for metrics collection (io.confluent.support.metrics.BaseMetricsReporter:171)\r\n[2021-10-19 14:38:38,630] INFO Monitored service is now ready (io.confluent.support.metrics.BaseMetricsReporter:183)\r\n[2021-10-19 14:38:38,630] INFO Attempting to collect and submit metrics (io.confluent.support.metrics.BaseMetricsReporter:142)\r\n[2021-10-19 14:38:38,633] INFO ksqlDB API server listening on http:\/\/0.0.0.0:8088 (io.confluent.ksql.rest.server.KsqlRestApplication:375)\r\n[2021-10-19 14:38:38,634] INFO Server up and running (io.confluent.ksql.rest.server.KsqlServerMain:90)\r\n[2021-10-19 14:38:39,648] INFO Successfully submitted metrics to Confluent via secure endpoint (io.confluent.support.metrics.submitters.ConfluentSubmitter:146)\r\n<\/code><\/pre>\n<p>ksql\u670d\u52a1\u5668\u542f\u52a8\u540e\uff0c\u5927\u7ea6\u521b\u5efa\u4e86\u4e09\u4e2a\u7528\u4e8e\u5185\u90e8\u5904\u7406\u7684\u4e3b\u9898\u3002<br \/>\n&#8211; \u4ea4\u6613\u72b6\u6001<br \/>\n&#8211; confluent-ksql-default__command_topic<br \/>\n&#8211; \u9ed8\u8ba4_ksql\u5904\u7406\u65e5\u5fd7<\/p>\n<pre class=\"post-pre\"><code>gen@LAPTOP-O8FG8ES2:~\/confluent-6.2.1$ bin\/kafka-topics --list --bootstrap-server localhost:9092\r\n__consumer_offsets\r\n__transaction_state\r\n_confluent-ksql-default__command_topic\r\n_schemas\r\ndefault_ksql_processing_log\r\n<\/code><\/pre>\n<h2>3. \u542f\u52a8 ksqlDB \u7684\u4ea4\u4e92\u5f0f CLI<\/h2>\n<p>\u7531\u4e8e\u6ca1\u6709\u4f7f\u7528Docker\uff0c\u6240\u4ee5\u76f4\u63a5\u901a\u8fc7\u547d\u4ee4\u542f\u52a8\u3002<br \/>\n\u542f\u52a8ksqlDB CLI\u3002<br \/>\n\u6309\u7167\u4e0a\u8ff0\u6307\u5357\uff0c\u9884\u5148\u521b\u5efa\u7528\u4e8e\u5b58\u50a8ksql\u65e5\u5fd7\u7684\u76ee\u5f55\uff0c\u5e76\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u4f20\u9012\u3002<br \/>\nLOG_DIR=.\/ksql_logs bin\/ksql http:\/\/localhost:8088<\/p>\n<pre class=\"post-pre\"><code>gen@LAPTOP-O8FG8ES2:~\/confluent-6.2.1$ LOG_DIR=.\/ksql_logs bin\/ksql http:\/\/localhost:8088\r\n\r\n                  ===========================================\r\n                  =       _              _ ____  ____       =\r\n                  =      | | _____  __ _| |  _ \\| __ )      =\r\n                  =      | |\/ \/ __|\/ _` | | | | |  _ \\      =\r\n                  =      |   &lt;\\__ \\ (_| | | |_| | |_) |     =\r\n                  =      |_|\\_\\___\/\\__, |_|____\/|____\/      =\r\n                  =                   |_|                   =\r\n                  =  Event Streaming Database purpose-built =\r\n                  =        for stream processing apps       =\r\n                  ===========================================\r\n\r\nCopyright 2017-2021 Confluent Inc.\r\n\r\nCLI v6.2.1, Server v6.2.1 located at http:\/\/localhost:8088\r\nServer Status: RUNNING\r\n\r\nHaving trouble? Type 'help' (case-insensitive) for a rundown of how things work!\r\n\r\nksql&gt;\r\n<\/code><\/pre>\n<p>\u6211\u559c\u6b22\u8fd9\u6837\u7684ASCII\u827a\u672f\uff01\uff08\u5df4\u554a\u554a\u554a\u554a\u554a\uff09<\/p>\n<h2>4. \u521b\u5efa\u4e00\u4e2a\u6d41<\/h2>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3astream\u7684\u4e1c\u897f\u3002\u7c7b\u4f3c\u4e8e\u4e3akafka\u4e3b\u9898\u6dfb\u52a0\u6a21\u5f0f\u7684\u4e1c\u897f\u3002\u7ed9\u4e88\u4ee5\u4e0b\u5c5e\u6027\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u540d\u524d: stream\u306e\u540d\u524d<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">kafka-topic: \u3053\u306estream\u306b\u5bfe\u5fdc\u3059\u308btopic\u540d<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">value_format: topic\u306b\u683c\u7d0d\u3057\u305f\u30e1\u30c3\u30bb\u30fc\u30b8\u306eEncoding\u3002JSON\u3063\u3066\u66f8\u3044\u3068\u3051\u3070\u3088\u3055\u305d\u3046\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">partitions: topic\u5185\u306e\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u6570<\/ul>\n<p>\u4ee5\u4e0b\u662f\u4eceksql CLI\u521b\u5efa\u7684\u6d41\u7684\u5c5e\u6027\u3002<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u540d\u524d: riderLocations(\u30e9\u30a4\u30c0\u30fc\u306e\u5c45\u5834\u6240\u307f\u305f\u3044\u306a\u3082\u3093)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u5c5e\u6027\u5024<\/ul>\n<\/li>\n<\/ul>\n<p>profileId VARCHAR(\u30d7\u30ed\u30d5\u30a1\u30a4\u30ebID\u5024)<br \/>\nlatitude DOUBLE(\u7def\u5ea6)<br \/>\nlongitude DOUBLE(\u7d4c\u5ea6)<\/p>\n<p>kafka-topic: locations<br \/>\nvalue_format: json<br \/>\npartitions: 1<\/p>\n<pre class=\"post-pre\"><code>ksql&gt; CREATE STREAM riderLocations (profileId VARCHAR, latitude DOUBLE, longitude DOUBLE)\r\n&gt;  WITH (kafka_topic='locations', value_format='json', partitions=1);\r\n\r\n Message\r\n----------------\r\n Stream created\r\n----------------\r\n<\/code><\/pre>\n<h2>5. \u521b\u5efa\u7269\u5316\u89c6\u56fe<\/h2>\n<p>\u521b\u5efa\u4e24\u4e2a\u8868\u3002\u7b2c\u4e00\u4e2a\u8868currentLocation\u4ec5\u5b58\u50a8\u4eceriderLocation\u6d41\u4e2d\u83b7\u53d6\u7684\u6700\u65b0\u4f4d\u7f6e\u3002LATEST_BY_OFFSET\u4f5c\u4e3aSQL\u805a\u5408\u51fd\u6570\u88ab\u4f7f\u7528\uff0c\u5b83\u8fd4\u56de(topic\/partition\u4e2d)\u6700\u65b0\u504f\u79fb\u91cf\u7684\u503c\uff0c\u5373latitude\/longitude\u3002EMIT CHANGES\u8868\u793a\u8fd9\u4e2aSQL\u67e5\u8be2\u662f\u4e00\u4e2a\u63a8\u9001\u67e5\u8be2\uff0c\u8868\u660eSQL\u5904\u7406\u5c06\u6301\u7eed\u6267\u884c\u7684\u7c7b\u578b\u3002<\/p>\n<pre class=\"post-pre\"><code>CREATE TABLE currentLocation AS\r\n  SELECT profileId,\r\n         LATEST_BY_OFFSET(latitude) AS la,\r\n         LATEST_BY_OFFSET(longitude) AS lo\r\n  FROM riderlocations\r\n  GROUP BY profileId\r\n  EMIT CHANGES;\r\n<\/code><\/pre>\n<p>\u7b2c\u4e8c\u4e2a\u8868\u683criderNearMountainView\u6709\u70b9\u590d\u6742\uff0c\u4f46\u6211\u4eec\u52aa\u529b\u89e3\u8bfb\u4e00\u4e0b\u3002<\/p>\n<pre class=\"post-pre\"><code>CREATE TABLE ridersNearMountainView AS\r\n  SELECT ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1) AS distanceInMiles,\r\n         COLLECT_LIST(profileId) AS riders,\r\n         COUNT(*) AS count\r\n  FROM currentLocation\r\n  GROUP BY ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1);\r\n<\/code><\/pre>\n<p>GEO_DISTANCE\uff08la\uff0clo\uff0c37.4133\uff0c-122.1162\uff09\u662f\u4e00\u4e2a\u8fd4\u56de\u7ecf\u7eac\u5ea6\u4e4b\u95f4\u5927\u5706\u8ddd\u79bb\uff08\u5355\u4f4d\uff1a\u5343\u7c73\uff09\u7684\u6807\u91cf\u51fd\u6570\u3002<\/p>\n<p>\u5c06xxx\u56db\u820d\u4e94\u5165\u81f3\u6700\u63a5\u8fd1\u7684\u6574\u6570\uff0c\u7cbe\u5ea6\u4e3a\u96f6\u3002\u5982\u679c\u7cbe\u5ea6\u4e3a\u8d1f\u6570\uff0c\u5219\u5c06\u6570\u503c\u56db\u820d\u4e94\u5165\u81f3\u5c0f\u6570\u70b9\u53f3\u4fa7\uff0c\u4f46\u6211\u4e0d\u592a\u660e\u767d\u5b83\u7684\u610f\u601d\u3002<\/p>\n<p>COLLECT_LIST(profileId)\u662f\u4e00\u79cd\u805a\u5408\u51fd\u6570\uff0c\u5c06\u6240\u6709\u503c\u4f5c\u4e3a\u6570\u7ec4\u8fd4\u56de\u3002<\/p>\n<p>\u603b\u884c\u6570<br \/>\n\u8fd4\u56de\u4e00\u4e2a\u7edf\u8ba1\u51fd\u6570\u7684\u884c\u6570<\/p>\n<p>\u901a\u8fc7\u6307\u5b9aFROM\u548cGROUP BY\u7684SQL\u8bed\u53e5\uff0c\u8fd9\u4f3c\u4e4e\u662f\u8981\u6267\u884c\u4e00\u4e2a\u64cd\u4f5c\uff0c\u5373\u5728\u6700\u65b0\u65f6\u95f4\u70b9(currentLocation)\u4e0a\uff0c\u6309\u7167\u8ddd\u79bb(distanceInMiles)\u4ece\u67d0\u4e00\u5730\u70b9\u8d77\u7684\u6bcf\u4e2a\u8ddd\u79bb\u8fd4\u56de\u6240\u6709\u9a91\u624b\u7684\u4e2a\u4eba\u8d44\u6599\u540d(riders)\u548c\u4eba\u6570(count)\u3002\u987a\u4fbf\u63d0\u4e00\u4e0b\uff0c\u8be5\u5730\u70b9(\u7eac\u5ea637.4133\u3001\u7ecf\u5ea6-122.1162)\u770b\u8d77\u6765\u50cf\u662f\u52a0\u5229\u798f\u5c3c\u4e9a\u7684MountainView\u3002\u4f7f\u7528ksqlcli\u521b\u5efa\u8868\u6ca1\u6709\u9047\u5230\u7279\u522b\u95ee\u9898\uff0c\u987a\u5229\u5b8c\u6210\u3002<\/p>\n<pre class=\"post-pre\"><code>ksql&gt; CREATE TABLE currentLocation AS\r\n&gt;  SELECT profileId,\r\n&gt;         LATEST_BY_OFFSET(latitude) AS la,\r\n&gt;         LATEST_BY_OFFSET(longitude) AS lo\r\n&gt;  FROM riderlocations\r\n&gt;  GROUP BY profileId\r\n&gt;  EMIT CHANGES;\r\n\r\n Message\r\n----------------------------------------------\r\n Created query with ID CTAS_CURRENTLOCATION_3\r\n----------------------------------------------\r\nksql&gt; CREATE TABLE ridersNearMountainView AS\r\n&gt;  SELECT ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1) AS distanceInMiles,\r\n&gt;         COLLECT_LIST(profileId) AS riders,\r\n&gt;         COUNT(*) AS count\r\n&gt;  FROM currentLocation\r\n&gt;  GROUP BY ROUND(GEO_DISTANCE(la, lo, 37.4133, -122.1162), -1);\r\n\r\n Message\r\n-----------------------------------------------------\r\n Created query with ID CTAS_RIDERSNEARMOUNTAINVIEW_5\r\n-----------------------------------------------------\r\n<\/code><\/pre>\n<h2>6. \u5728\u6d41\u4e0a\u8fd0\u884c\u4e00\u4e2a\u63a8\u9001\u67e5\u8be2<\/h2>\n<p>\u5728MoutainView\u53d1\u51fapush\u67e5\u8be2\u6765\u6d41\uff08stream\uff09\u8bf7\u6c42\u3002\u4ece\u8ddd\u79bb\u5c71\u89c65\u516c\u91cc\u4ee5\u5185\u7684\u4f4d\u7f6e\u4fe1\u606f\u5f00\u59cb\u9010\u4e2a\u663e\u793a\uff08Cofluent\u7f51\u7ad9\u4e0a\u4f7f\u7528\u82f1\u91cc\u8868\u793a\uff0c\u4f46GEO_DISTANCE\u51fd\u6570\u9ed8\u8ba4\u4f7f\u7528\u516c\u91cc\uff09\u3002\u7531\u4e8e\u6307\u5b9a\u4e86EMIT CHANGES\uff0c\u6240\u4ee5\u770b\u8d77\u6765\u4f1a\u6301\u7eed\u6267\u884c\u4e0b\u53bb\u3002<\/p>\n<pre class=\"post-pre\"><code>-----------------------------------------------------\r\nksql&gt; -- Mountain View lat, long: 37.4133, -122.1162\r\nksql&gt; SELECT * FROM riderLocations\r\n&gt;  WHERE GEO_DISTANCE(latitude, longitude, 37.4133, -122.1162) &lt;= 5 EMIT CHANGES;\r\n+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+\r\n|PROFILEID                                                                    |LATITUDE                                                                     |LONGITUDE                                                                    |\r\n+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+\r\n<\/code><\/pre>\n<h2>7. \u5f00\u542f\u53e6\u4e00\u4e2a\u547d\u4ee4\u884c\u4f1a\u8bdd<\/h2>\n<p>\u5728\u4e00\u4e2a\u65b0\u7684\u7a97\u53e3\u6253\u5f00ksqlCLI\u4f1a\u8bdd\u3002<\/p>\n<h2>8. \u7528\u4e8b\u4ef6\u586b\u5145\u6d41<\/h2>\n<p>\u4ece\u65b0\u7a97\u53e3\u542f\u52a8\u7684ksqlCLI\u5411\u6d41\u4e2d\u63d2\u51656\u6761\u6570\u636e\u3002<\/p>\n<pre class=\"post-pre\"><code>ksql&gt; INSERT INTO riderLocations (profileId, latitude, longitude) VALUES ('c2309eec', 37.7877, -122.4205);\r\nksql&gt; INSERT INTO riderLocations (profileId, latitude, longitude) VALUES ('18f4ea86', 37.3903, -122.0643);\r\nksql&gt; INSERT INTO riderLocations (profileId, latitude, longitude) VALUES ('4ab5cbad', 37.3952, -122.0813);\r\nksql&gt; INSERT INTO riderLocations (profileId, latitude, longitude) VALUES ('8b6eae59', 37.3944, -122.0813);\r\nksql&gt; INSERT INTO riderLocations (profileId, latitude, longitude) VALUES ('4a7c7b41', 37.4049, -122.0822);\r\nksql&gt; INSERT INTO riderLocations (profileId, latitude, longitude) VALUES ('4ddad000', 37.7857, -122.4011);\r\n<\/code><\/pre>\n<p>\u901a\u8fc7\u8fd9\u4e2a\u64cd\u4f5c\uff0c\u53ea\u6709\u8ddd\u79bbMountainView\u4e0d\u8d85\u8fc75\u516c\u91cc\u7684\u8bb0\u5f55\u4f1a\u5728ksqlCLI\u7684\u7ed3\u679c\u4e2d\u663e\u793a\u51fa\u6765\u3002<\/p>\n<pre class=\"post-pre\"><code>+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+\r\n|PROFILEID                                                                    |LATITUDE                                                                     |LONGITUDE                                                                    |\r\n+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+-----------------------------------------------------------------------------+\r\n|4ab5cbad                                                                     |37.3952                                                                      |-122.0813                                                                    |\r\n|8b6eae59                                                                     |37.3944                                                                      |-122.0813                                                                    |\r\n|4a7c7b41                                                                     |37.4049                                                                      |-122.0822                                                                    |\r\n<\/code><\/pre>\n<h2>9. \u5bf9\u7269\u5316\u89c6\u56fe\u8fd0\u884cPull\u67e5\u8be2<\/h2>\n<p>\u6700\u540e\uff0c\u5c1d\u8bd5\u4eceridersNearMountainView\u8868\u4e2d\u63d0\u53d6\u8ddd\u79bb\u572810\u516c\u91cc\u4ee5\u5185\u7684\u8bb0\u5f55\u3002\u901a\u8fc7\u8bbe\u7f6e\u53c2\u6570\u6765\u6267\u884cSQL\u67e5\u8be2\uff0c\u800c\u4e0d\u662f\u4f7f\u7528push\u65b9\u5f0f\u3002\u989d\u5916\u5c1d\u8bd5\u63d0\u53d6\u6240\u6709\u8bb0\u5f55\uff0c\u4f46\u662f\u4ecd\u7136\u4e0d\u592a\u6e05\u695aROUND\u51fd\u6570\u7684\u820d\u5165\u65b9\u5f0f\u3002<\/p>\n<pre class=\"post-pre\"><code>ksql&gt; SET 'ksql.query.pull.table.scan.enabled'='true';\r\nSuccessfully changed local property 'ksql.query.pull.table.scan.enabled' to 'true'. Use the UNSET command to revert your change.\r\nksql&gt; SELECT * from ridersNearMountainView WHERE distanceInMiles &lt;= 10;\r\n+---------------------------------------------------------+---------------------------------------------------------+---------------------------------------------------------+\r\n|DISTANCEINMILES                                          |RIDERS                                                   |COUNT                                                    |\r\n+---------------------------------------------------------+---------------------------------------------------------+---------------------------------------------------------+\r\n|0.0                                                      |[4ab5cbad, 8b6eae59, 4a7c7b41]                           |3                                                        |\r\n|10.0                                                     |[18f4ea86]                                               |1                                                        |\r\nksql&gt; SELECT * from ridersNearMountainView;\r\n+---------------------------------------------------------+---------------------------------------------------------+---------------------------------------------------------+\r\n|DISTANCEINMILES                                          |RIDERS                                                   |COUNT                                                    |\r\n+---------------------------------------------------------+---------------------------------------------------------+---------------------------------------------------------+\r\n|0.0                                                      |[4ab5cbad, 8b6eae59, 4a7c7b41]                           |3                                                        |\r\n|10.0                                                     |[18f4ea86]                                               |1                                                        |\r\n|50.0                                                     |[c2309eec, 4ddad000]                                     |2                                                        |\r\n\r\n<\/code><\/pre>\n<h1>\u603b\u7ed3<\/h1>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u5927\u5143\u306etopic\u3092stream\u3068\u3057\u3066\u5b9a\u7fa9<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">stream\u304b\u3089table\u3082\u4f5c\u308c\u308b\u3057\u3001table\u304b\u3089table\u3082\u4f5c\u308c\u308b\u3002\u3053\u308c\u3092materialized view\u3068\u547c\u3076?<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">ksql\u306e\u5b9f\u884c\u306fpush\u578b\u3068pull\u578b\u306e2\u3064\u304c\u3042\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">push\u3067\u4f5c\u3063\u305ftable\u3092pull\u2192pull\u3068materialized view\u3067\u5f15\u5f35\u3063\u305f\u308a\u3082\u3067\u304d\u308b<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\u95a2\u6570\u306f\u304b\u306a\u308a\u6ca2\u5c71\u3042\u308a\u305d\u3046<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6807 \u7531\u4e8e\u9700\u8981\u63a5\u89e6ksqlDB\uff0c\u56e0\u6b64\u521b\u5efa\u4e86Confluent\u7279\u5236\u7684\u5feb\u901f\u5f00\u59cb\u6307\u5357\uff0c\u5e76\u8bb0\u5f55\u4e86\u76f8\u5173\u5907\u6ce8\u3002\u539f\u59cb\u8d44\u6599\uff1ak [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-47005","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5c1d\u8bd5\u8fdb\u884c-ksqldb-\u5feb\u901f\u5165\u95e8\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8\" \/>\n<meta property=\"og:description\" content=\"\u76ee\u6807 \u7531\u4e8e\u9700\u8981\u63a5\u89e6ksqlDB\uff0c\u56e0\u6b64\u521b\u5efa\u4e86Confluent\u7279\u5236\u7684\u5feb\u901f\u5f00\u59cb\u6307\u5357\uff0c\u5e76\u8bb0\u5f55\u4e86\u76f8\u5173\u5907\u6ce8\u3002\u539f\u59cb\u8d44\u6599\uff1ak [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u5c1d\u8bd5\u8fdb\u884c-ksqldb-\u5feb\u901f\u5165\u95e8\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-12T05:31:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T10:31:02+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u9896\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u9896\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/\",\"name\":\"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-06-12T05:31:46+00:00\",\"dateModified\":\"2024-04-29T10:31:02+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e\",\"name\":\"\u79d1, \u9896\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u9896\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u5c1d\u8bd5\u8fdb\u884c-ksqldb-\u5feb\u901f\u5165\u95e8\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8","og_description":"\u76ee\u6807 \u7531\u4e8e\u9700\u8981\u63a5\u89e6ksqlDB\uff0c\u56e0\u6b64\u521b\u5efa\u4e86Confluent\u7279\u5236\u7684\u5feb\u901f\u5f00\u59cb\u6307\u5357\uff0c\u5e76\u8bb0\u5f55\u4e86\u76f8\u5173\u5907\u6ce8\u3002\u539f\u59cb\u8d44\u6599\uff1ak [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u5c1d\u8bd5\u8fdb\u884c-ksqldb-\u5feb\u901f\u5165\u95e8\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-06-12T05:31:46+00:00","article_modified_time":"2024-04-29T10:31:02+00:00","author":"\u79d1, \u9896","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u9896","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/","name":"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-06-12T05:31:46+00:00","dateModified":"2024-04-29T10:31:02+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u5c1d\u8bd5\u8fdb\u884c ksqlDB \u5feb\u901f\u5165\u95e8"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/8ca01ba7f7362ad4edb7da206a12f29e","name":"\u79d1, \u9896","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8a6fb3cc7ba2f69d2189ba532aec4633ea7ed75ac0af162ec367cb3abc0fb2af?s=96&d=mm&r=g","caption":"\u79d1, \u9896"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keying\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e5%b0%9d%e8%af%95%e8%bf%9b%e8%a1%8c-ksqldb-%e5%bf%ab%e9%80%9f%e5%85%a5%e9%97%a8%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/47005","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=47005"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/47005\/revisions"}],"predecessor-version":[{"id":86921,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/47005\/revisions\/86921"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=47005"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=47005"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=47005"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}