How to use SQL query to define table in dbtable?

前端 未结 2 1208
遇见更好的自我
遇见更好的自我 2020-12-04 00:03

In JDBC To Other Databases I found the following explanation of dbtable parameter:

The JDBC table that should be read. Note that anythin

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 00:26

    Code In Scala

    val checkQuery = "(SELECT * FROM " + inputTableName + " ORDER BY " + columnName + " DESC LIMIT 1) AS timetable"
    
    val timeStampDf = spark.read.format("jdbc").option("url", url).option("dbtable", checkQuery).load()
    

    Adding an alias is also necessary after the query in parenthesis.

提交回复
热议问题