gpt4 book ai didi

python - Spark : What's the difference between spark. sql 和 sqlCtx.sql

转载 作者:行者123 更新时间:2023-12-01 01:47:14 24 4
gpt4 key购买 nike

在使用 pyspark 的 Spark 2.1 中,如果您想查询表(例如从 HDP),您可以运行两者

df = sqlCtx.sql(''' select * from table ''') 

df = spark.sql(''' select * from table ''')

为什么你会做其中一个而不是另一个?两者有什么区别。

最佳答案

sqlCtx 是启动时创建的默认SQLContextspark 是启动时创建的默认 SparkSession。根据 SQLContext 的文档SparkSessionSQLContext 的替代品:

As of Spark 2.0, this is replaced by SparkSession. However, we are keeping the class here for backward compatibility.

关于python - Spark : What's the difference between spark. sql 和 sqlCtx.sql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51158135/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com