Spark sql 查询与数据框函数 [英] Spark sql queries vs dataframe functions

查看:28
本文介绍了Spark sql 查询与数据框函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Spark 实现良好的性能.我想知道通过 SQLContext 使用 sql 查询是否好,或者通过 df.select() 之类的 DataFrame 函数进行查询是否更好.

To perform good performance with Spark. I'm a wondering if it is good to use sql queries via SQLContext or if this is better to do queries via DataFrame functions like df.select().

有什么想法吗?:)

推荐答案

没有任何性能差异.这两种方法使用完全相同的执行引擎和内部数据结构.归根结底,一切都归结为个人喜好.

There is no performance difference whatsoever. Both methods use exactly the same execution engine and internal data structures. At the end of the day, all boils down to personal preferences.

  • 可以说 DataFrame 查询更容易以编程方式构建,并提供最小的类型安全.

  • Arguably DataFrame queries are much easier to construct programmatically and provide a minimal type safety.

简单的 SQL 查询可以更加简洁和易于理解.它们也是可移植的,无需任何修改即可使用每种支持的语言.使用 HiveContext,这些还可以用于公开一些以其他方式无法访问的功能(例如,没有 Spark 包装器的 UDF).

Plain SQL queries can be significantly more concise and easier to understand. They are also portable and can be used without any modifications with every supported language. With HiveContext, these can also be used to expose some functionalities which can be inaccessible in other ways (for example UDF without Spark wrappers).

这篇关于Spark sql 查询与数据框函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆