{"id":320902,"date":"2021-04-05T15:01:20","date_gmt":"2021-04-05T15:01:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=320902"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=320902","title":{"rendered":"Impala \u0434\u043b\u044f Python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u0434\u0430 \u043f\u0440\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u0432 \u043c\u0430\u0440\u043a\u0435\u0442\u0438\u043d\u0433\u043e\u0432\u043e\u0439 \u043f\u043b\u0430\u0442\u0444\u043e\u0440\u043c\u0435"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e8a\/9c7\/3cd\/e8a9c73cdc295a21476e23f139471f7c.png\" width=\"780\" height=\"440\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442.<\/p>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043d\u0438\u0445 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u044b \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e. \u042d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043b\u0438\u0448\u0435\u043d\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0431\u0430\u0437\u0435 Hadoop, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 HDFS. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u043d\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c (\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c&nbsp;\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438) \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043b\u0438\u043a\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u0445, \u0438\u0437\u043c\u0435\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u0441\u043e\u0442\u043d\u044f\u0445 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432 \u043c\u0435\u0441\u044f\u0446, \u043e\u0442\u0433\u043e\u0432\u043e\u0440\u043a\u0430 \u0432 \u0434\u0443\u0445\u0435 \u201c\u043d\u0443\u0443&#8230; \u043d\u0430\u0448 postgres \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438\u201d \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0411\u0435\u0437 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0443\u0442 \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, Clickhouse, Snowflake \u0438 \u0442.\u0434., \u043d\u043e&nbsp;\u0432&nbsp;\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438&nbsp;\u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 Impala \u0438 Hive. \u041f\u0435\u0440\u0432\u0430\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u0412\u0442\u043e\u0440\u043e\u0439 \u2013 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0434\u0438\u0441\u043a\u043e\u043c. \u041d\u0438\u043a\u0442\u043e \u043d\u0435 \u043b\u044e\u0431\u0438\u0442 \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 Impala.<\/p>\n<p>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u043d\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0447\u0442\u0435\u043d\u0438\u0435. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 update, delete, etc (\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c Kudu, \u043e \u0447\u0435\u043c \u0440\u0435\u0447\u044c \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435).<\/p>\n<\/li>\n<li>\n<p>\u0413\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u044b\u2026 \u043d\u0435\u0442, \u0442\u0435\u0440\u0430\u0431\u0430\u0439\u0442\u044b \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0432 python \u043d\u0435\u0442\u0443 ORM \u0434\u043b\u044f Impala? \u041a\u0430\u043a\u043e\u0435 \u0435\u0449\u0435 ODBC?<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0438\u0437 1000 \u0438 1 000 000 \u0441\u0442\u0440\u043e\u043a \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0440\u043c\u043e\u0437\u0438\u0442? \u0422\u043e, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0438 \u0434\u0435\u0441\u044f\u0442\u043a\u0430\u0445 \u0441\u0435\u043a\u0443\u043d\u0434, \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0442\u0447\u0435\u0442\u043e\u0432, \u043d\u043e \u0442\u0430\u043a \u0441\u0435\u0431\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 real-time\u2019\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443, \u0431\u043b\u0430\u0433\u043e \u0447\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0434\u0430\u0442\u0430. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a \u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0438\u043b\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0432\u0441\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043b\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u0437 30 \u043d\u043e\u0434 \u0441&nbsp;\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 90 \u0413\u0411 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043d\u043e\u0434\u0435 \u0438 1 \u0422\u0411 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e.&nbsp;\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2013 Hue (&#171;\u0425\u044c\u044e&#187;) \u2013 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Impala \u0434\u043b\u044f python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442&nbsp;\u0440\u0430\u0431\u043e\u0442\u044b&nbsp;\u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0411\u0414. \u0414\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0432\u0441\u0435\u0433\u043e 2 \u2013 impyla \u0438 cloudera odbc. \u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u043a\u043e\u0433\u0434\u0430-\u0442\u043e \u0434\u0430\u0432\u043d\u043e \u0431\u044b\u043b \u043f\u043b\u043e\u0445\u043e\u0439 \u043e\u043f\u044b\u0442, \u043f\u043b\u044e\u0441 \u0443 \u043d\u0435\u0433\u043e \u043a\u0443\u0447\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 issue \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435. \u0420\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0447\u0430\u0442\u044c \u0441\u0430\u043c \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440 \u0441 \u0441\u0430\u0439\u0442\u0430, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u0438 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c pyodbc. \u0422.\u043a. \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435, \u0432\u043c\u0435\u0441\u0442\u043e pyodbc \u0443 \u043d\u0430\u0441 aioodbc \u2013 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 pyodbc.<\/p>\n<pre><code class=\"python\">def _convert_timestamp(value):     unpacked = struct.unpack('6Hxxxx', value)     if unpacked == (1970, 1, 1, 0, 0, 0):         return None     return datetime(*unpacked)     class Impala:     def __init__(self):         self.dsn = (             f'DRIVER={{{cfg.impala_driver}}};'             f'HOST={{{cfg.impala_host}}};'             f'PORT={{{cfg.impala_port}}};'             f'SCHEMA={{{cfg.impala_default_schema}}};'             f'UID={{{cfg.impala_uid}}};'             f'PWD={{{cfg.impala_pwd}}};'             f'AUTHMECH=3;'             f'USESASL=1;'             f'SSL=0;'         )           self.pool: Optional[Pool] = None       async def connect(self):         self.pool: Pool = await create_pool(             minsize=cfg.impala_min_poolsize,             maxsize=cfg.impala_max_poolsize,             dsn=self.dsn,             after_created=self.after_created,             autocommit=True,             pool_recycle=55,         )           async with self.pool.acquire() as connection:             async with connection.cursor() as cursor:                 cursor: Cursor                   result = await cursor.execute('select 1')                 await result.fetchone()       async def disconnect(self):         if self.pool is not None:             self.pool.close()             await self.pool.wait_closed()       @staticmethod     async def after_created(connection):         # Driver return zero date values incorrectly         connection.add_output_converter(SQL_TYPE_TIMESTAMP, _convert_timestamp)           connection.setdecoding(SQL_CHAR, encoding='utf-8')         connection.setdecoding(SQL_WCHAR, encoding='utf-8')         connection.setdecoding(SQL_WMETADATA, encoding='utf-16')         connection.setencoding(encoding='utf-8')       async def _run_with_retries(         self,         query,         *params,         retries=0,         max_retries=cfg.impala_max_retries,     ):         try:             async with self.pool.acquire() as connection:                 async with connection.cursor() as cursor:                     result = await cursor.execute(query, *params)                     return await getattr(result, 'execute').__call__()         except Error as e:             if retries &lt; max_retries:                 retries += 1                 return await self._run_with_retries(                     query,                     *params,                     retries=retries,                     max_retries=max_retries,                 )             raise       async def execute(self, query, *params):         return await self._run_with_retries(query, *params)       @staticmethod     def to_python(data: Union[List[Row], Row]) -&gt; Union[List[dict], dict]:         if isinstance(data, List):             return list(map(Impala.to_python, data))           return {info[0]: data[i] for i, info in enumerate(data.cursor_description)}<\/code><\/pre>\n<p>\u0421\u0432\u044f\u0437\u043a\u0430 \u0438\u0437 \u0441\u0430\u043c\u043e\u0439 Impala \u0438 \u0435\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0411\u0414, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 retry-\u0438 \u2013 \u043d\u0430\u0448\u0435 \u0432\u0441\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e.<\/p>\n<p>\u041f\u0440\u043e \u041e\u0420\u041c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u2013 \u0435\u0433\u043e \u043d\u0435\u0442. \u041c\u043e\u0436\u0435\u0442, \u044d\u0442\u043e \u0438 \u043a \u043b\u0443\u0447\u0448\u0435\u043c\u0443, \u0442.\u043a. \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u041e\u0420\u041c \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e, \u043f\u0438\u0441\u0430\u0442\u044c raw-sql \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435, \u0438 \u043a\u043e\u0434 \u043b\u0443\u0447\u0448\u0435 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f. \u041d\u043e \u043e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u2013 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0441\u0445\u0435\u043c\u044b \u0442\u0430\u0431\u043b\u0438\u0446. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e,&nbsp;\u043d\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 (\u0438\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435?)<\/p>\n<p>SELECT-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a Impala \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0411\u0414:<\/p>\n<ul>\n<li>\n<p>\u041b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u0435\u043b\u0430\u0435\u0442 full scan, \u0442.\u043a. \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0435\u0442\u0443, \u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u043e \u043d\u0438\u043c. \u041f\u043e \u0441\u0443\u0442\u0438, \u043e\u0434\u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f \u2013 \u043e\u0434\u0438\u043d \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. \u041c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u043e \u2013 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Impala, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c\u0438. \u0422.\u043a. \u0443 \u043d\u0430\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Parquet \u2013 \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e Parquet \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442:&nbsp;<a href=\"https:\/\/www.bigdataschool.ru\/blog\/apache-parquet-avro-spark-big-data.html\">https:\/\/www.bigdataschool.ru\/blog\/apache-parquet-avro-spark-big-data.html<\/a><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 Impala \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0437\u043d\u0430\u043b\u0430, \u0433\u0434\u0435 \u0438 \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0435\u0436\u0430\u0442,&nbsp;\u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443&nbsp;(COMPUTE STATS), \u0438\u043d\u0430\u0447\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u0438\u0431\u043e \u0438\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f (\u043f\u0440\u0438\u0432\u0435\u0442, GDPR) \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c. Impala \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0442\u0430\u043a \u043d\u0435 \u0443\u043c\u0435\u0435\u0442, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.&nbsp;\u0422\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 KUDU. \u042d\u0442\u043e \u0434\u0432\u0438\u0436\u043e\u043a \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e primary key \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c. \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f KUDU \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c primary key (\u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0439), \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c DELETE \u0438 UPSERT, \u0430 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0447\u0435\u0442\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u2013 \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u044b \u043f\u043e\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438 \u0438\u0445 \u0442\u0438\u043f\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, KUDU \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u043e\u043b\u0435\u0439 (CHAR, DATE, etc.), \u0438, \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0427\u0442\u043e \u0432\u0430\u0436\u043d\u043e: \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a KUDU \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 Impala. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Impala \u0443\u0436\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u044e\u0442\u0441\u044f \u043a&nbsp;\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0411\u0414, \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435.<\/p>\n<p>\u0418\u043c\u0435\u044f \u044d\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u0442\u0438\u0442 \u0437\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u0430 (Google, Yandex \u0438 \u0434\u0440.). \u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043e\u043f\u043b\u0430\u0442\u044b: \u0437\u0430 \u043a\u043b\u0438\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e \u0431\u0430\u043d\u043d\u0435\u0440\u0443, \u0437\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0437\u0430 \u043f\u043e\u043a\u0430\u0437\u044b \u0431\u0430\u043d\u043d\u0435\u0440\u043e\u0432 \u0438 \u0442.\u0434. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u044f\u043a\u0438\u0435 \u043d\u0435\u0434\u043e\u0431\u0440\u043e\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c (\u0438 \u0434\u0435\u043b\u0430\u044e\u0442) \u043d\u0430\u043a\u0440\u0443\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0438\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0444\u0440\u043e\u0434. \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u043a\u0440\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043d\u0435 \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0437\u0430 \u043d\u0438\u0445.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442, click_event \u2013 \u0434\u0430\u043d\u043d\u044b\u0435&nbsp;\u043f\u043e \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u043c \u043a\u043b\u0438\u043a\u0430\u043c&nbsp;\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u044d\u0442\u0438 \u043a\u043b\u0438\u043a\u0438 (\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u043b\u043e\u0433\u0438\u043d\u044b \u0432 \u0438\u0433\u0440\u0443, \u043f\u043b\u0430\u0442\u0435\u0436\u0438 \u0438 \u0442.\u0434.).<\/p>\n<p>\u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0445 \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f,&nbsp;\u0443 \u043d\u0430\u0441 \u0438\u0445 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432. \u041e\u0431\u0449\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0444\u0438\u0447\u0438 \u0442\u0430\u043a\u043e\u0432\u0430: \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441 \u0444\u0440\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0433\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435\u0445 \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043e\u0434\u0438\u043d \u0434\u0430\u0442\u0430\u0441\u0435\u0442. \u0418 \u043f\u043e\u0442\u043e\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u0441\u0435\u0445 \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u2013 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u0434\u0430: \u0435\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u043e\u0434\u043d\u043e\u0433\u043e IP-\u0430\u0434\u0440\u0435\u0441\u0430, \u0442\u043e \u044d\u0442\u043e \u0444\u0440\u043e\u0434.<\/p>\n<pre><code class=\"sql\">UPSERT INTO {self.model.get_tablename()} (     id,     rule_run_id,     player_id,     event_id,     ip_hash,     regs_cnt,     analysed_start_day,     analysed_end_day,     created_at ) WITH same_ip_regs AS (     SELECT         CE.campaign_id,         CE.campaign_sub_id,         CE.player_id,         CE.event_id,         CE.ip_hash ip_address,         count(CE.event_id) OVER (PARTITION BY campaign_id, campaign_sub_id, CE.ip_hash) cnt     FROM click_event CE     WHERE         TO_DATE(CE.event_dt) = '{self.config.process_from}' AND         CE.event_name='registration' AND         CE.ip_hash != 'unknown' ) SELECT UUID() id, '{rule_run_id}', player_id, event_id, ip_address, cnt, '{self.config.process_from}', '{self.config.process_until}', now() created_at FROM same_ip_regs WHERE cnt&gt;1<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0430\u0433\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435\u0445 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0444\u0440\u043e\u0434-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439:<\/p>\n<pre><code class=\"python\">def generate_rules_select_sql(self):     rules_select_sql = []      for rule in all_rules:         rule_sql = f'''             SELECT player_id, '{rule[\"slug\"]}' rule_slug, rule_run_id             FROM {rule[\"tablename\"]}             WHERE created_at &gt;= date_add(now(), -{self.config.process_lookback})             GROUP BY player_id, rule_slug, rule_run_id         '''         rules_select_sql.append(rule_sql)      return ' UNION ALL '.join(rules_select_sql)   async def run_etl(self):     rules_data_sql = self.generate_rules_select_sql()      insert_sql = f'''         INSERT INTO fraud_user         (             id,             player_id,             rule_slug,             rule_run_id,             created_at,             load_day         )         WITH all_users AS (             {rules_data_sql}         )         SELECT UUID() id, au.player_id, au.rule_slug, au.rule_run_id,             now() created_at, to_date(now()) load_day         FROM all_users au         LEFT ANTI JOIN fraud_user fu             USING(rule_run_id)     '''      await impala.execute(insert_sql)<\/code><\/pre>\n<p>\u0418, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u043c \u0432\u0441\u0435 \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f:<\/p>\n<pre><code class=\"sql\">INSERT INTO fraud_event (     id,     event_id,     player_id,     rule_slug,     rule_run_id,     created_at,     load_day ) SELECT UUID() id,     fn.event_id,     fn.player_id,     fu.rule_slug,     fu.rule_run_id,     now() created_at,     to_date(now()) load_day FROM fraud_user fu INNER JOIN raw_event fn     ON fn.player_id = fu.player_id LEFT ANTI JOIN fraud_event fe     ON fe.event_id = fn.event_id AND fe.rule_run_id = fu.rule_run_id WHERE fn.dt&gt;= date_add(to_date(now()), -{self.config.process_lookback_for_events})     AND fu.load_day&gt;=date_add(to_date(now()), -{self.config.process_lookback_for_users})<\/code><\/pre>\n<p>\u0418\u0442\u043e\u0433\u043e: \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0432 \u0441\u043e\u0442\u043d\u0438 \u0442\u044b\u0441\u044f\u0447 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0437\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439, \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0438\u043d\u0443\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u0430. \u0427\u0430\u0441\u0442\u043e \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e: \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a \u0441\u043c\u043e\u0442\u0440\u0438\u0442, \u043a\u0430\u043a\u0438\u0435 \u0444\u0440\u043e\u0434-\u0441\u043e\u0431\u044b\u0442\u0438\u044f \u043d\u0430\u0439\u0434\u0435\u043d\u044b, \u043a\u0430\u043a\u0438\u0435 \u0438\u0445 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0438 \u0432\u0441\u0435 \u043b\u0438 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0442\u0430\u043a, \u043a\u0430\u043a \u043e\u0436\u0438\u0434\u0430\u043b\u043e\u0441\u044c. \u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u0435 \u0442\u0430\u043a \u2013 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438.&nbsp;Impala \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u0430\u043a\u0438\u0445 \u0443\u0433\u043e\u0434\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0437\u0430\u0445, \u0447\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.&nbsp;\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441 \u0440\u0430\u0437\u0431\u0438\u0432\u043a\u043e\u0439 \u043f\u043e \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u044f\u043c \u0438 \u0441\u0442\u0440\u0430\u043d\u0430\u043c:<\/p>\n<pre><code class=\"sql\">WITH \/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0444\u0440\u043e\u0434-\u044d\u0432\u0435\u043d\u0442\u043e\u0432, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u043d\u0443\u0436\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c filtered_fraud_event AS (     SELECT * FROM fraud_event     WHERE fraud_event.rule_slug IN (&lt;list_of_required_rules&gt;) ), \/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0444\u0440\u043e\u0434-\u044d\u0432\u0435\u043d\u0442\u043e\u0432, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u043d\u0443\u0436\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0435\u0439 fraud_events_wo_dups AS (     SELECT * FROM (         SELECT *, ROW_NUMBER() OVER (PARTITION BY event_id ORDER BY event_id) AS rn FROM filtered_fraud_event     ) AS t     WHERE t.rn=1 ), \/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0444\u0440\u043e\u0434-\u044d\u0432\u0435\u043d\u0442\u043e\u0432, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u043d\u0443\u0436\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u0431\u0435\u0437 \u0434\u0443\u0431\u043b\u0435\u0439 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430 fraud_events_wo_dups_by_rules AS (     SELECT * FROM (         SELECT *, ROW_NUMBER() OVER (PARTITION BY event_id, rule_slug ORDER BY event_id) AS rn FROM filtered_fraud_event     ) AS t     WHERE t.rn=1 ), \/\/ \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0441 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u044f\u043c\u0438, \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043f\u043e \u0434\u0430\u0442\u0430\u043c, \u044d\u0432\u0435\u043d\u0442\u0430\u043c \u0438 \u043a\u0430\u043c\u043f\u0430\u043d\u0438\u044f\u043c augmented_click_event AS (     SELECT campaign.full_name, click_event.country, click_event.event_id, click_event.event_name     FROM click_event     LEFT JOIN campaign ON campaign.id=click_event.campaign_id     WHERE          click_event.event_dt &lt;= '{self.config.report_to}'          AND click_event.event_dt &gt;= '{self.config.report_from}'          AND click_event.event_name IN ('registration')          AND click_event.campaign_id IN (&lt;list_of_required_campaigns&gt;) )   \/\/ \u0421\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u0440\u0438\u043a\u0438. \u0417\u0430\u043f\u0438\u0441\u0438 \u0441 layer=1 - \u0441\u0430\u043c\u0438 \u044d\u0432\u0435\u043d\u0442\u044b, \u043f\u043e \u0442\u0438\u043f\u0430\u043c. \u0421 layer=2 - \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0435 \u044d\u0432\u0435\u043d\u0442\u044b \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u043f\u0440\u0430\u0432\u0438\u043b. \u0421 layer=3 - \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0435 \u044d\u0432\u0435\u043d\u0442\u044b \u043f\u043e \u0442\u0438\u043f\u0430\u043c \u044d\u0432\u0435\u043d\u0442\u043e\u0432. \/\/ \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437 layer-\u043e\u0432 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0434\u0438\u043d \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043e\u043f\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. SELECT     ZEROIFNULL(SUM(CASE WHEN raw_data.layer = 1 THEN raw_data.event_count ELSE 0 END)) AS 'event_count',     ZEROIFNULL(SUM(CASE WHEN raw_data.layer = 1 and raw_data.event_name='registration' THEN raw_data.event_count ELSE 0 END)) AS 'event_count.registration',     ZEROIFNULL(SUM(CASE WHEN raw_data.layer = 3 THEN raw_data.fraud_event_count ELSE 0 END)) AS 'fraud_event_count',     ZEROIFNULL(SUM(CASE WHEN raw_data.layer = 3 and raw_data.event_name='registration' THEN raw_data.fraud_event_count ELSE 0 END)) AS 'fraud_event_count.registration',     ZEROIFNULL(SUM(CASE WHEN raw_data.layer = 2 and raw_data.rule_slug='&lt;rule_name&gt;' THEN raw_data.fraud_event_count ELSE 0 END)) AS 'fraud_rule_count.&lt;rule_name&gt;',     ...&lt;the_same_block_for_each_fraud_rule&gt;...       raw_data.country, raw_data.full_name FROM (     SELECT          augmented_click_event.country,          augmented_click_event.event_name,         augmented_click_event.full_name,         null AS rule_slug,         COUNT(augmented_click_event.event_id) AS event_count,         0 AS fraud_event_count,         1 AS layer     FROM augmented_click_event     GROUP BY augmented_click_event.country, augmented_click_event.event_name, augmented_click_event.full_name       UNION ALL       SELECT          augmented_click_event.country,          augmented_click_event.event_name,          augmented_click_event.full_name,         null AS rule_slug,         0 AS event_count,         count(fraud_events_wo_dups.event_id) AS fraud_event_count,         3 AS layer     FROM augmented_click_event     LEFT JOIN fraud_events_wo_dups     ON fraud_events_wo_dups.event_id=augmented_click_event.event_id     WHERE fraud_events_wo_dups.event_id IS NOT NULL     GROUP BY augmented_click_event.country, augmented_click_event.event_name, augmented_click_event.full_name       UNION ALL       SELECT          augmented_click_event.country,          augmented_click_event.event_name,          augmented_click_event.full_name,         fraud_events_wo_dups_by_rules.rule_slug AS rule_slug,         0 AS event_count,         count(fraud_events_wo_dups_by_rules.event_id) AS fraud_event_count,         2 AS layer     FROM augmented_click_event     LEFT JOIN fraud_events_wo_dups_by_rules     ON fraud_events_wo_dups_by_rules.event_id=augmented_click_event.event_id     WHERE          fraud_events_wo_dups_by_rules.event_id IS NOT NULL          AND fraud_events_wo_dups_by_rules.rule_slug IN (&lt;list_of_required_rules&gt;)     GROUP BY          augmented_click_event.country,          augmented_click_event.event_name,          augmented_click_event.full_name,          fraud_events_wo_dups_by_rules.rule_slug ) AS raw_data   GROUP BY raw_data.country, raw_data.full_name ORDER BY raw_data.country, raw_data.full_name<\/code><\/pre>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c&nbsp;\u043a\u0440\u0430\u0441\u0438\u0432\u0443\u044e&nbsp;\u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0443, \u043f\u043e\u043d\u044f\u0442\u043d\u0443\u044e \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fcd\/a81\/72b\/fcda8172b6d4e2cf22b3ffb79550497c.png\" width=\"1015\" height=\"1022\"><figcaption><\/figcaption><\/figure>\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\/wargaming\/blog\/550722\/\"> https:\/\/habr.com\/ru\/company\/wargaming\/blog\/550722\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442.<\/p>\n<p>\u041a\u0430\u043a \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0435\u0441\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043d\u0438\u0445 \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u043d\u044b \u043d\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445. \u0415\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u043e\u043b\u044c\u0448\u0435, \u0442\u043e \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u0435\u0441\u0442\u0438 \u0441\u0435\u0431\u044f \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u043e. \u042d\u0442\u0438\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043b\u0438\u0448\u0435\u043d\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0431\u0430\u0437\u0435 Hadoop, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 HDFS. \u041f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0432 \u0432\u0435\u0431-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435, \u043d\u043e \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u044b \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u043e\u0432.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c (\u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430\u043c&nbsp;\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438) \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0443 \u0437\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043a\u043b\u0438\u043a\u043e\u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043d\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u0445 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u044f\u0445, \u0438\u0437\u043c\u0435\u0440\u044f\u044e\u0449\u0438\u0445\u0441\u044f \u0432 \u0441\u043e\u0442\u043d\u044f\u0445 \u043c\u0438\u043b\u043b\u0438\u043e\u043d\u043e\u0432 \u0432 \u043c\u0435\u0441\u044f\u0446, \u043e\u0442\u0433\u043e\u0432\u043e\u0440\u043a\u0430 \u0432 \u0434\u0443\u0445\u0435 \u201c\u043d\u0443\u0443&#8230; \u043d\u0430\u0448 postgres \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0442\u0430\u043a\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438\u201d \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0411\u0435\u0437 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0442\u0443\u0442 \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c. \u041c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, Clickhouse, Snowflake \u0438 \u0442.\u0434., \u043d\u043e&nbsp;\u0432&nbsp;\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438&nbsp;\u0443\u0436\u0435 \u0431\u044b\u043b\u0430 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438 \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430 Impala \u0438 Hive. \u041f\u0435\u0440\u0432\u0430\u044f \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u0412\u0442\u043e\u0440\u043e\u0439 \u2013 \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0435 \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0434\u0438\u0441\u043a\u043e\u043c. \u041d\u0438\u043a\u0442\u043e \u043d\u0435 \u043b\u044e\u0431\u0438\u0442 \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u044b\u043b\u0430 \u0432\u044b\u0431\u0440\u0430\u043d\u0430 Impala.<\/p>\n<p>\u041d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u043d\u0435 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0414\u043e\u0441\u0442\u0443\u043f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0447\u0442\u0435\u043d\u0438\u0435. \u041d\u0438\u043a\u0430\u043a\u0438\u0445 update, delete, etc (\u0437\u0430 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435\u043c Kudu, \u043e \u0447\u0435\u043c \u0440\u0435\u0447\u044c \u0447\u0443\u0442\u044c \u043d\u0438\u0436\u0435).<\/p>\n<\/li>\n<li>\n<p>\u0413\u0438\u0433\u0430\u0431\u0430\u0439\u0442\u044b\u2026 \u043d\u0435\u0442, \u0442\u0435\u0440\u0430\u0431\u0430\u0439\u0442\u044b \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u041a\u0430\u043a \u0432 python \u043d\u0435\u0442\u0443 ORM \u0434\u043b\u044f Impala? \u041a\u0430\u043a\u043e\u0435 \u0435\u0449\u0435 ODBC?<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u043c \u0438\u0437 1000 \u0438 1 000 000 \u0441\u0442\u0440\u043e\u043a \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0442 \u0441\u0440\u0430\u0432\u043d\u0438\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f.<\/p>\n<\/li>\n<li>\n<p>\u041d\u0438\u043a\u0430\u043a\u0438\u0445 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u0438 \u043f\u0440\u043e\u0447\u0438\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0422\u043e\u0440\u043c\u043e\u0437\u0438\u0442? \u0422\u043e, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u0432\u0435\u0442\u0430 \u0438\u0437\u043c\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445 \u0438 \u0434\u0435\u0441\u044f\u0442\u043a\u0430\u0445 \u0441\u0435\u043a\u0443\u043d\u0434, \u0445\u043e\u0440\u043e\u0448\u043e \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043e\u0442\u0447\u0435\u0442\u043e\u0432, \u043d\u043e \u0442\u0430\u043a \u0441\u0435\u0431\u0435 \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0432 real-time\u2019\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u043f\u0430\u043c\u044f\u0442\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443, \u0431\u043b\u0430\u0433\u043e \u0447\u0442\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0435\u0441\u0442\u044c \u0434\u0430\u0442\u0430. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0442\u0430\u043a \u0436\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0438\u043b\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0432\u0441\u0435\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b, \u0438\u043b\u0438 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438.<\/p>\n<\/li>\n<\/ul>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u0440\u044f\u0436\u0435\u043d\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043a\u043b\u0430\u0441\u0442\u0435\u0440 \u0438\u0437 30 \u043d\u043e\u0434 \u0441&nbsp;\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0432 90 \u0413\u0411 \u043f\u0430\u043c\u044f\u0442\u0438 \u043d\u0430 \u043d\u043e\u0434\u0435 \u0438 1 \u0422\u0411 \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e.&nbsp;\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u2013 Hue (&#171;\u0425\u044c\u044e&#187;) \u2013 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0443\u0434\u043e\u0431\u043d\u044b\u0439 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0434\u043b\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.<\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Impala \u0434\u043b\u044f python-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0442&nbsp;\u0440\u0430\u0431\u043e\u0442\u044b&nbsp;\u0441 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u044b\u043c\u0438 \u0411\u0414. \u0414\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0432\u0441\u0435\u0433\u043e 2 \u2013 impyla \u0438 cloudera odbc. \u0421 \u043f\u0435\u0440\u0432\u044b\u043c \u043a\u043e\u0433\u0434\u0430-\u0442\u043e \u0434\u0430\u0432\u043d\u043e \u0431\u044b\u043b \u043f\u043b\u043e\u0445\u043e\u0439 \u043e\u043f\u044b\u0442, \u043f\u043b\u044e\u0441 \u0443 \u043d\u0435\u0433\u043e \u043a\u0443\u0447\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 issue \u043d\u0430 \u0433\u0438\u0442\u0445\u0430\u0431\u0435. \u0420\u0435\u0448\u0435\u043d\u043e \u0431\u044b\u043b\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u0447\u0430\u0442\u044c \u0441\u0430\u043c \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440 \u0441 \u0441\u0430\u0439\u0442\u0430, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u0438 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c pyodbc. \u0422.\u043a. \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0435, \u0432\u043c\u0435\u0441\u0442\u043e pyodbc \u0443 \u043d\u0430\u0441 aioodbc \u2013 \u043e\u0431\u0435\u0440\u0442\u043a\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 pyodbc.<\/p>\n<pre><code class=\"python\">def _convert_timestamp(value):     unpacked = struct.unpack('6Hxxxx', value)     if unpacked == (1970, 1, 1, 0, 0, 0):         return None     return datetime(*unpacked)     class Impala:     def __init__(self):         self.dsn = (             f'DRIVER={{{cfg.impala_driver}}};'             f'HOST={{{cfg.impala_host}}};'             f'PORT={{{cfg.impala_port}}};'             f'SCHEMA={{{cfg.impala_default_schema}}};'             f'UID={{{cfg.impala_uid}}};'             f'PWD={{{cfg.impala_pwd}}};'             f'AUTHMECH=3;'             f'USESASL=1;'             f'SSL=0;'         )           self.pool: Optional[Pool] = None       async def connect(self):         self.pool: Pool = await create_pool(             minsize=cfg.impala_min_poolsize,             maxsize=cfg.impala_max_poolsize,             dsn=self.dsn,             after_created=self.after_created,             autocommit=True,             pool_recycle=55,         )           async with self.pool.acquire() as connection:             async with connection.cursor() as cursor:                 cursor: Cursor                   result = await cursor.execute('select 1')                 await result.fetchone()       async def disconnect(self):         if self.pool is not None:             self.pool.close()             await self.pool.wait_closed()       @staticmethod     async def after_created(connection):         # Driver return zero date values incorrectly         connection.add_output_converter(SQL_TYPE_TIMESTAMP, _convert_timestamp)           connection.setdecoding(SQL_CHAR, encoding='utf-8')         connection.setdecoding(SQL_WCHAR, encoding='utf-8')         connection.setdecoding(SQL_WMETADATA, encoding='utf-16')         connection.setencoding(encoding='utf-8')       async def _run_with_retries(         self,         query,         *params,         retries=0,         max_retries=cfg.impala_max_retries,     ):         try:             async with self.pool.acquire() as connection:                 async with connection.cursor() as cursor:                     result = await cursor.execute(query, *params)                     return await getattr(result, 'execute').__call__()         except Error as e:             if retries &lt; max_retries:                 retries += 1                 return await self._run_with_retries(                     query,                     *params,                     retries=retries,                     max_retries=max_retries,                 )             raise       async def execute(self, query, *params):         return await self._run_with_retries(query, *params)       @staticmethod     def to_python(data: Union[List[Row], Row]) -&gt; Union[List[dict], dict]:         if isinstance(data, List):             return list(map(Impala.to_python, data))           return {info[0]: data[i] for i, info in enumerate(data.cursor_description)}<\/code><\/pre>\n<p>\u0421\u0432\u044f\u0437\u043a\u0430 \u0438\u0437 \u0441\u0430\u043c\u043e\u0439 Impala \u0438 \u0435\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0443\u043f\u0430\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0411\u0414, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 retry-\u0438 \u2013 \u043d\u0430\u0448\u0435 \u0432\u0441\u0435. \u0422\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0441\u0451 \u0437\u0430\u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0431\u043e\u043b\u0435\u0435-\u043c\u0435\u043d\u0435\u0435 \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e.<\/p>\n<p>\u041f\u0440\u043e \u041e\u0420\u041c \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u2013 \u0435\u0433\u043e \u043d\u0435\u0442. \u041c\u043e\u0436\u0435\u0442, \u044d\u0442\u043e \u0438 \u043a \u043b\u0443\u0447\u0448\u0435\u043c\u0443, \u0442.\u043a. \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u041e\u0420\u041c \u0432\u044b\u0433\u043b\u044f\u0434\u044f\u0442 \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e, \u043f\u0438\u0441\u0430\u0442\u044c raw-sql \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435, \u0438 \u043a\u043e\u0434 \u043b\u0443\u0447\u0448\u0435 \u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f. \u041d\u043e \u043e\u0442\u0441\u044e\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u043a \u2013 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f \u0434\u043b\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0439 \u0441\u0445\u0435\u043c\u044b \u0442\u0430\u0431\u043b\u0438\u0446. \u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432\u0440\u0443\u0447\u043d\u0443\u044e,&nbsp;\u043d\u043e \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 (\u0438\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445 \u0443\u0436\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435?)<\/p>\n<p>SELECT-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a Impala \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u044e\u0442\u0441\u044f \u043e\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u043e\u0431\u044b\u0447\u043d\u044b\u043c \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0411\u0414:<\/p>\n<ul>\n<li>\n<p>\u041b\u044e\u0431\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0434\u0435\u043b\u0430\u0435\u0442 full scan, \u0442.\u043a. \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u0432 \u043d\u0435\u0442\u0443, \u0438 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u0442 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u044c. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0436\u0435\u043b\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u043f\u043e \u043d\u0438\u043c. \u041f\u043e \u0441\u0443\u0442\u0438, \u043e\u0434\u043d\u0430 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u044f \u2013 \u043e\u0434\u0438\u043d \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435. \u041c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0439 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d\u043e \u2013 \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 Impala, \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430\u043c\u0438 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c\u0438. \u0422.\u043a. \u0443 \u043d\u0430\u0441 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e\u043c \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0437\u0430\u043f\u0438\u0441\u0435\u0439, \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c Parquet \u2013 \u043e\u043d \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0447\u0438\u0442\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 \u0438 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e Parquet \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0442\u0443\u0442:&nbsp;<a href=\"https:\/\/www.bigdataschool.ru\/blog\/apache-parquet-avro-spark-big-data.html\">https:\/\/www.bigdataschool.ru\/blog\/apache-parquet-avro-spark-big-data.html<\/a><\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445 Impala \u043f\u0435\u0440\u0435\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u0432\u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0438 \u0437\u043d\u0430\u043b\u0430, \u0433\u0434\u0435 \u0438 \u043a\u0430\u043a\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0435\u0436\u0430\u0442,&nbsp;\u043d\u0443\u0436\u043d\u043e \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443&nbsp;(COMPUTE STATS), \u0438\u043d\u0430\u0447\u0435 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043e\u0447\u0435\u043d\u044c \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<\/ul>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u0431\u0435\u0437 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u043b\u0438\u0431\u043e \u0438\u0445 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f (\u043f\u0440\u0438\u0432\u0435\u0442, GDPR) \u043d\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c. Impala \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0442\u0430\u043a \u043d\u0435 \u0443\u043c\u0435\u0435\u0442, \u043a\u0440\u043e\u043c\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u043f\u0430\u0440\u0442\u0438\u0446\u0438\u0438 \u0446\u0435\u043b\u0438\u043a\u043e\u043c.&nbsp;\u0422\u0443\u0442 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 KUDU. \u042d\u0442\u043e \u0434\u0432\u0438\u0436\u043e\u043a \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0432\u043c\u0435\u0449\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0438\u0441\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e primary key \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u0440\u043e\u043a, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u0439 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0441\u0442\u043e\u043b\u0431\u0446\u0430\u043c. \u0414\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f KUDU \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c primary key (\u043e\u0434\u043d\u043e \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u0435\u0439), \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c DELETE \u0438 UPSERT, \u0430 \u0441\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043c\u0435\u0442\u044c \u0447\u0435\u0442\u043a\u0443\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u2013 \u0436\u0435\u0441\u0442\u043a\u043e \u0437\u0430\u0434\u0430\u043d\u044b \u043f\u043e\u043b\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0438 \u0438\u0445 \u0442\u0438\u043f\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c, KUDU \u043d\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0438\u043f\u044b \u043f\u043e\u043b\u0435\u0439 (CHAR, DATE, etc.), \u0438, \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0445\u043e\u0440\u043e\u0448\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043c\u0430\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u0445. \u041c\u044b \u0440\u0435\u0448\u0438\u043b\u0438 \u043c\u0438\u0440\u0438\u0442\u044c\u0441\u044f \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u0430\u043c\u0438, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438. \u0427\u0442\u043e \u0432\u0430\u0436\u043d\u043e: \u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043a KUDU \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 Impala. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 Impala \u0443\u0436\u0435 \u043f\u0440\u0438\u0431\u043b\u0438\u0436\u0430\u044e\u0442\u0441\u044f \u043a&nbsp;\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c \u0440\u0435\u043b\u044f\u0446\u0438\u043e\u043d\u043d\u044b\u0445 \u0411\u0414, \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435.<\/p>\n<p>\u0418\u043c\u0435\u044f \u044d\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435. \u041a\u043e\u043c\u043f\u0430\u043d\u0438\u044f \u043f\u043b\u0430\u0442\u0438\u0442 \u0437\u0430 \u0440\u0435\u043a\u043b\u0430\u043c\u0443 \u043f\u043e\u0441\u0442\u0430\u0432\u0449\u0438\u043a\u0430\u043c \u0442\u0440\u0430\u0444\u0438\u043a\u0430 (Google, Yandex \u0438 \u0434\u0440.). \u0415\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u043e\u0434\u0435\u043b\u0435\u0439 \u043e\u043f\u043b\u0430\u0442\u044b: \u0437\u0430 \u043a\u043b\u0438\u043a\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u043f\u043e \u0431\u0430\u043d\u043d\u0435\u0440\u0443, \u0437\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0437\u0430 \u043f\u043e\u043a\u0430\u0437\u044b \u0431\u0430\u043d\u043d\u0435\u0440\u043e\u0432 \u0438 \u0442.\u0434. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u0441\u044f\u043a\u0438\u0435 \u043d\u0435\u0434\u043e\u0431\u0440\u043e\u0436\u0435\u043b\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0434\u0435\u043b\u0430\u0442\u044c (\u0438 \u0434\u0435\u043b\u0430\u044e\u0442) \u043d\u0430\u043a\u0440\u0443\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u0438\u043d\u0430\u0447\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u0444\u0440\u043e\u0434. \u041d\u0430\u0448\u0430 \u0437\u0430\u0434\u0430\u0447\u0430 \u2013 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0442\u0430\u043a\u0438\u0435 \u043d\u0430\u043a\u0440\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438 \u043d\u0435 \u043f\u043b\u0430\u0442\u0438\u0442\u044c \u0437\u0430 \u043d\u0438\u0445.<\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442, click_event \u2013 \u0434\u0430\u043d\u043d\u044b\u0435&nbsp;\u043f\u043e \u0440\u0435\u043a\u043b\u0430\u043c\u043d\u044b\u043c \u043a\u043b\u0438\u043a\u0430\u043c&nbsp;\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u044f\u043c, \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u0440\u0438\u0432\u0435\u043b\u0438 \u044d\u0442\u0438 \u043a\u043b\u0438\u043a\u0438 (\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438, \u043b\u043e\u0433\u0438\u043d\u044b \u0432 \u0438\u0433\u0440\u0443, \u043f\u043b\u0430\u0442\u0435\u0436\u0438 \u0438 \u0442.\u0434.).<\/p>\n<p>\u0415\u0441\u0442\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0449\u0438\u0445 \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f,&nbsp;\u0443 \u043d\u0430\u0441 \u0438\u0445 \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u0441\u044f\u0442\u043a\u043e\u0432. \u041e\u0431\u0449\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0444\u0438\u0447\u0438 \u0442\u0430\u043a\u043e\u0432\u0430: \u0440\u0430\u0437 \u0432 \u0441\u0443\u0442\u043a\u0438 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441 \u0444\u0440\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u0430\u0432\u0438\u043b\u0430. \u0417\u0430\u0442\u0435\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0430\u0433\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0432\u0441\u0435\u0445 \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 \u043e\u0434\u0438\u043d \u0434\u0430\u0442\u0430\u0441\u0435\u0442. \u0418 \u043f\u043e\u0442\u043e\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0441\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432\u0441\u0435 \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0432\u0441\u0435\u0445 \u0444\u0440\u043e\u0434\u043e\u0432\u044b\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u2013 \u044d\u0442\u043e \u0438 \u0435\u0441\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430.<\/p>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0444\u0440\u043e\u0434\u0430: \u0435\u0441\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u043e\u0434\u043d\u043e\u0433\u043e IP-\u0430\u0434\u0440\u0435\u0441\u0430, \u0442\u043e \u044d\u0442\u043e \u0444\u0440\u043e\u0434.<\/p>\n<pre><code class=\"sql\">UPSERT INTO {self.model.get_tablename()} (     id,     rule_run_id,     player_id,     event_id,     ip_hash,     regs_cnt,     analysed_start_day,     analysed_end_day,     created_at ) WITH same_ip_regs AS (     SELECT         CE.campaign_id,         CE.campaign_sub_id,         CE.player_id,         CE.event_id,         CE.ip_hash ip_address,         count(CE.event_id) OVER (PARTITION BY campaign_id, campaign_sub_id, CE.ip_hash) cnt     FROM click_event CE     WHERE         TO_DATE(CE.event_dt) = '{self.config.process_from}' AND         CE.event_name='registration' AND         CE.ip_hash != 'unknown' ) SELECT UUID() id, '{rule_run_id}', player_id, event_id, ip_address, cnt, '{self.config.process_from}', '{self.config.process_until}', now() created_at FROM same_ip_regs WHERE cnt&gt;1<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0430\u0433\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435\u0445 \u043d\u0430\u0439\u0434\u0435\u043d\u043d\u044b\u0445 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c\u0438 \u0444\u0440\u043e\u0434-\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439:<\/p>\n<pre><code class=\"python\">def generate_rules_select_sql(self):     rules_select_sql = []      for rule in all_rules:         rule_sql = f'''             SELECT player_id, '{rule[\"slug\"]}' rule_slug, rule_run_id             FROM {rule[\"tablename\"]}             WHERE created_at &gt;= date_add(now(),<\/code><\/pre>\n<\/div>\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-320902","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320902","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=320902"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/320902\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320902"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320902"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}