2017-05-31 83 views
0

我想從一個數據幀讀取列的值,並檢查該值是不是null,值的長度是< = 500我們如何檢查數據幀列的值是否爲空?

我的代碼:

import org.apache.spark.sql.functions._ 

object OmegaProcess 
{ 
    // Some scala lines of Code 

.... 
val line_flag = generateomegaLineFlag(omegaDF) 

def generateomegaLineFlag(omegaDF: DataFrame): Int = { 

    if (omegaDF("omega_file_name") != null && length(omegaDF("omega_file_name")) <= 500) 
     { 
      //Some Lines of code ..... 

     } 
100 
    } 

} 

但它不編譯,因爲下面的錯誤

Type mismatch expected :Boolean, actual: Column 

有人能幫我解決這個問題嗎?

回答

0

嘗試使用isNotNull檢查aganist NULL值

if (omegaDF("omega_file_name").isNotNull && length(omegaDF("omega_file_name")) <= 500)