Sean
Sean

Reputation: 97

What is the differences between spark.table("TABLE A") and spark.read.("TABLE A")

Question as the title,I am learning sparkSQL,but I can't get a good understanding of the difference between them. Thanks.

Upvotes: 8

Views: 12616

Answers (1)

s.polam
s.polam

Reputation: 10362

There is no difference between spark.table & spark.read.table function.

Inside of spark.read.table is again calling spark.table function.

Check below code.

spark.table It is available inside package org.apache.spark.sql.SparkSession

SparkSession

package org.apache.spark.sql.SparkSession

def table(tableName: String): DataFrame = {
  table(sessionState.sqlParser.parseTableIdentifier(tableName))
}

spark.read.table function is available in package org.apache.spark.sql.DataFrameReader & It is again calling spark.table function.

DataFrameReader

package org.apache.spark.sql.DataFrameReader

def table(tableName: String): DataFrame = {
   assertNoSpecifiedSchema("table")
   sparkSession.table(tableName)
}

Upvotes: 9

Related Questions