I have read accounts from a text file which use , as separator:
val csv = spark.read.text("src/main/resources/in/insight/account_issues.txt")
//implicits
import spark.sqlContext.implicits._
val string_account = csv.map(_.getString(0)).collect.toList.toString()
//print(string_account)
val query = s"""(SELECT
| ACCOUNT_NUMBER,
| CASE WHEN STMT.CRF_TYPE='CREDIT' THEN STMT.AMOUNT_LCY
| ELSE NULL
| END as 'CreditAmount',
| CASE WHEN STMT.CRF_TYPE='DEBIT' THEN STMT.AMOUNT_LCY
| ELSE NULL
| END as 'DebitAmount',
| STMT.BOOKING_DATE,
| STMT.VALUE_DATE,
| CRF_TYPE
|FROM [InsightLanding].[dbo].[v_STMT_ENTRY] AS STMT
| LEFT JOIN [InsightWarehouse].[dbo].[v_Account] AS A ON a.AccountNum = STMT.ACCOUNT_NUMBER
|
|WHERE STMT.MIS_DATE='$BusinessDate'
| AND STMT.ACCOUNT_NUMBER IN ($string_account) ) tmp """.stripMargin
val responseWithSelectedColumns = spark
.read
.format("jdbc")
.option("url", url)
.option("driver", driver)
.option("dbtable", query)
.load()
I cannot get the works instead getting error:
: 'List' is not a recognized built-in function name
What is wrong from my code?