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

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

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

    • <bdo id='KsV1u'></bdo><ul id='KsV1u'></ul>

      在 Apache Spark 2.0.0 中,是否可以从外部数据库获取

      时间:2023-08-22

              <tbody id='rSHnv'></tbody>

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

            <tfoot id='rSHnv'></tfoot>

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

              • 本文介绍了在 Apache Spark 2.0.0 中,是否可以从外部数据库获取查询(而不是获取整个表)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                使用pyspark:

                from pyspark.sql import SparkSession火花 = SparkSession\.builder\.appName("spark play")\.getOrCreate()df = spark.read\.format("jdbc")\.option("url", "jdbc:mysql://localhost:port")\.option("dbtable", "schema.tablename")\.option("用户", "用户名")\.option("密码", "密码")\.加载()

                我宁愿获取查询的结果集,而不是获取schema.tablename".

                解决方案

                同 1.x 可以传递有效的子查询作为 dbtable 参数例如:

                <预><代码>....option("dbtable", "(SELECT foo, bar FROM schema.tablename) AS tmp")...

                Using pyspark:

                from pyspark.sql import SparkSession
                
                spark = SparkSession\
                    .builder\
                    .appName("spark play")\
                    .getOrCreate()    
                
                df = spark.read\
                    .format("jdbc")\
                    .option("url", "jdbc:mysql://localhost:port")\
                    .option("dbtable", "schema.tablename")\
                    .option("user", "username")\
                    .option("password", "password")\
                    .load()
                

                Rather than fetch "schema.tablename", I would prefer to grab the result set of a query.

                解决方案

                Same as in 1.x you can pass valid subquery as dbtable argument for example:

                ...
                .option("dbtable", "(SELECT foo, bar FROM schema.tablename) AS tmp")
                ...
                

                这篇关于在 Apache Spark 2.0.0 中,是否可以从外部数据库获取查询(而不是获取整个表)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:猪中的组串联等价物? 下一篇:如何将 Apache Spark 与 MySQL 集成以将数据库表作为

                相关文章

                最新文章

                  <tfoot id='4WC1Z'></tfoot>
                    • <bdo id='4WC1Z'></bdo><ul id='4WC1Z'></ul>

                    <small id='4WC1Z'></small><noframes id='4WC1Z'>

                  1. <i id='4WC1Z'><tr id='4WC1Z'><dt id='4WC1Z'><q id='4WC1Z'><span id='4WC1Z'><b id='4WC1Z'><form id='4WC1Z'><ins id='4WC1Z'></ins><ul id='4WC1Z'></ul><sub id='4WC1Z'></sub></form><legend id='4WC1Z'></legend><bdo id='4WC1Z'><pre id='4WC1Z'><center id='4WC1Z'></center></pre></bdo></b><th id='4WC1Z'></th></span></q></dt></tr></i><div id='4WC1Z'><tfoot id='4WC1Z'></tfoot><dl id='4WC1Z'><fieldset id='4WC1Z'></fieldset></dl></div>
                    <legend id='4WC1Z'><style id='4WC1Z'><dir id='4WC1Z'><q id='4WC1Z'></q></dir></style></legend>