假设我有一个表'shares'与以下列:
company price quantity
Microsoft 100 10
Google 99 5
Google 99 20
Google 101 15
Run Code Online (Sandbox Code Playgroud)
我想运行相当于这样的SQL语句:
select price,
sum(quantity) as num
from shares
where company='Google'
group by price;
Run Code Online (Sandbox Code Playgroud)
我最接近的是:
result = (dbsession.query(Shares.price, func.sum(Shares.quantity))
.filter(Shares.company == 'Google')
.group_by(Shares.price)
.all())
Run Code Online (Sandbox Code Playgroud)
我在sqlalchemy中设置'sum(quantity)as num'时遇到了麻烦.看来我需要使用别名(),但我无法通过查看文档来弄清楚如何.如果有人能告诉我该怎么做,我将不胜感激.
非常感谢!
我们有一个在 Yarn 上运行 Spark 的 kerberized 集群。目前,我们在本地用 Scala 编写 Spark 代码,然后构建一个胖 JAR,我们将其复制到集群中,然后运行 spark-submit。我想在我的本地 PC 上编写 Spark 代码并让它直接在集群上运行。有没有直接的方法来做到这一点?Spark 文档似乎没有任何这样的模式。
仅供参考,我的本地机器正在运行 Windows 并且集群正在运行CDH。
apache-spark ×1
cloudera-cdh ×1
hadoop ×1
hadoop-yarn ×1
kerberos ×1
pyramid ×1
python ×1
sqlalchemy ×1