其他分享
首页 > 其他分享> > Databricks:有用的代码集锦

Databricks:有用的代码集锦

作者:互联网

本文总结了在工作中用过的脚本

1,列出folder中的所有文件

%python
display(dbutils.fs.ls("dbfs:/mnt/folder/"))

2,改变表的列

由于Azure Databricks不支持修改列,所以可以通过把数据表重命名,然后创建一个同名的表来实现列的改变

%sql

alter table capsbi.table_data
rename to capsbi.table_data_old;

create table capsbi.table_data
using delta
as 
select column_1, ...
from capsbi.table__data_old;

3,检查表的schema

%python

sql_query="select * from CAPSBI.vw_table_data limit 1"
df = spark.sql(sql_query)
print(df.dtypes)

 

 

 

参考文档:

标签:old,capsbi,Databricks,有用,集锦,sql,table,data,select
来源: https://www.cnblogs.com/ljhdo/p/15753742.html