Spark, how to print the query?

纵然是瞬间 提交于 2021-02-11 14:36:02

问题


I'm using pyspark

    df = self.sqlContext.read.option(
        "es.resource", indexes
    ).format("org.elasticsearch.spark.sql").load()


    df = df.filter(
        df.data.timestamp >= self.period_start
    )

I'd like to see sql query version of df if possible.

something like print(df.query) to see something like select * from my-indexes where data.timestamp > self.period_start


回答1:


You can check out this piece of documentation for pyspark.sql.DataFrame.explain . explain prints the (logical and physical) plan to the console for debugging purpose.



来源:https://stackoverflow.com/questions/56033068/spark-how-to-print-the-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!