{"id":301559,"date":"2020-04-09T09:00:24","date_gmt":"2020-04-09T09:00:24","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=301559"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-04-09T09:00:24","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=301559","title":{"rendered":"\u041f\u0440\u0430\u043a\u0442\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Spark SQL \u0438\u043b\u0438 \u043a\u0430\u043a \u043d\u0435 \u043d\u0430\u0441\u0442\u0443\u043f\u0438\u0442\u044c \u043d\u0430 \u0433\u0440\u0430\u0431\u043b\u0438"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/sberbank\/blog\/496310\/\">\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 SQL, \u0442\u043e \u0432\u0430\u043c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u043a\u043e\u0440\u043e. Apache Spark \u2013 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443 Hadoop, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Spark SQL, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u0434 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. Spark SQL \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439. <\/p>\n<p>  \u041d\u0438\u0436\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e Spark SQL:<\/p>\n<ul>\n<li>\u041a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0445\u0438\u043d\u0442\u043e\u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/li>\n<li>\u041a\u0430\u043a, \u043e\u0441\u0442\u0430\u0432\u0430\u044f\u0441\u044c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 SQL, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c \u0441 \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (skewed joins).<\/li>\n<li>\u041a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c broadcast join \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0435\u0441\u043b\u0438 \u0435\u0451 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0432\u0435\u043b\u0438\u043a.<\/li>\n<li>\u041a\u0430\u043a \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Spark SQL \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Spark \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u044f\u0434\u0435\u0440 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0432 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u043a\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a><\/p>\n<p>  \u0421\u0435\u0439\u0447\u0430\u0441 \u043d\u0430 \u0440\u044b\u043d\u043a\u0435 \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u043e\u0432 \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432, \u0432\u043b\u0430\u0434\u0435\u044e\u0449\u0438\u0445 SQL. \u042d\u0442\u043e \u044f\u0437\u044b\u043a, \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0439 \u0432\u0441\u0435\u043c \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0410\u043d\u0430\u043b\u0438\u0442\u0438\u043a \u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u0442, \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u043a\u0430\u043a\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0443\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u0431\u0438\u0432\u0430\u0435\u0442 \u043d\u0430 \u044d\u0442\u0430\u043f\u044b \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u0432\u0448\u0438\u0435 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u0437\u0430\u0442\u0435\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0438\u0437 \u043d\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u0438 ETL \u043f\u043e \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0421 \u0440\u043e\u0441\u0442\u043e\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0431\u0438\u0437\u043d\u0435\u0441\u0430 \u044d\u043f\u043e\u0445\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u0441\u0442\u0440\u043e\u043a \u0441\u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u044d\u043f\u043e\u0445\u043e\u0439 \u043e\u0437\u0451\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u044b \u0441\u0442\u0440\u043e\u043a. \u0411\u0438\u0437\u043d\u0435\u0441 \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442 \u0441\u0432\u043e\u0438 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0438 \u0441\u0442\u0430\u0432\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0438 \u043f\u043e \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0443 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0432 \u043e\u0431\u043b\u0430\u043a\u0430. \u0422\u0430\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0436\u0434\u0443\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 machine learning \u0438 data science. ETL-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043f\u0435\u0440\u0435\u043a\u0432\u0430\u043b\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u0434\u0430\u0442\u0430-\u0438\u043d\u0436\u0435\u043d\u0435\u0440\u043e\u0432 \u0438 \u0441\u0430\u043c\u044b\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0443\u0442\u044c \u0434\u043b\u044f \u043d\u0438\u0445 \u2013 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0437\u043d\u0430\u043a\u043e\u043c\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 SQL, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u043e\u0449\u043d\u043e\u0441\u0442\u0438 Spark, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043c\u0438\u043b\u043b\u0438\u0430\u0440\u0434\u044b \u0441\u0442\u0440\u043e\u043a \u0432 \u043e\u0437\u0435\u0440\u043e \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430 \u0432\u0445\u043e\u0434\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0441\u043e\u0442\u043d\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0443\u0436\u043d\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u0431\u043b\u0430\u0447\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043c\u0435\u0442\u043e\u0434 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Spark SQL, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0441\u0438\u043b\u0430\u043c\u0438 \u0441\u0430\u043c\u043e\u0433\u043e SQL \u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043f\u0440\u0438\u0435\u043c\u043b\u0435\u043c\u043e\u0439 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043f\u0440\u0438\u0431\u0435\u0433\u0430\u0442\u044c \u043a \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043d\u0430 Spark.<\/p>\n<p>  Spark SQL \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043c\u043d\u043e\u0433\u0438\u043c \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u044f\u043c \u0438\u0437 Global 100. \u041f\u0440\u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 Spark SQL \u0434\u0430\u0451\u0442 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0432\u044b\u0441\u043e\u043a\u0443\u044e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e. Spark SQL \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 ETL \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u0445 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430\u043c\u0438 Spark SQL \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0437\u0432\u0430\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Impala SQL \u0438\u043b\u0438 Hive (c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 mapreduce). \u0415\u0441\u043b\u0438 \u0436\u0435 \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 SQL, \u0442\u043e \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u2013 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 Spark \u044f\u0437\u044b\u043a\u0430 DSL. \u041d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u043e\u043c\u043d\u0435\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u044f\u0437\u044b\u043a\u0430 SQL, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u0435\u0441\u044f\u0442\u0438\u043b\u0435\u0442\u0438\u044f \u0438 \u0438\u043c\u0435\u044e\u0449\u0435\u0433\u043e \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439. \u041d\u0435\u043c\u0430\u043b\u044b\u0435 \u043f\u0435\u0440\u0441\u043f\u0435\u043a\u0442\u0438\u0432\u044b \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0438 Spark SQL. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 \u043d\u043e\u0432\u044b\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u044f\u043c\u0438 Spark \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0435 \u0445\u0438\u043d\u0442\u044b, \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435. Spark \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0442 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a \u0432\u0435\u0440\u0441\u0438\u0438 \u0432 \u043f\u043e\u0433\u043e\u043d\u0435 \u0437\u0430 \u043f\u043e\u0432\u044b\u0448\u0435\u043d\u0438\u0435\u043c \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0435\u0439 \u0441 DeepLearning. \u041c\u0435\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u044b: RDD, DataFrame, DataSet. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c, \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 Spark SQL \u2013 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e \u0438 \u043c\u043d\u043e\u0433\u043e\u043e\u0431\u0435\u0449\u0430\u044e\u0449\u0435. \u0414\u043b\u044f \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0439 \u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Spark SQL \u0432\u0435\u0434\u0451\u0442 \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043a \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u0438\u044e \u0437\u043d\u0430\u043d\u0438\u0439 \u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u0445, \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0438 \u043d\u043e\u0432\u044b\u0445 \u0431\u0438\u0437\u043d\u0435\u0441\u043e\u0432 \u043d\u0430 \u043d\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u043d\u0438\u044f\u0445.<\/p>\n<p>  \u0414\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u043d\u043a\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c Spark \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u0439\u0442\u0438 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 Spark SQL \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, DSL.<\/p>\n<p>  \u0423\u0442\u043e\u0447\u043d\u0438\u043c, \u0447\u0442\u043e \u0440\u0435\u0447\u044c \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u0438\u0434\u0451\u0442 \u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 Apache Spark 2.3, \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 Hadoop \u0432 Hadoop, \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c Yarn, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 Linux, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0421\u0423\u0411\u0414 Hive \u0441 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 hdfs \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 parquet.<\/p>\n<p>  \u041a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u044e\u0449\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0435\u043c\u0443 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 SQL \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c, \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043b\u0438\u0448\u044c, \u0447\u0442\u043e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043d\u0443\u0436\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e sqlStr \u0438 \u0432\u044b\u0437\u0432\u0430\u0442\u044c: <\/p>\n<pre><code class=\"java\">SparkSession spark = SparkSession         .builder()         .appName(&quot;&quot;)         .enableHiveSupport()         .getOrCreate(); Dataset&lt;Row&gt; sql = spark.sql(sqlStr);<\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 *.jar, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 SQL \u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c spark-submit:<\/p>\n<pre><code class=\"plaintext\">spark-submit --class &lt;\u2026sqlrunner&gt; --name &lt;taskname&gt; --queue &lt;yarnqueue&gt; --executor-cores 1 --executor-memory 1g --driver-cores 1 --driver-memory 1g --num-executors 1 --master yarn --deploy-mode cluster &lt;hdfs:\/\/\u2026sqlrunner.jar&gt; sqlFile=&lt;\u2026sql&gt;;<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u043e\u043c \u0444\u0430\u0439\u043b\u0435 sqlFile \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b SQL, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"sql\">insert overwrite table target_scheme.target_table select s.* from source_scheme.source_table s;<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0421\u0431\u043e\u0440 \u0438 \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0434\u043b\u044f Spark, \u0445\u0438\u043d\u0442 BROADCAST<\/h3>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0434\u043b\u044f Spark \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 (join) \u0442\u0430\u0431\u043b\u0438\u0446 \u0438\u043b\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 Spark \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 join-\u043e\u0432: SortMergeJoin, BroadcastHashJoin, CartesianProduct \u0438 \u0434\u0440. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u043e\u0447\u044c Spark \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u043d\u044f\u0442\u044c, \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u0438\u043b\u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043e\u043d \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u0438 \u043a\u0430\u043a\u043e\u0439 \u0442\u0438\u043f \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u0435\u043d, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u044d\u0442\u0438\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c spark-submit \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"sql\">ANALYZE TABLE scheme_name.table_name COMPUTE STATISTICS;<\/code><\/pre>\n<p>  \u042d\u0442\u0443 \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u043c\u043e\u0434\u0443\u043b\u044e sqlrunner.jar \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u044b SQL. \u0414\u043b\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0447\u0442\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u043f\u0438\u0441\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u0430, \u043c\u043e\u0436\u043d\u043e \u0432 \u0441\u0440\u0435\u0434\u0435 hive \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432\u0438\u0434\u0430:<\/p>\n<pre><code class=\"sql\">show create table scheme_name.table_name;<\/code><\/pre>\n<p>  \u041d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c, \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043b\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432 \u0431\u043b\u043e\u043a\u0435 TBLPROPERTIES \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 &#8216;spark.sql.statistics.numRows&#8217; \u0438 &#8216;spark.sql.statistics.totalSize&#8217;:<\/p>\n<pre><code class=\"sql\">CREATE EXTERNAL TABLE `scheme_name.table_name`( \u2026 TBLPROPERTIES ( \u2026   'spark.sql.statistics.numRows'='363852167',    'spark.sql.statistics.totalSize'='82589603650',  \u2026<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u0438\u043c\u0435\u0442\u044c \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u0443\u044e \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430\u043c, \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u043c \u0432 \u0440\u0430\u0441\u0447\u0451\u0442\u0430\u0445 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043f\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0432\u0438\u0442\u0440\u0438\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u043e\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u044b \u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f\u0445 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u0430\u0436\u0435\u043c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 broadcast \u0432 Spark. \u041f\u0440\u0438 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a \u0431\u043e\u043b\u044c\u0448\u043e\u043c\u0443 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0443 \u0447\u0430\u0441\u0442\u043e \u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u044b\u043c \u043d\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043d\u0430 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043d\u043e\u0434\u044b \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432 \u0432\u0438\u0434\u0435 \u043f\u043e\u0440\u0446\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0435\u0451 \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u043d\u0430 \u0432\u0441\u0435 \u043d\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0438\u0435\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f broadcast \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0430 \u0432\u0441\u0435 \u043d\u043e\u0434\u044b \u0438 \u0442\u0438\u043f \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043a \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c\u0443 \u043c\u0430\u0441\u0441\u0438\u0432\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u2013 broadcast join.<\/p>\n<p>  \u0417\u0430\u0447\u0430\u0441\u0442\u0443\u044e, broadcast join \u043d\u0443\u0436\u0435\u043d \u0432 Spark SQL \u0432 \u0442\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0431\u0430\u0437\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f nested loop join. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c broadcast \u043f\u0440\u0438 \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0432 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043a\u043b\u044e\u0447\u0430\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0433\u043e \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a\u0430 \u0432\u0430\u043b\u044e\u0442 \u043a \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u043f\u0440\u043e\u0432\u043e\u0434\u043e\u043a, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 99% \u0441\u0442\u0440\u043e\u043a \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u0440\u0443\u0431\u043b\u044f\u043c.<\/p>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043a\u0430\u0437\u0430\u0442\u044c Spark, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c broadcast \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043b\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 (\u0434\u043e ~1Gb), \u043c\u043e\u0436\u043d\u043e \u0432 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u0445\u0438\u043d\u0442 \/*+ BROADCAST(t)*\/, \u0433\u0434\u0435 t \u2013 \u0430\u043b\u0438\u0430\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0438\u043b\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430.<\/p>\n<pre><code class=\"sql\">insert overwrite table target_scheme.target_table select \/*+ BROADCAST(t) *\/ big.field1,        big.field2,        t.field3   from source_scheme.big_table as big   left join source_scheme.small_table as t     on big.field1 = t.field1;<\/code><\/pre>\n<p>  \u0412 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0435\u0441\u043b\u0438 \u043f\u043e \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043d\u0435 \u0441\u043e\u0431\u0440\u0430\u043d\u0430 \u0438\u043b\u0438 \u043c\u044b \u0438\u043c\u0435\u0435\u043c \u0434\u0435\u043b\u043e \u0441 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u201c\u043d\u0430 \u043b\u0435\u0442\u0443\u201d \u0438 Spark \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043b\u0438 \u043e\u043d, \u0442\u043e \u0445\u0438\u043d\u0442 \/*+ BROADCAST(t)*\/ \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u0435\u043d, \u0435\u0441\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u043b\u0438 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043c\u0430\u043b\u043e \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>  \u0415\u0441\u043b\u0438 broadcast \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0437\u0436\u0435 \u0447\u0435\u043c, \u0447\u0435\u0440\u0435\u0437 5 \u043c\u0438\u043d\u0443\u0442 \u0441 \u043d\u0430\u0447\u0430\u043b\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c spark-submit \u0441 \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c (\u0437\u0434\u0435\u0441\u044c 36000 \u2013 \u0432\u0440\u0435\u043c\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445), \u043f\u043e\u0442\u043e\u043c\u0443 \u043a\u0430\u043a \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 5 \u043c\u0438\u043d\u0443\u0442 \u043c\u043e\u0436\u0435\u0442 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442\u044c:<\/p>\n<pre><code class=\"plaintext\">--conf spark.sql.broadcastTimeout=36000<\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a\u043e\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435, \u0433\u0434\u0435 \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f broadcast \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \/*+ BROADCAST(small) *\/, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0433\u043e\u0442\u043e\u0432 \u043d\u0435 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0440\u0430\u0431\u043e\u0442\u044b \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0430 \u043d\u0430 \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u0437\u0434\u043d\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445:<\/p>\n<pre><code class=\"sql\">select \/*+ BROADCAST(small) *\/  big.field3, small.field1, small.field2   from source_scheme.big_table as big  inner join (select t1.field1, t2.field2                from source_scheme.table1 as t1               inner join source_scheme.table2 as t2                  on t1.field1 = t2.field1) small     on big.field2 = small.field2;<\/code><\/pre>\n<p>  \u0423\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0445\u0438\u043d\u0442 \u0443\u0447\u0442\u0451\u043d \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u0438 broadcast \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0451\u043d \u043c\u043e\u0436\u043d\u043e, \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0432 Yarn \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 Tracking UI \u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spark \u043f\u043b\u0430\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u0437\u0430\u043a\u043b\u0430\u0434\u043a\u0435 SQL:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cs\/iw\/rd\/csiwrd4ya3wh0so0r7cversdjl0.png\"><\/p>\n<p>  \u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0432 Spark SQL \u0435\u0441\u0442\u044c \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0445\u0438\u043d\u0442\u044b, \u0432 \u0442.\u0447. \u0441 \u0432\u0435\u0440\u0441\u0438\u0438 2.4 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0445\u0438\u043d\u0442\u044b \/*+ COALESCE(n) *\/, \u0433\u0434\u0435 n \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0438 \/* + REPARTITION (n) *\/, \u0433\u0434\u0435 n \u2013 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043f\u0440\u0438 repartition.<\/p>\n<h3>\u041e\u0431\u0445\u043e\u0434 SKEWED JOIN \u044f\u0432\u043d\u044b\u043c \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c SKEWED \u043a\u043b\u044e\u0447\u0435\u0439<\/h3>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0432\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b:<\/p>\n<ul>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 A, \u0438\u043c\u0435\u044e\u0449\u0430\u044f \u043f\u043e\u043b\u0435 AID<\/li>\n<li>\u0422\u0430\u0431\u043b\u0438\u0446\u0430 B, \u0438\u043c\u0435\u044e\u0449\u0430\u044f \u043f\u043e\u043b\u0435 BID<\/li>\n<\/ul>\n<p>  \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c A.AID = B.BID:<\/p>\n<pre><code class=\"sql\">select A.*, B.* from A inner join B on A.AID = B.BID;<\/code><\/pre>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446, \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e.<\/p>\n<p>  \u041f\u0443\u0441\u0442\u044c \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 B \u043d\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 BID 4089, 4107, 4468 \u0438 6802 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0441\u0443\u043c\u043c\u0435 70% \u0441\u0442\u0440\u043e\u043a, \u0432 \u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043a\u0430\u043a \u043d\u0430 \u043c\u0438\u043b\u043b\u0438\u043e\u043d \u043f\u0440\u043e\u0447\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043b\u044e\u0447\u0435\u0439 BID \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438\u0448\u044c \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f 30% \u0441\u0442\u0440\u043e\u043a.<\/p>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 A \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 AID \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f 4089, 4107, 4468 \u0438 6802 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u044e\u0442\u0441\u044f \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0440\u0430\u0437\u0443.<\/p>\n<p>  \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f skewed join, \u0442.\u0435. \u201c\u043f\u0435\u0440\u0435\u043a\u043e\u0448\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435\u201d, \u0430 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0447\u0430\u0441\u0442\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f skewed keys.<\/p>\n<p>  \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0437\u0430\u0434\u0430\u0447\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0442\u0430\u0431\u043b\u0438\u0446, \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c spark-submit, \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0431\u0438\u0442\u0430 \u043d\u0430 200 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439. \u0418\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u044d\u0442\u0443 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u043d\u043e, \u0437\u0430\u0434\u0430\u0432 \u0434\u0440\u0443\u0433\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 spark.sql.shuffle.partitions, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"plaintext\">--conf spark.sql.shuffle.partitions=1000<\/code><\/pre>\n<p>  \u041a\u0430\u043a Spark \u0431\u0443\u0434\u0435\u0442 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c skewed join?<\/p>\n<p>  Spark \u0431\u0435\u0437 \u043f\u043e\u0434\u0441\u043a\u0430\u0437\u043a\u0438 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e, \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0442\u0430\u0431\u043b\u0438\u0446 \u0442\u0430\u043a: \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043b\u044e\u0447\u0435\u0439 \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u201c\u043b\u0451\u0433\u043a\u0438\u0435\u201d \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043e\u0431\u044a\u0451\u043c \u0434\u0430\u043d\u043d\u044b\u0445; \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 skewed keys \u043f\u043e\u043f\u0430\u0434\u0451\u0442 \u0432 \u201c\u0442\u044f\u0436\u0451\u043b\u044b\u0435\u201d \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438.<\/p>\n<p>  \u041a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043d\u0438\u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0430\u043a\u043e\u0433\u043e \u0441\u043b\u0443\u0447\u0430\u044f: 999 \u0438\u0437 1000 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0431\u044b\u0441\u0442\u0440\u043e, \u0432\u044b\u0434\u0430\u0432 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0430 \u043e\u0434\u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043f\u043e\u043f\u0430\u043b\u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0447\u0430\u0441\u043e\u0432.<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/l0\/l7\/ya\/l0l7ya40dzuv05i8rytaqgr2gc4.png\"><br \/>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/j_\/we\/vm\/j_wevm3rpbgjjq2ie8g1fkp1prq.png\"><\/p>\n<p>  \u041a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f\u043c \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c?<\/p>\n<p>  \u041a\u0430\u043a \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043d\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 A.AID = B.BID, \u0430 \u043f\u043e \u043f\u0430\u0440\u0435 \u043a\u043b\u044e\u0447\u0435\u0439, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043f\u0430\u0440\u0435 \u043a\u043b\u044e\u0447\u0435\u0439 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c.<\/p>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 B \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0442\u0430\u043a\u0436\u0435 \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 BID2, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u044b \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e (\u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 BID). \u0415\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u043e\u0433\u043e \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0447\u0438\u0441\u043b\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u043d\u0435\u0442, \u0442\u043e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0435\u0439 \u0432 hive \u0438 spark \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 hash() \u0438\u0437 \u043a\u043e\u043d\u043a\u0430\u0442\u0435\u043d\u0430\u0446\u0438\u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u043b\u0435\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f hash() \u0432\u044b\u0434\u0430\u0441\u0442 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  \u041d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043f\u043e\u0434 spark \u0437\u0430\u043f\u0440\u043e\u0441 \u0440\u0435\u0448\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0443. \u042d\u0442\u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441 \u0446\u0435\u043b\u0435\u0441\u043e\u043e\u0431\u0440\u0430\u0437\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u043e <i>\u201cselect A.*, B.* from A inner join B on A.AID = B.BID;\u201d<\/i><\/p>\n<p>  \u0412 \u0441\u0435\u043a\u0446\u0438\u0438 with \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f \u0442\u0430\u0431\u043b\u0438\u0446 A \u0438 B. \u0418\u043c\u0435\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u043a\u043e\u0448\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043a\u043b\u044e\u0447\u0435 BID. \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441 ANTISKEW, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043f\u0435\u0440\u0435\u043a\u043e\u0448\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u044e\u0447\u0435\u0439 4089, 4107, 4468 \u0438 6802 \u0440\u0430\u0437\u043c\u043d\u043e\u0436\u0435\u043d\u044b \u0434\u043e 10 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u0430\u0436\u0434\u043e\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0410 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0441 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c ANTISKEW, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 A_ \u0434\u043b\u044f \u043a\u043b\u044e\u0447\u0435\u0439 AID, \u0440\u0430\u0432\u043d\u044b\u0445 4089, 4107, 4468 \u0438 6802, \u043f\u043e 10 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0441 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 ANTISKEWKEY \u043e\u0442 0 \u0434\u043e 9. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0434\u043b\u044f \u043f\u0440\u043e\u0447\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 AID \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u0435 A_ \u0431\u0443\u0434\u0435\u0442 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0443 \u0441 ANTISKEWKEY = 0. \u0414\u0430\u043b\u0435\u0435 \u043c\u0430\u0441\u0441\u0438\u0432 A_ \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u0442\u0441\u044f \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 B \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e A_.AID = B.BID, \u043d\u043e \u0438 \u043f\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0440\u0435 \u043a\u043b\u044e\u0447\u0435\u0439. \u0410 \u0438\u043c\u0435\u043d\u043d\u043e, \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u043a\u043e\u0448\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043b\u044e\u0447\u0435\u0439 BID \u043c\u043d\u043e\u0433\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0438\u0437 \u0442\u0430\u0431\u043b\u0438\u0446\u044b B \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u0441\u044f \u0441 \u043e\u0434\u043d\u0438\u043c \u0438\u0437 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 ANTISKEWKEY \u043e\u0442 0 \u0434\u043e 9 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043e\u0441\u0442\u0430\u0442\u043a\u0430 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f BID2 \u043d\u0430 10. \u041d\u0435\u043f\u0435\u0440\u0435\u043a\u043e\u0448\u0435\u043d\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f BID \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0442\u0441\u044f \u043e\u0434\u0438\u043d \u043a \u043e\u0434\u043d\u043e\u043c\u0443 \u0441 ANTISKEWKEY = 0. \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0441\u0442\u0438\u0433\u043d\u0443\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043a\u043e\u0448\u0435\u043d\u043d\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 BID \u043f\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f\u043c \u2013 \u043e\u043d\u0438 \u043f\u043e\u0439\u0434\u0443\u0442 \u043d\u0435 \u0432 \u043e\u0434\u043d\u0443, \u0430 \u0432 10 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439.<\/p>\n<pre><code class=\"sql\">with A as (select 4089 AID union all select 4468 AID union all select 6802 AID union all            select    5 AID union all select    8 AID union all select   14 AID),      B as (select 4089 BID,  1 BID2 union all            select 4089 BID,  2 BID2 union all            select 4089 BID,  3 BID2 union all             select 4107 BID,  4 BID2 union all            select 4107 BID,  5 BID2 union all            select 4107 BID,  6 BID2 union all             select 4468 BID,  7 BID2 union all            select 4468 BID,  8 BID2 union all            select 4468 BID,  9 BID2 union all             select 6802 BID, 10 BID2 union all            select 6802 BID, 11 BID2 union all            select 6802 BID, 12 BID2 union all            select    1 BID, 13 BID2 union all            select    2 BID, 14 BID2 union all            select    3 BID, 15 BID2 union all            select    4 BID, 16 BID2 union all            select    5 BID, 17 BID2 union all            select    6 BID, 18 BID2 union all            select    7 BID, 19 BID2 union all            select    8 BID, 20 BID2 union all            select    9 BID, 21 BID2 union all            select   10 BID, 22 BID2 union all            select   11 BID, 23 BID2 union all            select   12 BID, 24 BID2 union all            select   13 BID, 25 BID2 union all            select   14 BID, 26 BID2 union all            select   15 BID, 27 BID2) select A_.*, B.*   from (select A.*, coalesce(ANTISKEW.ANTISKEWKEY, 0) ANTISKEWKEY           from A           left join (select Y.ID, Z.ANTISKEWKEY                       from (select 4089 ID union all                             select 4107 ID union all                             select 4468 ID union all                             select 6802 ID) Y                      cross join (select 0 ANTISKEWKEY union all                                  select 1 ANTISKEWKEY union all                                  select 2 ANTISKEWKEY union all                                  select 3 ANTISKEWKEY union all                                  select 4 ANTISKEWKEY union all                                  select 5 ANTISKEWKEY union all                                  select 6 ANTISKEWKEY union all                                  select 7 ANTISKEWKEY union all                                  select 8 ANTISKEWKEY union all                                  select 9 ANTISKEWKEY) Z) ANTISKEW             on A.AID = ANTISKEW.ID) A_  inner join B     on A_.AID = B.BID    and A_.ANTISKEWKEY = case when A_.AID in (4089, 4107, 4468, 6802) then B.BID2%10 else 0 end;<\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u0431\u0438\u0440\u0430\u0442\u044c \u0432 \u043f\u043e\u0434\u0437\u0430\u043f\u0440\u043e\u0441\u0435 ANTISKEW, \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u043a\u043b\u044e\u0447. \u041e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0437\u043d\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u2013 \u043f\u043e \u043a\u0430\u043a\u0438\u043c \u043f\u0435\u0440\u0435\u043a\u043e\u0448\u0435\u043d\u043d\u044b\u043c \u043a\u043b\u044e\u0447\u0430\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u043d\u0442\u043e\u0432 \u0441\u0442\u0440\u043e\u043a \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0436\u0438\u0434\u0430\u0442\u044c.<\/p>\n<h3>\u041f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c BROADCAST<\/h3>\n<p>  \u041d\u0438\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043d \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u0432 Spark SQL \u0434\u0435\u043b\u0430\u0442\u044c broadcast join \u0432\u043c\u0435\u0441\u0442\u043e shuffle join \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u043c\u0435\u0440 \u043c\u0435\u043d\u044c\u0448\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0432\u0435\u043b\u0438\u043a \u0434\u043b\u044f broadcast.<\/p>\n<p>  \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 big_table (100Gb)<\/p>\n<pre><code class=\"sql\">create table big_table(   id decimal(18,0),   key1 decimal(18,0) ) stored as parquet;<\/code><\/pre>\n<p>  \u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u0435\u0439 small_table (4Gb)<\/p>\n<pre><code class=\"sql\">create table small_table(   id decimal(18,0),   key2 decimal(18,0) ) stored as parquet;<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0430\u0431\u043b\u0438\u0446\u044b small_table \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0432\u0435\u043b\u0438\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0435\u0451 broadcast, \u043e \u0447\u0451\u043c \u0432\u044b\u0434\u0430\u0451\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430.<\/p>\n<p>  \u0426\u0435\u043b\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443:<\/p>\n<pre><code class=\"sql\">truncate table result_table; insert into table result_table select big_table.id,        big_table.key1,        small_table.key2   from big_table   left join small_table     on big_table.id = small_table.id;<\/code><\/pre>\n<p>  \u0421\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u043b\u044e\u0447\u0443 id \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c.<\/p>\n<p>  \u0421\u0434\u0435\u043b\u0430\u0435\u043c \u043e\u0431\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c\u044b\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438:<\/p>\n<pre><code class=\"sql\">create table big_table(   id decimal(18,0),   key1 decimal(18,0) ) partitioned by (part_mod decimal(6,0)) stored as parquet;  create table small_table(   id decimal(18,0),   key2 decimal(18,0) ) partitioned by (part_mod decimal(6,0)) stored as parquet;<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043e\u0431\u0435\u0438\u0445 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u0431\u043b\u0438\u0446 big_table \u0438 small_table \u043a\u043b\u044e\u0447 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f part_mod \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0430\u0432\u043d\u044b\u043c \u043e\u0441\u0442\u0430\u0442\u043a\u0443 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f id \u043d\u0430 4:<\/p>\n<p>  part_mod = id%4;<\/p>\n<p>  \u0417\u0430\u0432\u0435\u0434\u0451\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u043c\u043e\u0442\u0440\u044f\u0449\u0443\u044e \u0441\u0432\u043e\u0438\u043c location \u043d\u0430 \u043e\u0434\u043d\u0443 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e big_table (part_mod = 0):  <\/p>\n<pre><code class=\"sql\">create table big_table_0(   id decimal(18,0),   key1 decimal(18,0) ) stored as parquet location '\u2026\/big_table\/part_mod=0';<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0436\u0435 \u0437\u0430\u0432\u0435\u0434\u0451\u043c \u043f\u0441\u0435\u0432\u0434\u043e\u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0441\u043c\u043e\u0442\u0440\u044f\u0449\u0443\u044e \u0441\u0432\u043e\u0438\u043c location \u043d\u0430 \u043e\u0434\u043d\u0443 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044e small_table (part_mod = 0):<\/p>\n<pre><code class=\"sql\">create table small_table_0(   id decimal(18,0),   key1 decimal(18,0) ) stored as parquet location '\u2026\/small_table\/part_mod=0';<\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043e\u0434\u043d\u0443 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u0432\u044b\u0448\u0435\u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u043f\u0441\u0435\u0432\u0434\u043e\u0442\u0430\u0431\u043b\u0438\u0446.<\/p>\n<p>  \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043e, \u0447\u0442\u043e \u0445\u0438\u043d\u0442 BROADCAST \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442:<\/p>\n<pre><code class=\"sql\">truncate table result_table; insert into table result_table select \/*+ BROADCAST(small_table_0)*\/ big_table_0.id,        big_table_0.key1,        small_table_0.key2   from big_table_0   left join small_table_0     on big_table.id = small_table.id;<\/code><\/pre>\n<p>  \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0440\u0435\u043c\u044f \u0448\u0430\u0433\u0430\u043c\u0438 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u043e\u0441\u0442\u0430\u0432\u0448\u0438\u0435\u0441\u044f \u0442\u0440\u0438 \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 part_mod = 1, part_mod = 2, part_mod = 3.<\/p>\n<p>  \u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u00ab\u043c\u0435\u0442\u043e\u0434\u043e\u043c \u043f\u043e\u044d\u0442\u0430\u043f\u043d\u043e\u0433\u043e broadcast \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439\u00bb \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u0445 \u043c\u0435\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c shuffle join. \u041e\u0434\u043d\u0430\u043a\u043e \u0442\u0430\u043a\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0442\u0440\u0435\u0431\u0443\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0431\u044b\u043b\u0438 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0442.\u0435. \u043f\u043e \u043e\u0441\u0442\u0430\u0442\u043a\u0443 \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f id \u043d\u0430 \u043a\u0430\u043a\u043e\u0435-\u043b\u0438\u0431\u043e \u0447\u0438\u0441\u043b\u043e, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0441\u043e\u0435\u0434\u0438\u043d\u044f\u0435\u043c\u0441\u044f. \u0415\u0441\u043b\u0438 id \u043d\u0435 \u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u043e\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u0440\u0430\u0442\u044c \u043e\u0441\u0442\u0430\u0442\u043e\u043a \u043e\u0442 \u0434\u0435\u043b\u0435\u043d\u0438\u044f hash(id) \u043d\u0430 \u043a\u0430\u043a\u043e\u0435-\u043b\u0438\u0431\u043e \u0447\u0438\u0441\u043b\u043e. \u041e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u0431\u044b\u043b\u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 (\u0441\u0442\u0435\u0439\u0434\u0436\u0438\u043d\u0433\u043e\u0432\u044b\u0435) \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0434\u0438\u0437\u0430\u0439\u043d \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043d\u0438\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430.<\/p>\n<h3>\u041c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/h3>\n<p>  \u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u043e\u0437\u0435\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u0430\u0436\u043d\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0437\u0430\u0434\u0430\u0447\u0430\u043c \u043f\u043e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u043c\u0435\u044e\u0442\u0441\u044f \u0440\u0438\u0441\u043a\u0438 \u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438 \u043e\u0442 \u043d\u0435\u0445\u0432\u0430\u0442\u043a\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u0447\u0438, \u043b\u0438\u0431\u043e \u043d\u0435\u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043d\u043e \u0432\u044b\u0441\u043e\u043a\u043e\u0433\u043e \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432 \u0443\u0449\u0435\u0440\u0431 \u0434\u0440\u0443\u0433\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0430\u043c.<\/p>\n<p>  \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u044f\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u2013 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0430\u044f \u0442\u0435\u043c\u0430. \u0412 \u044d\u0442\u043e\u0439 \u0436\u0435 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0433\u043e\u0432\u043e\u0440\u0438\u043c \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u044c:<\/p>\n<ol>\n<li>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432\u044b\u0434\u0435\u043b\u0438\u043b Yarn \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438\u043b\u0438 \u0433\u0440\u0443\u043f\u043f\u0443 \u0437\u0430\u0434\u0430\u0447 \u0432 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u043a\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n<li>\u0421\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b Spark \u043d\u0430 \u0437\u0430\u0434\u0430\u0447\u0443 \u0438\u0437 \u0447\u0438\u0441\u043b\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0435\u043c\u0443 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u043e\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 Yarn \u0432 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u043a\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n<\/ol>\n<p>  \u0421\u0440\u0430\u0437\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Graphite\/Grafana, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d\u0438 \u0442\u0440\u0435\u0431\u0443\u044e\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438. \u041d\u0438\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u0441\u043f\u043e\u0441\u043e\u0431, \u043a\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u201c\u043d\u0430 \u043a\u043e\u043b\u0435\u043d\u043a\u0435\u201d, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, Spark SQL \u0438 \u043b\u043e\u0433\u043e\u0432 Spark.<\/p>\n<p>  <b>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0438\u0448\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0438\u0434 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 (\u201c\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 yarn\u201d).<\/b><\/p>\n<p>  \u041a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 \u0432\u0438\u0434\u0430<\/p>\n<pre><code class=\"plaintext\">while [ ! -f complete.flg ]; do for app in $(yarn application -list -appStates RUNNING | grep &lt;filter_for_app_names&gt; | awk '{print $1}'); do ( command1 () { date +&quot;%Y-%m-%d %H:%M:%S&quot;; }; command2 () { yarn application -status $app; }; x=&lt;loading_date&gt;&quot;|&quot;&lt;loading_id&gt;&quot;|$(command1) $(command2)&quot;; echo $x &gt;&gt; app.txt; ) &amp; done; wait; done<\/code><\/pre>\n<p>  \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u0412 \u043f\u0435\u0440\u0438\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430, \u043a\u043e\u0433\u0434\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0444\u043b\u0430\u0433 \u0432 \u0432\u0438\u0434\u0435 \u0444\u0430\u0439\u043b\u0430 complete.flg, \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0438\u0445\u0441\u044f \u0432 \u0441\u0442\u0430\u0442\u0443\u0441\u0435 RUNNING \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 Yarn, \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u0432 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0438 \u0448\u0430\u0431\u043b\u043e\u043d &lt;filter_for_app_names&gt;, \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b app.txt \u0434\u043e\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u044b\u0437\u043e\u0432\u0430 \u043a\u043e\u043c\u0430\u043d\u0434\u044b yarn application \u2013status $app. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0444\u0430\u0439\u043b\u0435 app.txt \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0437\u0430\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u044b\u0445 \u0437\u0430 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0435\u0433\u0430\u0431\u0430\u0439\u0442*\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 (MB-seconds) \u0438 \u044f\u0434\u0440\u043e*\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 (vcore-seconds) \u043d\u0430\u043a\u043e\u043f\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0438\u0442\u043e\u0433\u043e\u043c. \u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0444\u043b\u0430\u0433 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f complete.flg \u0438 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b app.txt \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u0432 hdfs \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u0443\u044e \u0442\u0430\u0431\u043b\u0438\u0446\u0443 yarn_monitoring:<\/p>\n<pre><code class=\"sql\">CREATE EXTERNAL TABLE IF NOT EXISTS scheme_name.yarn_monitoring(   loading_date string,   loading_id string,   txt string ) ROW FORMAT SERDE   'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES (   'field.delim'='|',   'serialization.format'='|')  STORED AS INPUTFORMAT   'org.apache.hadoop.mapred.TextInputFormat' OUTPUTFORMAT   'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' LOCATION   '\u2026\/yarn_monitoring';<\/code><\/pre>\n<p>  \u0421\u0442\u0440\u043e\u043a\u0438 \u0432 \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438\u043c\u0435\u044e\u0442 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"sql\">2020-02-18|2235599|2020-02-18 01:00:44 Application Report : Application-Id : application_1580486634374_3632578 Application-Name : &lt;app_name&gt; Application-Type : SPARK User : &lt;user&gt; Queue : &lt;yarnqueue&gt; Start-Time : 1581976835176 Finish-Time : 0 Progress : 10% State : RUNNING Final-State : UNDEFINED Tracking-URL : &lt;url&gt; RPC Port : 0 AM Host : &lt;host&gt; Aggregate Resource Allocation : 18663 MB-seconds, 9 vcore-seconds Log Aggregation Status : NOT_START Diagnostics :<\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043d\u0430 \u0442\u043e\u043c \u0436\u0435 Spark SQL \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u044d\u0442\u043e\u0439 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 (MB-seconds, vcore-seconds) \u043d\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u0435\u043d\u0438\u044f \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430. \u0414\u0430\u043b\u0435\u0435 \u0432 \u044d\u0442\u043e\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0432 \u0432\u0438\u0434\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0432\u0435\u043a\u0442\u043e\u0440\u043d\u043e\u0439 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 *.svg:<\/p>\n<pre><code class=\"sql\">\u2026 &lt;text x=&quot;101&quot; y=&quot;21&quot; font-size=&quot;10&quot; fill=&quot;rgb(0,150,255)&quot;&gt;13:47:48&lt;\/text&gt; &lt;line x1=&quot;948&quot; x2=&quot;949&quot; y1=&quot;2041&quot; y2=&quot;2041&quot; style=&quot;stroke:rgb(255,0,0); stroke-width:1px&quot;\/&gt;  \u2026<\/code><\/pre>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b *.svg \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u0441 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0433\u0440\u0443\u043f\u043f\u043e\u0439 \u043d\u0430\u0431\u043b\u044e\u0434\u0430\u0435\u043c\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 Yarn, \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0438\u0436\u0435. \u041a\u0440\u0430\u0441\u043d\u044b\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438, \u0441\u0438\u043d\u0438\u043c \u0446\u0432\u0435\u0442\u043e\u043c \u2014 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0445 \u044f\u0434\u0435\u0440:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/nn\/yo\/le\/nnyole0wfcl1dxhctvm-bu4waf4.png\"><\/p>\n<p>  \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043e\u0431 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0438 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0445 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 Yarn \u0441 \u0446\u0435\u043b\u044c\u044e \u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0443\u0442\u043e\u043a.<\/p>\n<p>  <b>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043f\u0438\u0448\u0435\u043c \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0438\u0434 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 (\u201c\u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433 spark\u201d).<\/b><\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 Yarn \u0432\u044b\u0434\u0435\u043b\u0438\u043b \u0437\u0430\u0434\u0430\u0447\u0435 Spark, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, 200 \u044f\u0434\u0435\u0440 \u0438 \u043d\u0435 \u043e\u0442\u0434\u0430\u0451\u0442 \u044d\u0442\u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u0440\u0443\u0433\u0438\u043c \u0437\u0430\u0434\u0430\u0447\u0430\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438 199 \u0438\u0437 200 \u044f\u0434\u0435\u0440 \u0443\u0436\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 Spark, \u0430 \u0440\u0430\u0431\u043e\u0442\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u043d\u043e \u044f\u0434\u0440\u043e. \u042d\u0442\u043e\u0442 \u0432\u0438\u0434 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0430 \u0441\u0440\u0435\u0434\u0438 \u043f\u0440\u043e\u0447\u0435\u0433\u043e \u043d\u0430\u0446\u0435\u043b\u0435\u043d \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0442\u0430\u043a\u0438\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439.<\/p>\n<p>  \u0421\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u0430\u0435\u043c\u044b\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0438\u043d\u0433\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spark \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0438\u0437 \u043d\u0435\u043a\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0421\u0431\u0435\u0440\u0431\u0430\u043d\u043a\u0430 \u044d\u0442\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, Oozie \u0438\u043b\u0438 Informatica BDM. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spark \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043b\u043e\u0433 \u0432 hdfs \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Spark SQL \u043f\u043e \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0443 \u044d\u0442\u043e\u0433\u043e \u043b\u043e\u0433\u0430 (\u0438\u043b\u0438 \u0433\u0440\u0443\u043f\u043f\u044b \u043b\u043e\u0433\u043e\u0432) \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0438 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0445\u0441\u044f Spark \u044f\u0434\u0435\u0440 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 *.svg.<\/p>\n<p>  \u0418\u0442\u0430\u043a, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043d\u0438\u0436\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u043c\u044b:<\/p>\n<ol>\n<li>\u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e $app \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 yarn, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u00abapplication_1576046768499_16691\u00bb<\/li>\n<li>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b command1 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b $app&quot;.txt&quot; \u0441\u0442\u0440\u043e\u043a\u0443-\u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spark<\/li>\n<li>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u00abyarn logs -applicationId $app\u00bb\u0434\u043e\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0444\u0430\u0439\u043b $app&quot;.txt&quot; \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u0438\u0437 Yarn \u043b\u043e\u0433 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0432\u0448\u0435\u0433\u043e\u0441\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spark<\/li>\n<li>\u041f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b $app&quot;.txt&quot; \u0441\u043e \u0441\u0442\u0430\u0442\u0443\u0441\u043e\u043c \u0438 \u043b\u043e\u0433\u043e\u043c \u0432 hdfs<\/li>\n<\/ol>\n<p>  <\/p>\n<pre><code class=\"plaintext\">'app=$(grep &quot;(state: FINISHED)&quot; \/tmp\/'&lt;spark_log_file&gt;' | grep -o &quot;application_[^ ]*&quot; | tee \/tmp\/applicationid_'&lt;yarn_task_name&gt;'.txt); command1 () { yarn application -status $app; }; x=&quot;'&lt;loading_date&gt;'|'&lt;loading_id&gt;'|$app|0|$(command1)&quot;; echo $x &gt; &quot;\/tmp\/&quot;$app&quot;.txt&quot;; yarn logs -applicationId $app | nl -ba -s&quot;|&quot; | sed &quot;s\/^\/'&lt;loading_date&gt;'|'&lt;loading_id&gt;'|&quot;$app&quot;|\/&quot; &gt;&gt; &quot;\/tmp\/&quot;$app&quot;.txt&quot;; hdfs dfs -copyFromLocal -f &quot;\/tmp\/&quot;$app&quot;.txt&quot; \u2026\/spark_monitoring; rm &quot;\/tmp\/&quot;$app&quot;.txt&quot;'<\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0432 hdfs \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u0438\u0434\u0430<\/p>\n<pre><code class=\"sql\">2019-12-13|1227125|application_1576046768499_16691|0|Application Report : Application-Id : application_1576046768499_16691 Application-Name : &lt;app_name&gt; Application-Type : SPARK User : &lt;user&gt; Queue : &lt;yarnqueue&gt; Start-Time : 1576229137128 Finish-Time : 1576229189406 Progress : 100% State : FINISHED Final-State : SUCCEEDED Tracking-URL : http:\/\/...sbrf.ru:18089\/history\/application_1576046768499_16691\/1 RPC Port : 0 AM Host : \u2026 Aggregate Resource Allocation : 93763306 MB-seconds, 9957 vcore-seconds Log Aggregation Status : NOT_START Diagnostics : 2019-12-13|1227125|application_1576046768499_16691|     1| 2019-12-13|1227125|application_1576046768499_16691|     2| 2019-12-13|1227125|application_1576046768499_16691|     3|Container: container_1576046768499_16691_01_000162 on \u2026sbrf.ru_8041 2019-12-13|1227125|application_1576046768499_16691|     4|=========================================================================================== 2019-12-13|1227125|application_1576046768499_16691|     5|LogType:container-localizer-syslog 2019-12-13|1227125|application_1576046768499_16691|     6|Log Upload Time:Fri Dec 13 12:26:32 +0300 2019 2019-12-13|1227125|application_1576046768499_16691|     7|LogLength:0 2019-12-13|1227125|application_1576046768499_16691|     8|Log Contents: 2019-12-13|1227125|application_1576046768499_16691|     9| \u2026 2019-12-13|1227125|application_1576046768499_16691|    53|19\/12\/13 12:26:02 INFO executor.Executor: Running task 26.0 in stage 0.0 (TID 19)  \u2026 2019-12-13|1227125|application_1576046768499_16691|    82|19\/12\/13 12:26:07 INFO executor.Executor: Finished task 26.0 in stage 0.0 (TID 19). 5735 bytes result sent to driver  \u2026 2019-12-13|1227125|application_1576046768499_16691|    84|19\/12\/13 12:26:07 INFO executor.Executor: Running task 441.0 in stage 0.0 (TID 364)  \u2026 2019-12-13|1227125|application_1576046768499_16691|   102|19\/12\/13 12:26:08 INFO executor.Executor: Finished task 441.0 in stage 0.0 (TID 364). 5543 bytes result sent to driver \u2026<\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0435 \u0432 \u043b\u043e\u0433\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spark \u0438\u0449\u0443\u0442\u0441\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0432\u044b\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u044f\u0434\u0435\u0440 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0442\u0435\u043c \u0438\u043b\u0438 \u0438\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c, \u0442.\u0435. \u043c\u044b \u0438\u0449\u0435\u043c \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043b\u043e\u0433 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u043f\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c<\/p>\n<pre><code class=\"sql\">INFO executor.Executor: Running task INFO executor.Executor: Finished task<\/code><\/pre>\n<p>  \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043d\u0430 \u043b\u044e\u0431\u043e\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0445 \u044f\u0434\u0435\u0440 \u0431\u044b\u043b\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f Spark, \u0442.\u0435. \u043d\u0430\u0447\u0430\u043b\u0438 \u0438 \u0435\u0449\u0435 \u043d\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043b\u0438 \u0441\u0432\u043e\u044e \u0440\u0430\u0431\u043e\u0442\u0443.<\/p>\n<p>  \u0414\u043b\u044f \u043f\u0430\u0440\u0441\u0438\u043d\u0433\u0430 \u0441\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0445 \u0432 hdfs \u043b\u043e\u0433\u043e\u0432 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0442\u0430\u0431\u043b\u0438\u0446\u0430 spark_monitoring \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435:<\/p>\n<pre><code class=\"sql\">CREATE EXTERNAL TABLE IF NOT EXISTS scheme_name.spark_monitoring(   loading_date string,   loading_id string,   applicationid string,   rn string,   txt string ) ROW FORMAT SERDE   'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' WITH SERDEPROPERTIES (   'field.delim'='|',   'serialization.format'='|')  STORED AS INPUTFORMAT   'org.apache.hadoop.mapred.TextInputFormat' OUTPUTFORMAT   'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' LOCATION   '\u2026\/spark_monitoring';<\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432\u044b\u0448\u0435, \u043f\u0430\u0440\u0441\u0438\u043d\u0433 \u043b\u043e\u0433\u043e\u0432 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u043b\u0430\u043c\u0438 Spark SQL. \u0422.\u0435. \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 spark_monitoring, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0434\u0430\u0451\u0442 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 *.svg \u0441 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u043e\u0439 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044f\u0434\u0435\u0440 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c Spark. <\/p>\n<p>  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u0444\u0430\u0439\u043b *.svg \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435. \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d \u043d\u0438\u0436\u0435:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/yu\/vi\/ie\/yuviieatqcri0xusj62fxyykgp8.png\"><\/p>\n<p>  \u041d\u0430 \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u0438\u0445 \u0433\u0440\u0430\u0444\u0438\u043a\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043d\u044f\u0442\u044c, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Spark \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0435 \u0435\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u044b\u0435 \u044f\u0434\u0440\u0430 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430. \u041c\u043e\u0436\u043d\u043e \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u043e\u0432\u043e. \u0420\u0435\u0437\u043a\u0438\u0435 \u0441\u043a\u0430\u0447\u043a\u0438 \u0432\u0432\u0435\u0440\u0445-\u0432\u043d\u0438\u0437, \u0432\u0438\u0434\u043d\u044b\u0435 \u043d\u0430 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u0445 \u2013 \u044d\u0442\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0430\u043f\u0430\u043c\u0438 (stages) \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439 Spark. \u041a\u043e\u0433\u0434\u0430 \u0437\u0430\u043a\u0430\u043d\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u044d\u0442\u0430\u043f \u043f\u043e \u0447\u0442\u0435\u043d\u0438\u044e \u0438\u043b\u0438 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u044f\u0434\u0440\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0430 \u043a \u043d\u0443\u043b\u044e. \u0410 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u043e\u0432\u044b\u0445 \u044d\u0442\u0430\u043f\u043e\u0432 \u0438\u0434\u0451\u0442 \u0440\u0435\u0437\u043a\u0438\u0439 \u0440\u043e\u0441\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u044f\u0434\u0435\u0440. \u0421\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u0440\u0438\u0442\u044f\u043d\u0443\u0442 \u043a \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0443 \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u044f\u0434\u0435\u0440 \u0438 \u0441\u043a\u0430\u0447\u043a\u0438 \u043c\u0435\u0436\u0434\u0443 \u044d\u0442\u0430\u043f\u0430\u043c\u0438 \u0440\u0435\u0437\u043a\u0438\u0435 \u2013 \u044d\u0442\u043e \u043f\u0440\u0438\u0437\u043d\u0430\u043a \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432. \u041c\u0435\u0434\u043b\u0435\u043d\u043d\u044b\u0435 \u0436\u0435 \u0441\u043d\u0438\u0436\u0435\u043d\u0438\u044f \u043c\u043e\u0433\u0443\u0442 \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043e skew joins, \u043e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u043e\u0441\u044c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0432\u044b\u0448\u0435.<\/p>\n<blockquote><p>\u0410\u0432\u0442\u043e\u0440: \u041c\u0438\u0445\u0430\u0438\u043b \u0413\u0440\u0438\u0447\u0438\u043a, \u044d\u043a\u0441\u043f\u0435\u0440\u0442 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u0430 \u0421\u0431\u0435\u0440\u0431\u0430\u043d\u043a\u0430 SberProfi DWH\/BigData.<\/p>\n<p>  \u041f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e SberProfi DWH\/BigData \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u0440\u0430\u0437\u0432\u0438\u0442\u0438\u0435 \u043a\u043e\u043c\u043f\u0435\u0442\u0435\u043d\u0446\u0438\u0439 \u0432 \u0442\u0430\u043a\u0438\u0445 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f\u0445, \u043a\u0430\u043a \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0430 Hadoop, Teradata, Oracle DB, GreenPlum, \u0430 \u0442\u0430\u043a\u0436\u0435 BI \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0445 Qlik, SAP BO, Tableau \u0438 \u0434\u0440.<\/p><\/blockquote>\n<\/div>\n<p> \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\/company\/sberbank\/blog\/496310\/\"> https:\/\/habr.com\/ru\/company\/sberbank\/blog\/496310\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/sberbank\/blog\/496310\/\">\u0415\u0441\u043b\u0438 \u0432\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u0435 \u0441 SQL, \u0442\u043e \u0432\u0430\u043c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u043a\u043e\u0440\u043e. Apache Spark \u2013 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0445 \u0432 \u044d\u043a\u043e\u0441\u0438\u0441\u0442\u0435\u043c\u0443 Hadoop, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0435\u0433\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Spark SQL, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u0434 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. Spark SQL \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0441 \u0432\u044b\u0441\u043e\u043a\u043e\u0439 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439. <\/p>\n<p>  \u041d\u0438\u0436\u0435 \u0432\u044b \u043d\u0430\u0439\u0434\u0451\u0442\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0445\u0438\u0442\u0440\u044b\u0435 \u043f\u0440\u0438\u0451\u043c\u044b \u043f\u043e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e Spark SQL:<\/p>\n<ul>\n<li>\u041a\u0430\u043a \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0431\u043e\u0440\u0430 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0445\u0438\u043d\u0442\u043e\u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u043d \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430.<\/li>\n<li>\u041a\u0430\u043a, \u043e\u0441\u0442\u0430\u0432\u0430\u044f\u0441\u044c \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 SQL, \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u044e\u0447\u0430\u043c \u0441 \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u044b\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (skewed joins).<\/li>\n<li>\u041a\u0430\u043a \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c broadcast join \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0435\u0441\u043b\u0438 \u0435\u0451 \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0432\u0435\u043b\u0438\u043a.<\/li>\n<li>\u041a\u0430\u043a \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 Spark SQL \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 Spark \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u043e \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u044f\u0434\u0435\u0440 \u043a\u043b\u0430\u0441\u0442\u0435\u0440\u0430 \u0432 \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u043a\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/li>\n<\/ul>\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-301559","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301559","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=301559"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/301559\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=301559"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=301559"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=301559"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}