SPARK的时间函数
package test
import java.util.Date
import org.apache.spark.SparkConf
import org.apache.spark.sql.SparkSession
/**
- Created by fanxiaoxia on 2018/11/28.
*/
object SPARKDATE {
Class.forName(“oracle.jdbc.driver.OracleDriver”)
val url = “jdbc:oracle:thin:test/test@//192.168.1.123:1521/orcl”
def main(args: Array[String]): Unit = {
//加载数据库中表
val conf = new SparkConf().setAppName(“A”).setMaster(“local[*]”)
val spark = SparkSession.builder().config(conf).getOrCreate()
val jdbcDF = spark.read.format("jdbc").options(
Map("url" -> url,
"user" -> "test1",
"password" -> "test1",
"dbtable" -> "XL_CARD_INFO")).load()
jdbcDF.createOrReplaceTempView("XL_CARD_INFO") //从oracle读到的数据注册成临时表
// val date = new Date() //常规创建日期对象;
//获取当前时间
// val sql = spark.sql(
// “”"
// |select current_date from XL_CARD_INFO
// “”".stripMargin)
// .show()
// current_timestamp/now()获取当前时间
// val sql = spark.