设置分区字段名和类型val partitionColumnName = fen_quval partitionColumnType = string 构造静态分区的分区路径val partitionPath = s$partitionColumnName=$time 添加静态分区sparksqlsALTER TABLE ods1user_inflave236135 with 4139 MiB RA
The code you provided has a syntax error. The issue is with the ALTER TABLE statement. It should be ALTER TABLE ods1.user_inf ADD PARTITION instead of ALTER TABLE ods1.user info ADD PARTITION. Additionally, you need to fix the closing single quote in the partition value. Here's the corrected code:
// 设置分区字段名和类型
val partitionColumnName = "fen_qu"
val partitionColumnType = "string"
// 构造静态分区的分区路径
val partitionPath = s"$partitionColumnName='$time'"
// 添加静态分区
spark.sql(s"ALTER TABLE ods1.user_inf ADD PARTITION ($partitionPath) PARTITIONED BY ($partitionColumnName $partitionColumnType)")
Make sure to replace ods1.user_inf with your actual table name
原文地址: https://www.cveoy.top/t/topic/imQq 著作权归作者所有。请勿转载和采集!