{"id":1466,"date":"2022-06-19T01:31:53","date_gmt":"2022-06-18T17:31:53","guid":{"rendered":"http:\/\/www.eait.co\/?p=1466"},"modified":"2022-06-19T01:31:53","modified_gmt":"2022-06-18T17:31:53","slug":"spark%e8%a1%a8%e7%bc%93%e5%ad%98","status":"publish","type":"post","link":"https:\/\/notes.coremix.net\/?p=1466","title":{"rendered":"spark\u8868\u7f13\u5b58"},"content":{"rendered":"<p>\u5b9e\u6d4b\u53ef\u4ee5\u4ece1s\u964d\u4f4e\u523076ms<\/p>\n<p>scala&gt; val df1 = spark.read.json(&#8220;\/testdata\/emp.json&#8221;) \/\/\u9700\u8981\u4e0a\u4f20\u5230hdfs<br \/>\ndf1: org.apache.spark.sql.DataFrame = [comm: string, deptno: bigint &#8230; 6 more fields]<\/p>\n<p>scala&gt; df1.registerTempTable(&#8220;emp&#8221;)<br \/>\nwarning: there was one deprecation warning; re-run with -deprecation for details<\/p>\n<p>scala&gt; spark.sql(&#8220;select * from emp&#8221;).show<\/p>\n<p><span style=\"color: #ff0000;\">\/\/\u6807\u8bb0\u7f13\u5b58\u67d0\u5f20\u8868<\/span><br \/>\n<span style=\"color: #ff0000;\">scala&gt; spark.sqlContext.cacheTable(&#8220;emp&#8221;)<\/span><\/p>\n<p><span style=\"color: #ff0000;\">\/\/\u6e05\u7406\u6240\u6709\u7684\u7f13\u5b58<\/span><br \/>\n<span style=\"color: #ff0000;\">scala&gt; spark.sqlContext.clearCache<\/span><br \/>\n<span style=\"color: #ff0000;\">\/\/\u6e05\u7406\u67d0\u5f20\u8868<\/span><br \/>\n<span style=\"color: #ff0000;\">scala&gt; spark.sqlContext.uncacheTable(&#8220;emp&#8221;)<\/span><\/p>\n<p>scala&gt; spark.sql(&#8220;select * from emp&#8221;).show<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b9e\u6d4b\u53ef\u4ee5\u4ece1s\u964d\u4f4e\u523076ms scala&gt; val df1 = spark.read.json(&#038;#82 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1466","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1466","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1466"}],"version-history":[{"count":2,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1466\/revisions"}],"predecessor-version":[{"id":1468,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=\/wp\/v2\/posts\/1466\/revisions\/1468"}],"wp:attachment":[{"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/notes.coremix.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}