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

    <bdo id='QYDiF'></bdo><ul id='QYDiF'></ul>

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

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

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

        如何在 jdbc 數據源中使用 dbtable 選項的子查詢?

        How to use a subquery for dbtable option in jdbc data source?(如何在 jdbc 數據源中使用 dbtable 選項的子查詢?)

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

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

              • <legend id='QdQiP'><style id='QdQiP'><dir id='QdQiP'><q id='QdQiP'></q></dir></style></legend>
              • <tfoot id='QdQiP'></tfoot>

                  <tbody id='QdQiP'></tbody>
                  <bdo id='QdQiP'></bdo><ul id='QdQiP'></ul>
                  本文介紹了如何在 jdbc 數據源中使用 dbtable 選項的子查詢?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我想使用 Spark 處理來自 JDBC 源的一些數據.但是首先,我想在JDBC端運行一些查詢來過濾列和連接表,而不是從JDBC讀取原始表,并將查詢結果作為表加載到Spark SQL中.

                  I want to use Spark to process some data from a JDBC source. But to begin with, instead of reading original tables from JDBC, I want to run some queries on the JDBC side to filter columns and join tables, and load the query result as a table in Spark SQL.

                  以下加載原始 JDBC 表的語法適用于我:

                  The following syntax to load raw JDBC table works for me:

                  df_table1 = sqlContext.read.format('jdbc').options(
                      url="jdbc:mysql://foo.com:3306",
                      dbtable="mydb.table1",
                      user="me",
                      password="******",
                      driver="com.mysql.jdbc.Driver" # mysql JDBC driver 5.1.41
                  ).load() 
                  df_table1.show() # succeeded
                  

                  根據 Spark 文檔(我使用的是 PySpark 1.6.3):

                  According to Spark documentation (I'm using PySpark 1.6.3):

                  dbtable:應該讀取的 JDBC 表.請注意,任何有效的可以在 SQL 查詢的 FROM 子句中使用.例如,而不是完整的表,您也可以在括號中使用子查詢.

                  dbtable: The JDBC table that should be read. Note that anything that is valid in a FROM clause of a SQL query can be used. For example, instead of a full table you could also use a subquery in parentheses.

                  所以只是為了實驗,我嘗試了一些簡單的方法:

                  So just for experiment, I tried something simple like this:

                  df_table1 = sqlContext.read.format('jdbc').options(
                      url="jdbc:mysql://foo.com:3306",
                      dbtable="(SELECT * FROM mydb.table1) AS table1",
                      user="me",
                      password="******",
                      driver="com.mysql.jdbc.Driver"
                  ).load() # failed
                  

                  它拋出了以下異常:

                  com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'table1 WHERE 1=0' at line 1
                  

                  我還嘗試了其他一些語法變體(添加/刪除括號、刪除as"子句、切換大小寫等),但都沒有成功.那么正確的語法是什么?在哪里可以找到更詳細的語法文檔?此外,錯誤消息中這個奇怪的WHERE 1 = 0"來自哪里?謝謝!

                  I also tried a few other variations of the syntax (add / remove parentheses, remove 'as' clause, switch case, etc) without any luck. So what would be the correct syntax? Where can I find more detailed documentation for the syntax? Besides, where does this weird "WHERE 1=0" in error message come from? Thanks!

                  推薦答案

                  對于在 Spark SQL 中使用 sql 查詢從 JDBC 源讀取數據,您可以嘗試如下操作:

                  For reading data from JDBC source using sql query in Spark SQL, you can try something like this:

                  val df_table1 = sqlContext.read.format("jdbc").options(Map(
                      ("url" -> "jdbc:postgresql://localhost:5432/mydb"),
                      ("dbtable" -> "(select * from table1) as table1"),
                      ("user" -> "me"),
                      ("password" -> "******"),
                      ("driver" -> "org.postgresql.Driver"))
                  ).load()
                  

                  我用 PostgreSQL 試過了.可以根據MySQL修改.

                  I tried it using PostgreSQL. You can modify it according to MySQL.

                  這篇關于如何在 jdbc 數據源中使用 dbtable 選項的子查詢?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 數據幀讀取?)
                    <tbody id='nVwM8'></tbody>
                • <tfoot id='nVwM8'></tfoot>
                • <legend id='nVwM8'><style id='nVwM8'><dir id='nVwM8'><q id='nVwM8'></q></dir></style></legend>

                        <bdo id='nVwM8'></bdo><ul id='nVwM8'></ul>
                      • <small id='nVwM8'></small><noframes id='nVwM8'>

                            <i id='nVwM8'><tr id='nVwM8'><dt id='nVwM8'><q id='nVwM8'><span id='nVwM8'><b id='nVwM8'><form id='nVwM8'><ins id='nVwM8'></ins><ul id='nVwM8'></ul><sub id='nVwM8'></sub></form><legend id='nVwM8'></legend><bdo id='nVwM8'><pre id='nVwM8'><center id='nVwM8'></center></pre></bdo></b><th id='nVwM8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='nVwM8'><tfoot id='nVwM8'></tfoot><dl id='nVwM8'><fieldset id='nVwM8'></fieldset></dl></div>
                            主站蜘蛛池模板: 中文字幕av久久爽一区 | 国产三级一区 | www.伊人网| 午夜视频免费 | 亚洲日本天堂 | 日韩精品一二区 | 天天射影院 | 成人午夜激情视频 | 五月天激情国产综合婷婷婷 | 亚洲一区在线观看视频 | 午夜精品视频 | 亚洲天码中字 | 五月开心婷婷 | 午夜激情福利 | 夫妻av| 国产成人久久 | 久久精品视频网 | 一区二区三区四区在线视频 | 天天射综合 | 日韩免费小视频 | 日韩一级在线 | 国产精品一区在线播放 | 亚洲另类色图 | 日韩第一区 | 久久精品免费看 | 亚洲国产成人精品久久 | 久视频在线 | 色一情一乱一伦一区二区三区 | 性高潮久久久久久久 | 特级丰满少妇一级aaaa爱毛片 | 日韩视频一区二区三区 | 亚洲精品小视频 | 六月婷婷综合 | 国产日韩精品一区二区 | 18色av| 自拍偷拍欧美日韩 | 国产成人亚洲精品自产在线 | 日日av| 久久久麻豆 | 日韩在线观看中文字幕 | 成年人免费在线观看 |