-
Notifications
You must be signed in to change notification settings - Fork 28.7k
[SPARK-52704][SQL] Simplify interoperations between SQLConf and file-format options in TextBasedFileFormats #51398
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ import org.apache.spark.sql.catalyst.expressions._ | |
import org.apache.spark.sql.catalyst.expressions.codegen.GenerateUnsafeProjection | ||
import org.apache.spark.sql.catalyst.types.DataTypeUtils.toAttributes | ||
import org.apache.spark.sql.errors.QueryExecutionErrors | ||
import org.apache.spark.sql.internal.SQLConf | ||
import org.apache.spark.sql.internal.{SessionState, SQLConf} | ||
import org.apache.spark.sql.sources.Filter | ||
import org.apache.spark.sql.types._ | ||
|
||
|
@@ -235,6 +235,20 @@ trait FileFormat { | |
*/ | ||
def fileConstantMetadataExtractors: Map[String, PartitionedFile => Any] = | ||
FileFormat.BASE_METADATA_EXTRACTORS | ||
|
||
protected def sessionState(sparkSession: SparkSession): SessionState = { | ||
sparkSession.sessionState | ||
} | ||
|
||
protected def sqlConf(sparkSession: SparkSession): SQLConf = { | ||
sessionState(sparkSession).conf | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the same. Both |
||
|
||
protected def hadoopConf( | ||
sparkSession: SparkSession, | ||
options: Map[String, String]): Configuration = { | ||
sessionState(sparkSession).newHadoopConfWithOptions(options) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto. This method has no relation to any underlying objects or |
||
} | ||
|
||
object FileFormat { | ||
|
@@ -364,8 +378,7 @@ abstract class TextBasedFileFormat extends FileFormat { | |
options: Map[String, String], | ||
path: Path): Boolean = { | ||
if (codecFactory == null) { | ||
codecFactory = new CompressionCodecFactory( | ||
sparkSession.sessionState.newHadoopConfWithOptions(options)) | ||
codecFactory = new CompressionCodecFactory(hadoopConf(sparkSession, options)) | ||
} | ||
val codec = codecFactory.getCodec(path) | ||
codec == null || codec.isInstanceOf[SplittableCompressionCodec] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the method body, this method is a kind of utility method which can be a static method also.