Skip to content

Comments

[GH-2659] Fix file-based readers on Databricks by using reflection for DataSource.checkAndGlobPathIfNecessary#2660

Merged
jiayuasu merged 1 commit intomasterfrom
fix-shapefile-databricks-2659
Feb 18, 2026
Merged

[GH-2659] Fix file-based readers on Databricks by using reflection for DataSource.checkAndGlobPathIfNecessary#2660
jiayuasu merged 1 commit intomasterfrom
fix-shapefile-databricks-2659

Conversation

@jiayuasu
Copy link
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

What changes were proposed in this PR?

On Databricks Runtime (both Spark 3.5 and 4.0), the method DataSource.checkAndGlobPathIfNecessary has all required parameters with no default values. This differs from OSS Apache Spark, where some parameters have defaults.

The previous code used Scala named parameters when calling this method, which causes the Scala compiler to emit synthetic $default$N() accessor method calls in the bytecode. On Databricks these synthetic accessors do not exist, resulting in a NoSuchMethodError at runtime when reading Shapefiles, GeoPackages, or GeoParquet metadata files.

This PR changes SedonaFileIndexHelper to invoke DataSource.checkAndGlobPathIfNecessary via reflection, resolving the method at runtime and passing all arguments explicitly based on the detected parameter count (5 or 6). This avoids any dependency on compiler-generated default parameter accessors and works across OSS Spark 3.x/4.x and Databricks Runtime.

Affected readers (all go through the fixed SedonaFileIndexHelper.createFileIndex):

  • Shapefile (ShapefileTable)
  • GeoPackage (GeoPackageTable)
  • GeoParquet metadata (GeoParquetMetadataTable)

How was this patch tested?

Verified that Scala compilation succeeds across all Spark versions (3.4, 3.5, 4.0, 4.1). The runtime fix is a reflection-based dispatch that will be validated on Databricks.

Did this PR include necessary documentation updates?

  • No, this PR does not affect any public API so no need to change the documentation.

@jiayuasu jiayuasu added this to the sedona-1.9.0 milestone Feb 18, 2026
@jiayuasu jiayuasu force-pushed the fix-shapefile-databricks-2659 branch from aff0507 to 405a363 Compare February 18, 2026 20:55
…tion for DataSource.checkAndGlobPathIfNecessary

On Databricks Runtime (both Spark 3.5 and 4.0), DataSource.checkAndGlobPathIfNecessary
has all required parameters with no defaults, unlike OSS Apache Spark where some
parameters have default values.

The previous code used named parameters, causing the Scala compiler to generate
$default$N() synthetic method calls in bytecode. On Databricks these accessors
don't exist, resulting in NoSuchMethodError at runtime.

Using reflection resolves the method at runtime, avoiding any dependency on
compiler-generated default parameter accessors.
@jiayuasu jiayuasu force-pushed the fix-shapefile-databricks-2659 branch from 405a363 to 3dae185 Compare February 18, 2026 22:00
@jiayuasu jiayuasu merged commit 59e836b into master Feb 18, 2026
40 checks passed
@jiayuasu jiayuasu deleted the fix-shapefile-databricks-2659 branch February 19, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shapefile table metadata reader does not work for Databricks

1 participant