久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='5zbEL'></bdo><ul id='5zbEL'></ul>

      <small id='5zbEL'></small><noframes id='5zbEL'>

      <tfoot id='5zbEL'></tfoot>
    1. <legend id='5zbEL'><style id='5zbEL'><dir id='5zbEL'><q id='5zbEL'></q></dir></style></legend>

    2. <i id='5zbEL'><tr id='5zbEL'><dt id='5zbEL'><q id='5zbEL'><span id='5zbEL'><b id='5zbEL'><form id='5zbEL'><ins id='5zbEL'></ins><ul id='5zbEL'></ul><sub id='5zbEL'></sub></form><legend id='5zbEL'></legend><bdo id='5zbEL'><pre id='5zbEL'><center id='5zbEL'></center></pre></bdo></b><th id='5zbEL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='5zbEL'><tfoot id='5zbEL'></tfoot><dl id='5zbEL'><fieldset id='5zbEL'></fieldset></dl></div>

        在 SparkSQL 中使用窗口函數 (dense_rank()) 進行選擇

        select with window function (dense_rank()) in SparkSQL(在 SparkSQL 中使用窗口函數 (dense_rank()) 進行選擇)
        <i id='sKaUx'><tr id='sKaUx'><dt id='sKaUx'><q id='sKaUx'><span id='sKaUx'><b id='sKaUx'><form id='sKaUx'><ins id='sKaUx'></ins><ul id='sKaUx'></ul><sub id='sKaUx'></sub></form><legend id='sKaUx'></legend><bdo id='sKaUx'><pre id='sKaUx'><center id='sKaUx'></center></pre></bdo></b><th id='sKaUx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='sKaUx'><tfoot id='sKaUx'></tfoot><dl id='sKaUx'><fieldset id='sKaUx'></fieldset></dl></div>
          <bdo id='sKaUx'></bdo><ul id='sKaUx'></ul>

            <tbody id='sKaUx'></tbody>

        • <small id='sKaUx'></small><noframes id='sKaUx'>

          1. <tfoot id='sKaUx'></tfoot>
              <legend id='sKaUx'><style id='sKaUx'><dir id='sKaUx'><q id='sKaUx'></q></dir></style></legend>

                  本文介紹了在 SparkSQL 中使用窗口函數 (dense_rank()) 進行選擇的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有一個包含客戶購買記錄的表格,我需要指定購買是在特定日期時間窗口內進行的,一個窗口是 8 天,所以如果我今天購買了 5 天內購買了一次,那么如果窗口號是我的購買1,但如果我在今天的第一天和 8 天后的第二天這樣做,第一次購買將在窗口 1 中,最后一次購買將在窗口 2 中

                  I have a table which contains records for customer purchases, I need to specify that purchase was made in specific datetime window one window is 8 days , so if I had purchase today and one in 5 days its mean my purchase if window number 1, but if I did it on day one today and next in 8 days, first purchase will be in window 1 and the last purchase in window 2

                  create temporary table transactions
                   (client_id int,
                   transaction_ts datetime,
                   store_id int)
                  
                   insert into transactions values 
                   (1,'2018-06-01 12:17:37', 1),
                   (1,'2018-06-02 13:17:37', 2),
                   (1,'2018-06-03 14:17:37', 3),
                   (1,'2018-06-09 10:17:37', 2),
                   (2,'2018-06-02 10:17:37', 1),
                   (2,'2018-06-02 13:17:37', 2),
                   (2,'2018-06-08 14:19:37', 3),
                   (2,'2018-06-16 13:17:37', 2),
                   (2,'2018-06-17 14:17:37', 3)
                  

                  窗口是8天,問題是我不明白如何指定dense_rank() OVER (PARTITION BY)查看日期時間并在8天內制作一個窗口,結果我需要這樣的東西

                  the window is 8 days, the problem is I don't understand how to specify for dense_rank() OVER (PARTITION BY) to look at datetime and make a window in 8 days, as result I need something like this

                  1,'2018-06-01 12:17:37', 1,1
                  1,'2018-06-02 13:17:37', 2,1
                  1,'2018-06-03 14:17:37', 3,1
                  1,'2018-06-09 10:17:37', 2,2
                  2,'2018-06-02 10:17:37', 1,1
                  2,'2018-06-02 13:17:37', 2,1
                  2,'2018-06-08 14:19:37', 3,2
                  2,'2018-06-16 13:17:37', 2,3
                  2,'2018-06-17 14:17:37', 3,3
                  

                  知道如何獲得它嗎?我可以在 Mysql 或 Spark SQL 中運行它,但 Mysql 不支持分區.還是找不到解決辦法!任何幫助

                  any idea how to get it? I can run it in Mysql or Spark SQL, but Mysql doesn't support partition. Still cannot find solution! any help

                  推薦答案

                  很可能你可以在 Spark SQL 中使用時間和分區窗口函數來解決這個問題:

                  Most likely you may solve this in Spark SQL using time and partition window functions:

                  val purchases = Seq((1,"2018-06-01 12:17:37", 1), (1,"2018-06-02 13:17:37", 2), (1,"2018-06-03 14:17:37", 3), (1,"2018-06-09 10:17:37", 2), (2,"2018-06-02 10:17:37", 1), (2,"2018-06-02 13:17:37", 2), (2,"2018-06-08 14:19:37", 3), (2,"2018-06-16 13:17:37", 2), (2,"2018-06-17 14:17:37", 3)).toDF("client_id", "transaction_ts", "store_id")
                  
                  purchases.show(false)
                  +---------+-------------------+--------+
                  |client_id|transaction_ts     |store_id|
                  +---------+-------------------+--------+
                  |1        |2018-06-01 12:17:37|1       |
                  |1        |2018-06-02 13:17:37|2       |
                  |1        |2018-06-03 14:17:37|3       |
                  |1        |2018-06-09 10:17:37|2       |
                  |2        |2018-06-02 10:17:37|1       |
                  |2        |2018-06-02 13:17:37|2       |
                  |2        |2018-06-08 14:19:37|3       |
                  |2        |2018-06-16 13:17:37|2       |
                  |2        |2018-06-17 14:17:37|3       |
                  +---------+-------------------+--------+
                  
                  
                  
                  val groupedByTimeWindow = purchases.groupBy($"client_id", window($"transaction_ts", "8 days")).agg(collect_list("transaction_ts").as("transaction_tss"), collect_list("store_id").as("store_ids"))
                  
                  val withWindowNumber = groupedByTimeWindow.withColumn("window_number", row_number().over(windowByClient))
                  
                  withWindowNumber.orderBy("client_id", "window.start").show(false)
                  
                      +---------+---------------------------------------------+---------------------------------------------------------------+---------+-------------+
                  |client_id|window                                       |transaction_tss                                                |store_ids|window_number|
                  +---------+---------------------------------------------+---------------------------------------------------------------+---------+-------------+
                  |1        |[2018-05-28 17:00:00.0,2018-06-05 17:00:00.0]|[2018-06-01 12:17:37, 2018-06-02 13:17:37, 2018-06-03 14:17:37]|[1, 2, 3]|1            |
                  |1        |[2018-06-05 17:00:00.0,2018-06-13 17:00:00.0]|[2018-06-09 10:17:37]                                          |[2]      |2            |
                  |2        |[2018-05-28 17:00:00.0,2018-06-05 17:00:00.0]|[2018-06-02 10:17:37, 2018-06-02 13:17:37]                     |[1, 2]   |1            |
                  |2        |[2018-06-05 17:00:00.0,2018-06-13 17:00:00.0]|[2018-06-08 14:19:37]                                          |[3]      |2            |
                  |2        |[2018-06-13 17:00:00.0,2018-06-21 17:00:00.0]|[2018-06-16 13:17:37, 2018-06-17 14:17:37]                     |[2, 3]   |3            |
                  +---------+---------------------------------------------+---------------------------------------------------------------+---------+-------------+
                  

                  如果需要,您可以explode 列出 store_ids 或 transaction_tss 中的元素.

                  If you need, you may explode list elements from store_ids or transaction_tss.

                  希望能幫到你!

                  這篇關于在 SparkSQL 中使用窗口函數 (dense_rank()) 進行選擇的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數根據 N 個先前值來決定接下來的 N 個行)
                  reuse the result of a select expression in the quot;GROUP BYquot; clause?(在“GROUP BY中重用選擇表達式的結果;條款?)
                  Does ignore option of Pyspark DataFrameWriter jdbc function ignore entire transaction or just offending rows?(Pyspark DataFrameWriter jdbc 函數的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環數組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發生錯誤 沒有合適的驅動程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數據庫表作為 Spark 數據幀讀取?)
                  <tfoot id='uq6ex'></tfoot>
                1. <i id='uq6ex'><tr id='uq6ex'><dt id='uq6ex'><q id='uq6ex'><span id='uq6ex'><b id='uq6ex'><form id='uq6ex'><ins id='uq6ex'></ins><ul id='uq6ex'></ul><sub id='uq6ex'></sub></form><legend id='uq6ex'></legend><bdo id='uq6ex'><pre id='uq6ex'><center id='uq6ex'></center></pre></bdo></b><th id='uq6ex'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='uq6ex'><tfoot id='uq6ex'></tfoot><dl id='uq6ex'><fieldset id='uq6ex'></fieldset></dl></div>

                    <tbody id='uq6ex'></tbody>

                        <legend id='uq6ex'><style id='uq6ex'><dir id='uq6ex'><q id='uq6ex'></q></dir></style></legend>

                        <small id='uq6ex'></small><noframes id='uq6ex'>

                            <bdo id='uq6ex'></bdo><ul id='uq6ex'></ul>
                            主站蜘蛛池模板: 国产99视频精品免费播放照片 | 久久日韩粉嫩一区二区三区 | 日本一区二区三区在线观看 | 久久久久1 | 91精品久久久久久久久久 | 超碰97免费在线 | 91视频在线 | 国产精品日产欧美久久久久 | 欧美电影在线观看网站 | 久久99精品久久久久久国产越南 | 国产精品久久久99 | 久久久久亚洲国产| 欧美情趣视频 | 久久九 | 国产区在线 | 久久毛片网站 | 亚洲午夜小视频 | 国产91在线 | 中日 | 日本精品一区二区三区视频 | 国产91视频一区二区 | 亚洲精品在线免费看 | 成人在线观看网址 | 色接久久 | www.99热.com| 97超碰在线免费 | 久久国| 在线视频一区二区 | 九九视频在线观看 | 亚洲精品一区中文字幕乱码 | 亚洲精品一区久久久久久 | 性在线| 成人免费观看视频 | 色欧美综合 | 久草在线青青草 | 国产精品久久久久久久午夜片 | 男女视频在线免费观看 | 久久精品久久精品久久精品 | 国产精品18毛片一区二区 | 国产精品亚洲精品久久 | 一区二区三区欧美在线 | 国产精品成av人在线视午夜片 |