简体   繁体   English

spark hive 获取外部分区文件位置

[英]spark hive get external partition file location

I'm trying to get the external table file location of a partition calculated at run time.我正在尝试获取在运行时计算的分区的外部表文件位置。 Simply alter table drop wouldn't work since it's external.简单地改变表删除是行不通的,因为它是外部的。 The closest I can get is我能得到的最接近的是

 spark.sql(s"describe $tableName partition ($partitionBy=$partitionValue)")
But this would fail when partitionValue is of type timestamp and directly toString before calling the above function. 但是,当 partitionValue 的类型为 timestamp 并且在调用上述函数之前直接为 toString 时,这将失败。 Is there a way to use the same function where spark.write.saveastable() use to create the file path? 有没有办法使用 spark.write.saveastable() 用于创建文件路径的相同函数? or is there a way to get the location of the data by partition at runtime? 或者有没有办法在运行时通过分区获取数据的位置?

Try something尝试一些东西

show table extended FROM $tableSchema like $tableName partition ($partitionBy=$partitionValue)

See more here: https://spark.apache.org/docs/3.0.0/sql-ref-syntax-aux-show-table.html在此处查看更多信息: https ://spark.apache.org/docs/3.0.0/sql-ref-syntax-aux-show-table.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM