val hiveContext=new HiveContext(new SparkContext(new SparkConf().setAppName("HiveApp").setMaster("spark://master:7077")))  ---定义一个hiveContext变量

val sqlContext=new SQLContext(new SparkContext(new SparkConf().setAppName("HiveApp").setMaster("spark://master:7077")))  ---定义一个sqlContext变量

调用的方法如下:

def  dropTempTable(tableName: String)Unit  ---删除临时表,无返回值

def  emptyDataFrameDataFrame  ---返回一个没有行列的数据框

def  sql(sqlText: String)DataFrame ---在spark引擎上执行一个sql查询,并返回一个数据框

def  udfUDFRegistration ---用户自定义函数

sqlContext.udf.register("myUDF", (arg1: Int, arg2: String) => arg2 + arg1)  ---scala

sqlContext.udf().register("myUDF", (Integer arg1, String arg2) -> arg2 + arg1, DataTypes.StringType); ---Java

相关文章:

  • 2021-11-01
  • 2022-02-02
  • 2021-11-30
  • 2022-01-17
  • 2022-12-23
  • 2022-12-23
  • 2021-07-06
  • 2022-02-08
猜你喜欢
  • 2021-12-13
  • 2022-12-23
  • 2021-11-13
  • 2021-11-13
  • 2021-09-16
  • 2021-10-14
  • 2022-12-23
相关资源
相似解决方案