我对SQL不太了解,但我还是想问一下这个论坛。
我的工作是处理带有空值的记录。我的意思是,我们有自然键(假设有4列),其中任何一列都会获取NULL值,那么应该将其路由到另一个表,以便将其报告给客户端。
AFAIK SQL只提供一个输出,不能分割。我们有没有办法在SQL/spark SQL中处理这个问题?我需要使用spark来执行这个任务。
工艺流程是:
发布于 2018-09-13 16:51:47
虽然你不能一蹴而就,但你可以按照上面提到的步骤去做。
在Hive中创建表之后,使用PySpark可以这样做,
#Set all the imports and enable Hive support for the session
#Dataframe to hold rows where either of 4 columns is null
df=spark.sql("select * from tblName where col1 is null or col2 is null or col3 is null or col4 is null")
#Write the resulting dataframe to a Hive table
df.saveAsTable('tableName') #Use other arguments in saveAsTable as requiredhttps://stackoverflow.com/questions/52318128
复制相似问题