cloud-fan commented on code in PR #50921:
URL: https://github.com/apache/spark/pull/50921#discussion_r2184495403
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/jdbc/JDBCScanBuilder.scala:
##########
@@ -121,6 +123,103 @@ case class JDBCScanBuilder(
}
}
+ override def isOtherSideCompatibleForJoin(other: SupportsPushDownJoin):
Boolean = {
+ other.isInstanceOf[JDBCScanBuilder] &&
+ jdbcOptions.url == other.asInstanceOf[JDBCScanBuilder].jdbcOptions.url
+ };
+
+ // When getJoinedSchema is called, schema shouldn't be pruned yet because
pushDownJoin API call
+ // can fail. For this reason, we are temporarily holding pruned schema in
new variable that is
+ // later used in pushDownJoin when crafting the SQL query.
+ var aboutToBePrunedSchema: StructType = finalSchema
+
+ override def getJoinedSchema(
+ other: SupportsPushDownJoin,
+ requiredSchema: StructType,
+ otherSideRequiredSchema: StructType): StructType = {
+ aboutToBePrunedSchema = requiredSchema
+ other.asInstanceOf[JDBCScanBuilder].aboutToBePrunedSchema =
otherSideRequiredSchema
+
+ var joinedSchema = StructType(Seq())
+
+ (requiredSchema.fields ++ otherSideRequiredSchema.fields)
+ .zipWithIndex
+ .foreach { case (field, idx) =>
+ val newFieldName = JoinOutputAliasIterator.generateColumnAlias
Review Comment:
shall we only generate the alias when there are name conflicts?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]