Skip to content

Commit

Permalink
change to 9 parameters constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierZYXue committed Aug 1, 2024
1 parent a6f63b1 commit ca37c4d
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ class BigQueryPlugin(spark: SparkSession)

def bigQueryConfig = {
SparkBigQueryConfig.from(
ImmutableMap.copyOf(cmd.options.asJava),
cmd.options.asJava,
ImmutableMap.copyOf(spark.conf.getAll.asJava),
spark.sparkContext.hadoopConfiguration,
ImmutableMap.of,
0,
spark.sessionState.conf,
spark.version,
Optional.empty()
Optional.empty(),
true
)
}

Expand Down Expand Up @@ -145,9 +147,9 @@ object BigQueryPlugin {
.find(
m => m.getName == "from"
&& isStatic(m.getModifiers)
&& m.getParameterTypes.length == 7
&& m.getParameterTypes.length == 9
&& m.getReturnType.getSimpleName == "SparkBigQueryConfig"
).getOrElse(sys.error(s"Cannot find method `public static SparkBigQueryConfig from(... {7 args} ...)` in the class `$clazz`"))
).getOrElse(sys.error(s"Cannot find method `public static SparkBigQueryConfig from(... {9 args} ...)` in the class `$clazz`"))

object ImmutableMap {
type ImmutableMap = AnyRef
Expand All @@ -157,11 +159,16 @@ object BigQueryPlugin {
.getMethod("copyOf", classOf[java.util.Map[_, _]])
.invoke(imClass, _)
.asInstanceOf[ImmutableMap]
val of: ImmutableMap =
imClass
.getMethod("of")
.invoke(imClass)
.asInstanceOf[ImmutableMap]
}

val from: (ImmutableMap.ImmutableMap, ImmutableMap.ImmutableMap, Configuration, Integer, SQLConf, String, Optional[StructType]) => SparkBigQueryConfig =
val from: (java.util.Map[_, _], ImmutableMap.ImmutableMap, Configuration, ImmutableMap.ImmutableMap, Integer, SQLConf, String, Optional[StructType], java.lang.Boolean) => SparkBigQueryConfig =
methodFrom
.invoke(clazz, _, _, _, _, _, _, _)
.invoke(clazz, _, _, _, _, _, _, _, _, _)
.asInstanceOf[SparkBigQueryConfig]
}

Expand Down

0 comments on commit ca37c4d

Please sign in to comment.