{"id":354632,"date":"2024-05-20T22:52:19","date_gmt":"2024-05-20T22:52:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=354632"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=354632","title":{"rendered":"<span>\u0421\u0442\u0430\u0439\u043b\u0433\u0430\u0439\u0434 PySpark: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u0434 \u044d\u043b\u0435\u0433\u0430\u043d\u0442\u043d\u044b\u043c<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tp\/7z\/od\/tp7zods6_pi2nwem0m_uwn8divo.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tp\/7z\/od\/tp7zods6_pi2nwem0m_uwn8divo.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 VK Cloud \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 PySpark. \u041e\u043d\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448 \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e<\/h2>\n<p>  \u042d\u0442\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043d\u0435 \u0437\u0430\u0433\u0440\u044f\u0437\u043d\u044f\u0442\u044c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0438\u043c\u0435\u043d \u0438 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0438\u0437 \u0440\u0430\u0437\u043d\u044b\u0445 \u043f\u0430\u043a\u0435\u0442\u043e\u0432.<\/p>\n<pre><code class=\"python\">from pyspark.sql import functions as F from pyspark.sql import types as T <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0420\u0435\u0444\u0440\u0430\u043a\u0442\u043e\u0440\u044c\u0442\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438<\/h2>\n<p>  \u0412 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445 \u0442\u0440\u0443\u0434\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f. \u041b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0433\u0440\u0443\u043f\u043f\u044b \u0438 \u043f\u043e\u0442\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c.<\/p>\n<pre><code class=\"python\"># Bad F.when( (F.col('prod_status') == 'Delivered') | (((F.datediff('deliveryDate_actual', 'current_date') &lt; 0) &amp; ((F.col('currentRegistration') != '') | ((F.datediff('deliveryDate_actual', 'current_date') &lt; 0) &amp; ((F.col('originalOperator') != '') | (F.col('currentOperator') != '')))))), 'In Service')  # Good has_operator = ((F.col('originalOperator') != '') | (F.col('currentOperator') != '')) delivery_date_passed = (F.datediff('deliveryDate_actual', 'current_date') &lt; 0) has_registration = (F.col('currentRegistration').rlike('.+')) is_delivered = (F.col('prod_status') == 'Delivered') is_active = (has_registration | has_operator)  F.when(is_delivered | (delivery_date_passed &amp; is_active), 'In Service') <\/code><\/pre>\n<p>  \u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0432\u044b\u0448\u0435 \u043c\u044b \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0432 \u0435\u0434\u0438\u043d\u043e\u0435 \u0446\u0435\u043b\u043e\u0435. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u043c\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0442\u0434\u0435\u043b\u0438\u043b\u0438 \u0434\u0440\u0443\u0433 \u043e\u0442 \u0434\u0440\u0443\u0433\u0430 \u0438 \u043f\u043e\u0442\u043e\u043c \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u043b\u0438 \u0441\u0442\u0430\u0442\u0443\u0441 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438, \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e, \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u00a0<code>F.when<\/code>\u00a0\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043b\u0430\u043a\u043e\u043d\u0438\u0447\u043d\u044b\u043c.<\/p>\n<h2>\u041e\u0442\u043a\u0430\u0436\u0438\u0442\u0435\u0441\u044c \u043e\u0442 withColumnRenamed<\/h2>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 alias, \u0430 \u043d\u0435 <code>withColumnRenamed<\/code>.<\/p>\n<pre><code class=\"python\">#bad df.select('key', 'comments').withColumnRenamed('comments', 'num_comments')  # good df.select('key', F.col('comments').alias('num_comments')) <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041e\u0442\u043a\u0430\u0436\u0438\u0442\u0435\u0441\u044c \u043e\u0442 withColumn<\/h2>\n<p>  \u0412 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0434\u043b\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0442\u0438\u043f\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u0435\u0442\u043e\u0434\u0430 <code>withColumn<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>select<\/code>, \u0430 \u043f\u043e\u0442\u043e\u043c <code>cast<\/code>.<\/p>\n<pre><code class=\"python\"># bad df.select('comments').withColumn('comments', F.col('comments').cast('double'))  # good df.select(F.col('comments').cast('double')) <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 lit(None)<\/h2>\n<p>  \u041b\u0443\u0447\u0448\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>None<\/code>, \u0447\u0435\u043c \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u0435 \u043f\u0443\u0441\u0442\u044b\u043c \u0438\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c <code>NA<\/code>. \u0422\u043e\u0433\u0434\u0430 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0432\u0440\u043e\u0434\u0435 <code>isNull<\/code> \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439,\u00a0<code>'NA'<\/code>\u00a0\u0438 \u0442. \u043f.<\/p>\n<pre><code class=\"python\"># bad df = df.withColumn('foo', F.lit('')) df = df.withColumn('foo', F.lit('NA'))  # good df = df.withColumn('foo', F.lit(None)) <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u044f\u0432\u043d\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 join<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\"># bad flights = flights.join(aircraft, 'aircraft_id') flights = flights.join(aircraft, 'aircraft_id', 'inner')  # good flights = flights.join(aircraft, 'aircraft_id', how='inner') <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 right-\u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 join<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\"># bad flights = aircraft.join(flights, 'aircraft_id', how='right')  # good flights = flights.join(aircraft, 'aircraft_id', how='left') <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0420\u0430\u0437\u0431\u0435\u0440\u0438\u0442\u0435\u0441\u044c \u0441 \u043f\u043e\u0445\u043e\u0436\u0438\u043c\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\">import pyspark.pandas as ps psdf = ps.DataFrame({'a': [1, 2], 'A':[3, 4]}) psdf.columns = [\"a\", \"a\"]  Reference 'a' is ambiguous, could be: a, a. <\/code><\/pre>\n<p>  <\/p>\n<ul>\n<li>\u041f\u0440\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435\u0441\u044c \u043e\u0442 \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0435\u0441\u043b\u0438 \u0432 DF \u0435\u0441\u0442\u044c \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438.  <\/li>\n<li>\u0415\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u044b \u043e\u0431\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u0430, \u043b\u0443\u0447\u0448\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0438\u0445 \u0434\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f.  <\/li>\n<li>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043d\u044b\u043c\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430. \u041f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u044b \u0443\u0436\u0435 \u043d\u0435 \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u0438\u0442\u044c.  <\/li>\n<li>\u0410 \u0435\u0449\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u0430 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432, \u0447\u0443\u0432\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043a \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443.  <\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u0440\u0443\u0433\u043b\u044b\u0435 \u0441\u043a\u043e\u0431\u043a\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \\ (\u044f\u0432\u043d\u044b\u0445 \u0440\u0430\u0437\u0440\u044b\u0432\u043e\u0432 \u0441\u0442\u0440\u043e\u043a\u0438)<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\"># bad df = df.filter(F.col('event') == 'executing')\\ \u00a0 \u00a0 .filter(F.col('has_tests') == True)\\ \u00a0 \u00a0 .drop('has_tests')  # good df = ( \u00a0 df \u00a0 .filter(F.col('event') == 'executing') \u00a0 .filter(F.col('has_tests') == True) \u00a0 .drop('has_tests') ) <\/code><\/pre>\n<p>  <\/p>\n<h2>\u041d\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0439\u0442\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0437\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\"># bad df = ( \u00a0 \u00a0 df \u00a0 \u00a0 .select('a', 'b', 'c', 'key') \u00a0 \u00a0 .filter(F.col('a') == 'truthiness') \u00a0 \u00a0 .withColumn('boverc', F.col('b') \/ F.col('c')) \u00a0 \u00a0 .join(df2, 'key', how='inner') \u00a0 \u00a0 .join(df3, 'key', how='left') \u00a0 \u00a0 .drop('c') )  # better (separating into steps) # first: we select and trim down the data that we need # second: we create the columns that we need to have # third: joining with other dataframes  df = ( \u00a0 \u00a0 df \u00a0 \u00a0 .select('a', 'b', 'c', 'key') \u00a0 \u00a0 .filter(F.col('a') == 'truthiness') )  df = df.withColumn('boverc', F.col('b') \/ F.col('c'))  df = ( \u00a0 \u00a0 df \u00a0 \u00a0 .join(df2, 'key', how='inner') \u00a0 \u00a0 .join(df3, 'key', how='left') \u00a0 \u00a0 .drop('c') ) <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0417\u0430\u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u0443\u043f\u043e\u0440\u044f\u0434\u043e\u0447\u0438\u0432\u0430\u043d\u0438\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 Null<\/h2>\n<p>  <\/p>\n<pre><code class=\"python\">ignorenulls=True F.asc_nulls_last('num') <\/code><\/pre>\n<p>  <\/p>\n<h2>\u0418\u0437\u0431\u0435\u0433\u0430\u0439\u0442\u0435 \u043f\u0443\u0441\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 PartitionBy<\/h2>\n<p>  \u041d\u0435 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u0445 \u043e\u043a\u043e\u043d, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0438\u0437-\u0437\u0430 \u043d\u0438\u0445 Spark \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u0434\u043d\u0443 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e \u0438 \u044d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0447\u0440\u0435\u0437\u0432\u044b\u0447\u0430\u0439\u043d\u043e \u0441\u043d\u0438\u0437\u0438\u0442\u044c \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c.<\/p>\n<pre><code class=\"python\"># bad w = W.partitionBy() df = df.select(F.sum('num').over(w).alias('sum'))  # good df = df.agg(F.sum('num').alias('sum')) &lt;h2>\u041e\u043a\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f |. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043b\u0438\u0431\u043e \u0444\u0440\u0435\u0439\u043c\u044b row, \u043b\u0438\u0431\u043e \u0444\u0440\u0435\u0439\u043c\u044b range&lt;\/h2> # bad w1 = W.partitionBy('key') w2 = W.partitionBy('key').orderBy('num')  # good w1 = W.partitionBy('key').orderBy('num').rowsBetween(W.unboundedPreceding, 0) w2 = W.partitionBy('key').orderBy('num').rowsBetween(W.unboundedPreceding, W.unboundedFollowing) <\/code><\/pre>\n<p>  <\/p>\n<h2>Select \u0434\u043b\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u044f \u0441\u0445\u0435\u043c\u044b<\/h2>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 Select \u043a\u0430\u043a \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d:<\/p>\n<ul>\n<li>\u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f,  <\/li>\n<li>\u043f\u0435\u0440\u0435\u0434 \u0432\u044b\u0432\u043e\u0434\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430.  <\/li>\n<\/ul>\n<p>  <\/p>\n<h2>\u0414\u0440\u0443\u0433\u0438\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438<\/h2>\n<p>  <\/p>\n<ol>\n<li>\u041d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u0439\u0442\u0435 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u044b\u0435 \u0438\u043b\u0438 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0442\u043e\u043b\u0431\u0446\u044b \u0432 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e <code>select<\/code>.  <\/li>\n<li>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043b\u0438\u0442\u0435\u0440\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043b\u0438 \u0446\u0435\u043b\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0443\u0441\u043b\u043e\u0432\u0438\u044f\u0445 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u0432 \u043d\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 \u0438 \u0442. \u043f. \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0441\u0432\u043e\u0439\u0442\u0435 \u0438\u0445 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439.  <\/li>\n<li>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u043e \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u0441\u0435\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <code>df.cache.count()<\/code>. \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 <code>unpersist<\/code>.  <\/li>\n<li>\u041f\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0446\u0438\u043a\u043b\u044b \u0434\u043b\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432.  <\/li>\n<li>\u041e\u0442\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 Spark \u043e\u0442 \u043a\u043e\u0434\u0430.  <\/li>\n<li>\u041e\u0442\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044e Spark Job \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0430\u0439\u043b\u0430 .ini.  <\/li>\n<li>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 <code>JobContext<\/code>, \u0447\u0442\u043e\u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u0430\u043a\u043a\u0443\u043c\u0443\u043b\u044f\u0442\u043e\u0440\u044b, \u0441\u0447\u0435\u0442\u0447\u0438\u043a\u0438, \u043e\u0431\u0449\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0442. \u043f.  <\/li>\n<li>\u041e\u0442\u0434\u0435\u043b\u044f\u0439\u0442\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043b\u044e\u0431\u043e\u0439 \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0438\u043b\u0438 \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0438.  <\/li>\n<li>\u041d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>print<\/code> \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043b\u043e\u0433\u0438 \u0438 \u043b\u043e\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435.  <\/li>\n<\/ol>\n<blockquote><p>\u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0448\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 \u0433\u043e\u0442\u043e\u0432\u0438\u0442 \u043a \u0440\u0435\u043b\u0438\u0437\u0443 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 Spark \u0432 K8s, \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0439\u0442\u0435\u0441\u044c \u043d\u0430 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b <a href=\"https:\/\/t.me\/+mRmjbHoS0qoxMDAy\">\u00ab\u0414\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0441\u0442\u0435\u0440\u043e\u0438\u0434\u0430\u0445\u00bb<\/a>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0430\u043d\u043e\u043d\u0441!<\/p><\/blockquote>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/760416\/\"> https:\/\/habr.com\/ru\/articles\/760416\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/tp\/7z\/od\/tp7zods6_pi2nwem0m_uwn8divo.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/tp\/7z\/od\/tp7zods6_pi2nwem0m_uwn8divo.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u0430 VK Cloud \u043f\u0435\u0440\u0435\u0432\u0435\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044e \u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u0445 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0432 PySpark. \u041e\u043d\u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f, \u043d\u043e \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0430\u0448 \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c \u0438 \u0443\u0434\u043e\u0431\u043d\u044b\u043c \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-354632","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354632","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=354632"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/354632\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=354632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=354632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=354632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}