#If you want to do on HDFS level, below is one of the approaches
#FromHive/beeline run the below HQL
ALTER TABLE TableName ADD IF NOT EXISTS PARTITION (PartitionCol=2017-12-31);
#Now from HDFS Just move the data in 2018 to 2017 partition
hdfs dfs -mv /your/table_hdfs/path/schema.db/tableName/PartitionCol=2018-12-31/* /your/table_hdfs/path/schema.db/tableName/PartitionCol=2017-12-31/
#removing the 2018 partition if you require
hdfs dfs -rm -r /your/table_hdfs/path/schema.db/tableName/PartitionCol=2018-12-31
#You can also drop from beeline/hive
alter table tableName drop if exists partition (PartitionCol=2018-12-31);
#At the end repair the table
msck repair table tableName
2 回答
据我了解,您希望将数据从 2018-12-31 分区移至 2017/12/31。以下是我的说明。
FromSparkCode,您基本上必须启动 hiveContext 并从中运行相同的 HQL。您可以参考我的答案这里中有关如何启动配置单元上下文的信息。
为什么我要修理桌子?
有一个与此https://issues.apache.org/jira/browse/SPARK-19187相关的 JIRA。将您的 Spark 版本升级到 2.0.1 应该可以解决问题