Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions spark2/src/main/java/org/apache/iceberg/spark/source/Reader.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import org.apache.spark.sql.vectorized.ColumnarBatch;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scala.Option;

import static org.apache.iceberg.TableProperties.DEFAULT_NAME_MAPPING;

Expand Down Expand Up @@ -144,7 +143,7 @@ class Reader implements DataSourceReader, SupportsScanColumnarBatch, SupportsPus
if (io.getValue() instanceof HadoopFileIO) {
String fsscheme = "no_exist";
try {
Configuration conf = new Configuration(activeSparkSession().sessionState().newHadoopConf());
Configuration conf = new Configuration(SparkSession.active().sessionState().newHadoopConf());
// merge hadoop config set on table
mergeIcebergHadoopConfs(conf, table.properties());
// merge hadoop config passed as options and overwrite the one on table
Expand Down Expand Up @@ -521,25 +520,11 @@ private String[] getPreferredLocations() {
return new String[0];
}

Configuration conf = activeSparkSession().sparkContext().hadoopConfiguration();
Configuration conf = SparkSession.active().sparkContext().hadoopConfiguration();
return Util.blockLocations(task, conf);
}
}

private static SparkSession activeSparkSession() {
final Option<SparkSession> activeSession = SparkSession.getActiveSession();
if (activeSession.isDefined()) {
return activeSession.get();
} else {
final Option<SparkSession> defaultSession = SparkSession.getDefaultSession();
if (defaultSession.isDefined()) {
return defaultSession.get();
} else {
throw new IllegalStateException("No active spark session found");
}
}
}

private interface ReaderFactory<T> extends Serializable {
InputPartitionReader<T> create(CombinedScanTask task, Schema tableSchema, Schema expectedSchema,
String nameMapping, FileIO io,
Expand Down