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

  • <i id='rmjVK'><tr id='rmjVK'><dt id='rmjVK'><q id='rmjVK'><span id='rmjVK'><b id='rmjVK'><form id='rmjVK'><ins id='rmjVK'></ins><ul id='rmjVK'></ul><sub id='rmjVK'></sub></form><legend id='rmjVK'></legend><bdo id='rmjVK'><pre id='rmjVK'><center id='rmjVK'></center></pre></bdo></b><th id='rmjVK'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='rmjVK'><tfoot id='rmjVK'></tfoot><dl id='rmjVK'><fieldset id='rmjVK'></fieldset></dl></div>
      <legend id='rmjVK'><style id='rmjVK'><dir id='rmjVK'><q id='rmjVK'></q></dir></style></legend>

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

      • <bdo id='rmjVK'></bdo><ul id='rmjVK'></ul>
      <tfoot id='rmjVK'></tfoot>

      1. Spark SQL 和 MySQL- SaveMode.Overwrite 不插入修改的數(shù)據(jù)

        Spark SQL and MySQL- SaveMode.Overwrite not inserting modified data(Spark SQL 和 MySQL- SaveMode.Overwrite 不插入修改的數(shù)據(jù))
        • <tfoot id='BecoW'></tfoot>
            • <bdo id='BecoW'></bdo><ul id='BecoW'></ul>
              <i id='BecoW'><tr id='BecoW'><dt id='BecoW'><q id='BecoW'><span id='BecoW'><b id='BecoW'><form id='BecoW'><ins id='BecoW'></ins><ul id='BecoW'></ul><sub id='BecoW'></sub></form><legend id='BecoW'></legend><bdo id='BecoW'><pre id='BecoW'><center id='BecoW'></center></pre></bdo></b><th id='BecoW'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='BecoW'><tfoot id='BecoW'></tfoot><dl id='BecoW'><fieldset id='BecoW'></fieldset></dl></div>

                  <tbody id='BecoW'></tbody>

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

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

                1. 本文介紹了Spark SQL 和 MySQL- SaveMode.Overwrite 不插入修改的數(shù)據(jù)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在 MySQL 中有一個 test 表,其 ID 和名稱如下:

                  +----+-------+|身份證 |姓名 |+----+-------+|1 |姓名1 |+----+-------+|2 |姓名2 |+----+-------+|3 |姓名3 |+----+-------+

                  我正在使用 Spark DataFrame 讀取此數(shù)據(jù)(使用 JDBC)并像這樣修改數(shù)據(jù)

                  Datasetmodified = sparkSession.sql("select id, concat(name,' - new') as name from test");modified.write().mode("overwrite").jdbc(AppProperties.MYSQL_CONNECTION_URL,測試",連接屬性);

                  但我的問題是,如果我提供覆蓋模式,它會刪除以前的表并創(chuàng)建一個新表但不插入任何數(shù)據(jù).

                  我通過從 csv 文件(與測試表相同的數(shù)據(jù))讀取并覆蓋來嘗試相同的程序.那對我有用.

                  我在這里遺漏了什么嗎?

                  謝謝!

                  解決方案

                  問題出在您的代碼中.因為你覆蓋了一個你試圖從中讀取的表,所以在 Spark 可以實際訪問它之前,你有效地清除了所有數(shù)據(jù).

                  記住 Spark 是懶惰的.當您創(chuàng)建 Dataset 時,Spark 會獲取所需的元數(shù)據(jù),但不會加載數(shù)據(jù).所以沒有可以保留原始內容的魔法緩存.數(shù)據(jù)將在實際需要時加載.這是當您執(zhí)行 write 操作并且當您開始寫入時沒有更多數(shù)據(jù)要獲取時.

                  你需要的是這樣的:

                  • 創(chuàng)建一個數(shù)據(jù)集.
                  • 應用所需的轉換并將數(shù)據(jù)寫入中間 MySQL 表.

                  • TRUNCATE 原始輸入和 INSERT INTO ... SELECT 來自中間表或 DROP 原始表和 RENAME 中間表.

                  另一種但不太有利的方法是:

                  • 創(chuàng)建一個數(shù)據(jù)集.
                  • 應用所需的轉換并將數(shù)據(jù)寫入持久 Spark 表(df.write.saveAsTable(...) 或等效項)
                  • TRUNCATE 原始輸入.
                  • 讀回數(shù)據(jù)并保存 (spark.table(...).write.jdbc(...))
                  • 刪除 Spark 表.

                  我們不能過分強調使用 Spark cache/persist 不是正確的方法.即使使用保守的 StorageLevel (MEMORY_AND_DISK_2/MEMORY_AND_DISK_SER_2) 緩存數(shù)據(jù)也可能丟失(節(jié)點故障),導致無提示的正確性錯誤.>

                  I have a test table in MySQL with id and name like below:

                  +----+-------+
                  | id | name  |
                  +----+-------+
                  | 1  | Name1 |
                  +----+-------+
                  | 2  | Name2 |
                  +----+-------+
                  | 3  | Name3 |
                  +----+-------+
                  

                  I am using Spark DataFrame to read this data (using JDBC) and modifying the data like this

                  Dataset<Row> modified = sparkSession.sql("select id, concat(name,' - new') as name from test");
                  modified.write().mode("overwrite").jdbc(AppProperties.MYSQL_CONNECTION_URL,
                                  "test", connectionProperties);
                  

                  But my problem is, if I give overwrite mode, it drops the previous table and creates a new table but not inserting any data.

                  I tried the same program by reading from a csv file (same data as test table) and overwriting. That worked for me.

                  Am I missing something here ?

                  Thank You!

                  解決方案

                  The problem is in your code. Because you overwrite a table from which you're trying to read you effectively obliterate all data before Spark can actually access it.

                  Remember that Spark is lazy. When you create a Dataset Spark fetches required metadata, but doesn't load the data. So there is no magic cache which will preserve original content. Data will be loaded when it is actually required. Here it is when you execute write action and when you start writing there is no more data to be fetched.

                  What you need is something like this:

                  • Create a Dataset.
                  • Apply required transformations and write data to an intermediate MySQL table.

                  • TRUNCATE the original input and INSERT INTO ... SELECT from the intermediate table or DROP the original table and RENAME intermediate table.

                  Alternative, but less favorable approach, would be:

                  • Create a Dataset.
                  • Apply required transformations and write data to a persistent Spark table (df.write.saveAsTable(...) or equivalent)
                  • TRUNCATE the original input.
                  • Read data back and save (spark.table(...).write.jdbc(...))
                  • Drop Spark table.

                  We cannot stress enough that using Spark cache / persist is not the way to go. Even in with the conservative StorageLevel (MEMORY_AND_DISK_2 / MEMORY_AND_DISK_SER_2) cached data can be lost (node failures), leading to silent correctness errors.

                  這篇關于Spark SQL 和 MySQL- SaveMode.Overwrite 不插入修改的數(shù)據(jù)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關文檔推薦

                  How to use windowing functions efficiently to decide next N number of rows based on N number of previous values(如何有效地使用窗口函數(shù)根據(jù) 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 函數(shù)的 ignore 選項是忽略整個事務還是只是有問題的行?) - IT屋-程序員軟件開發(fā)技
                  Error while using INSERT INTO table ON DUPLICATE KEY, using a for loop array(使用 INSERT INTO table ON DUPLICATE KEY 時出錯,使用 for 循環(huán)數(shù)組)
                  pyspark mysql jdbc load An error occurred while calling o23.load No suitable driver(pyspark mysql jdbc load 調用 o23.load 時發(fā)生錯誤 沒有合適的驅動程序)
                  How to integrate Apache Spark with MySQL for reading database tables as a spark dataframe?(如何將 Apache Spark 與 MySQL 集成以將數(shù)據(jù)庫表作為 Spark 數(shù)據(jù)幀讀取?)
                    <bdo id='2y9Xm'></bdo><ul id='2y9Xm'></ul>

                    <small id='2y9Xm'></small><noframes id='2y9Xm'>

                    • <tfoot id='2y9Xm'></tfoot>

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

                          <tbody id='2y9Xm'></tbody>

                          <legend id='2y9Xm'><style id='2y9Xm'><dir id='2y9Xm'><q id='2y9Xm'></q></dir></style></legend>

                          1. 主站蜘蛛池模板: 伊久在线 | 91精品综合久久久久久五月天 | 男人天堂99 | 成人免费一区二区三区视频网站 | 看毛片网站| 日韩欧美在线观看 | 精品国产亚洲一区二区三区大结局 | 国产日屁 | 日韩激情一区 | 国产精品美女在线观看 | 午夜爽爽爽男女免费观看 | 日韩av成人 | 国产欧美精品 | 欧美久久一区二区三区 | 日韩欧美网 | 中文区中文字幕免费看 | 成人高清网站 | 久久在线| 日本一级淫片免费啪啪3 | 一级a毛片| 久久久久国产一区二区三区四区 | 亚洲国产欧美日韩 | 亚洲欧美国产一区二区三区 | 全免费a级毛片免费看视频免 | 午夜天堂精品久久久久 | 精品一二区 | 久久最新网址 | 精品少妇一区二区三区在线播放 | 国产羞羞视频在线观看 | 精久久久久 | 男女爱爱网站 | 亚洲视频欧美视频 | 久久9久 | 自拍偷拍小视频 | 在线观看电影av | 午夜精品一区二区三区在线观看 | 国产农村一级国产农村 | 天天射天天操天天干 | 亚洲欧美激情精品一区二区 | 成人在线中文字幕 | 国产情侣久久 |