spark-test commented on code in PR #59909: URL: https://github.com/apache/spark/pull/59909#discussion_r4501628883
########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FormExternalLookupJoin.scala: ########## @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.catalyst.analysis + +import org.apache.spark.sql.catalyst.optimizer.EliminateResolvedHint +import org.apache.spark.sql.catalyst.plans.{Inner, LeftOuter} +import org.apache.spark.sql.catalyst.plans.logical.{ExternalLookupJoin, Join, JoinStrategyHint, + LogicalPlan} +import org.apache.spark.sql.catalyst.rules.Rule +import org.apache.spark.sql.catalyst.trees.TreePattern.JOIN +import org.apache.spark.sql.connector.catalog.Table +import org.apache.spark.sql.errors.{QueryCompilationErrors, QueryErrorsBase} +import org.apache.spark.sql.execution.datasources.v2.ExternalLookupRelations + +/** + * Classifies a join for external lookup. [[CheckExternalLookupJoin]] and [[FormExternalLookupJoin]] + * share it, so a join that passes analysis is exactly a join that the optimizer converts. Review Comment: **Nit (P3):** Two statements here don't match the code. First, 'a join that passes analysis is exactly a join that the optimizer converts': a join without a condition passes `CheckExternalLookupJoin`, by design as its own scaladoc explains, and then fails in `FormExternalLookupJoin` with `MISSING_JOIN_CONDITION`, a split the suite asserts. Second, `NotLookupJoin` is documented as 'The join reads no lookup-only table', but a join whose lookup-only table sits under a `Project` or `SubqueryAlias` is classified `NotLookupJoin` (the suite's `Project(lookupOnly.output, lookupOnly)` case) and later fails as a batch scan. Saying that analysis reports every ineligible join except one without a condition, and that `NotLookupJoin` means the classifier did not recognize a lookup-only relation as the lookup side, would keep both comments true. **Verification:** - **Inspection:** The classifier's comments state that a join without a condition passes analysis and fails at the start of optimization, and that a lookup-only relation below a projection or an alias is not classified and fails later as a batch scan. Both statements agree with the existing tests of those two cases. ########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/PrepareExternalLookupJoin.scala: ########## @@ -0,0 +1,237 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.execution.datasources.v2 + +import java.util.{Collections, IdentityHashMap} + +import org.apache.spark.sql.catalyst.expressions.{And, Attribute, EqualNullSafe, EqualTo, + Expression, ExprUtils, PredicateHelper} +import org.apache.spark.sql.catalyst.plans.logical.{ExternalLookupJoin, ExternalLookupKeyTypes, + LogicalPlan, PreparedExternalLookupJoin} +import org.apache.spark.sql.catalyst.rules.Rule +import org.apache.spark.sql.catalyst.trees.TreePattern.EXTERNAL_LOOKUP_JOIN +import org.apache.spark.sql.catalyst.util.CharVarcharUtils +import org.apache.spark.sql.connector.catalog.{SupportsRead, TableCapability} +import org.apache.spark.sql.connector.expressions.{Expression => V2Expression, FieldReference} +import org.apache.spark.sql.connector.expressions.filter.{Predicate => V2Predicate} +import org.apache.spark.sql.connector.read.{LookupParameter, SupportsExternalLookup} +import org.apache.spark.sql.errors.{QueryCompilationErrors, QueryErrorsBase} +import org.apache.spark.sql.types.DataType + +/** Finalizes an optimized external lookup side immediately before ordinary V2 scan preparation. */ +object PrepareExternalLookupJoin extends Rule[LogicalPlan] with PredicateHelper + with QueryErrorsBase { + override def apply(plan: LogicalPlan): LogicalPlan = { + val prepared = plan.transformUpWithPruning(_.containsPattern(EXTERNAL_LOOKUP_JOIN)) { + case join: ExternalLookupJoin => prepare(join) + } + // Prepared lookup joins no longer contain their lookup relation, so a lookup-only table that + // is still read here cannot run. + prepared.foreach { node => + ExternalLookupRelations.lookupOnlyTable(node).foreach { table => + throw QueryCompilationErrors.unsupportedBatchReadError(table) + } + } + prepared + } + + private def prepare(join: ExternalLookupJoin): PreparedExternalLookupJoin = { + val relation = extractLookupPlan(join.right).getOrElse { + throw QueryCompilationErrors.unsupportedExternalLookupJoinError("LOOKUP_PLAN") + } + val tableName = relation.table.name() + val supportsRead = relation.table match { + case table: SupportsRead + if table.capabilities().contains(TableCapability.EXTERNAL_LOOKUP) => table + case _ => + throw QueryCompilationErrors.unsupportedExternalLookupJoinError( + "TABLE", Map("table" -> toSQLId(tableName))) + } + val conjuncts = join.condition.toSeq.flatMap(splitConjunctivePredicates) + val offeredCandidates = conjuncts.zipWithIndex.collect { + case (EqualTo(leftExpr, rightAttr: Attribute), index) + if isLookupEquality(join, leftExpr, rightAttr) => + OfferedLookupPredicate(leftExpr, rightAttr, index, "=", false) + case (EqualTo(rightAttr: Attribute, leftExpr), index) + if isLookupEquality(join, leftExpr, rightAttr) => + OfferedLookupPredicate(leftExpr, rightAttr, index, "=", false) + } + if (offeredCandidates.isEmpty) { + throw QueryCompilationErrors.unsupportedExternalLookupJoinError( + "NO_LOOKUP_CANDIDATE", Map("table" -> toSQLId(tableName))) + } + + val scanBuilder = supportsRead.newScanBuilder(relation.options) + val lookupBuilder = scanBuilder match { + case builder: SupportsExternalLookup => builder + case _ => + throw QueryCompilationErrors.unsupportedExternalLookupJoinError( + "SCAN_BUILDER", Map("table" -> toSQLId(tableName))) + } + val offeredPredicates = offeredCandidates.map { candidate => + new V2Predicate(candidate.predicateName, Array[V2Expression]( + FieldReference.column(candidate.projectedField.name), Review Comment: **Non-blocking (P2):** This reference takes the lookup attribute's name as the join condition spells it. Under the default `spark.sql.caseSensitive=false`, the analyzer renames a resolved attribute to the query's spelling (`a.withName(name)` in `expressions/package.scala`) while keeping the table column's exprId. So `ON s.id = t.ID` over a table column `id` reaches this rule as `ID#n`, passes `isLookupEquality`, which matches by exprId, and is offered as `ID = ?`. A connector that matches schema names exactly, like this suite's `selectIdEqualities`, selects nothing, and the join fails with `NO_LOOKUP_PREDICATE`, which blames the data source. A connector that resolves the name against its schema may fail on the unknown field instead. The other DSv2 pushdown paths avoid this by first renaming attributes to the relation's names with `DataSourceStrategy.normalizeExprs`. Taking the name from the `relation.output` attribute with the same exprId would do the same here. This matters once the rules are registered; nothing changes at runtime in this PR. **Verification:** - **Regression:** With case-insensitive analysis, a lookup join whose condition writes the lookup column in a different case from the table schema offers a predicate naming the schema column, and a connector that matches schema names exactly selects it, so preparation succeeds instead of failing with NO_LOOKUP_PREDICATE. - **Compatibility:** Lookup joins whose conditions already use the schema's spelling offer the same predicates in the same order, with the same parameter binding and residual as before. ########## sql/core/src/test/scala/org/apache/spark/sql/connector/PrepareExternalLookupJoinSuite.scala: ########## @@ -0,0 +1,270 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.connector + +import org.apache.spark.SparkException +import org.apache.spark.sql.AnalysisException +import org.apache.spark.sql.catalyst.analysis.FormExternalLookupJoin +import org.apache.spark.sql.catalyst.dsl.expressions._ +import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeReference, Expression, + Literal} +import org.apache.spark.sql.catalyst.optimizer.ColumnPruning +import org.apache.spark.sql.catalyst.plans.{FullOuter, Inner, JoinType, LeftOuter, PlanTest} +import org.apache.spark.sql.catalyst.plans.logical.{ExternalLookupJoin, Join, JoinHint, + LocalRelation, LogicalPlan, PreparedExternalLookupJoin, Project} +import org.apache.spark.sql.connector.catalog.{SupportsRead, Table, TableCapability} +import org.apache.spark.sql.connector.catalog.TableCapability.EXTERNAL_LOOKUP +import org.apache.spark.sql.connector.expressions.FieldReference +import org.apache.spark.sql.connector.expressions.filter.Predicate +import org.apache.spark.sql.connector.read.{ExternalLookup, ExternalLookupReaderFactory, Scan, + ScanBuilder, SupportsExternalLookup} +import org.apache.spark.sql.execution.datasources.v2.{DataSourceV2Relation, + ExternalLookupRelation, PrepareExternalLookupJoin} +import org.apache.spark.sql.internal.SQLConf +import org.apache.spark.sql.types.{IntegerType, LongType, StructType} +import org.apache.spark.sql.util.CaseInsensitiveStringMap + +class PrepareExternalLookupJoinSuite extends PlanTest { + private val stream = + LocalRelation(Seq($"streamId".int, $"streamLabel".string), isStreaming = true) + private val QUOTED_TABLE_NAME = "`PlanningExternalLookupTable`" + + private def lookupRelation(table: PlanningExternalLookupTable): ExternalLookupRelation = + ExternalLookupRelation( + DataSourceV2Relation.create(table, None, None, CaseInsensitiveStringMap.empty)) + + private def lookupJoin( + lookup: LogicalPlan, + condition: Expression, + joinType: JoinType = Inner, + left: LogicalPlan = stream): LogicalPlan = + FormExternalLookupJoin(Join(left, lookup, joinType, Some(condition), JoinHint.NONE)) + + private def lookupJoinOnId(lookup: LogicalPlan): LogicalPlan = + lookupJoin(lookup, stream.output.head === lookup.output.head) + + private def prepare(plan: LogicalPlan): PreparedExternalLookupJoin = + PrepareExternalLookupJoin(plan) match { + case lookup: PreparedExternalLookupJoin => lookup + case other => fail(s"Expected a prepared external lookup join: $other") + } + + private def prepareError(plan: LogicalPlan): AnalysisException = + intercept[AnalysisException] { PrepareExternalLookupJoin(plan) } + + test("a lookup-only relation that no lookup join reads is rejected") { + val lookup = lookupRelation(PlanningExternalLookupTable()) + prepare(lookupJoinOnId(lookup)) + checkError( + exception = prepareError(Project(lookup.output, lookup)), + condition = "UNSUPPORTED_FEATURE.TABLE_OPERATION", + parameters = Map("tableName" -> QUOTED_TABLE_NAME, "operation" -> "batch scan")) + } + + test("an equality is a lookup candidate only on a type that stores compare as Spark does") { + val offeredTypes = Seq("TINYINT", "SMALLINT", "INT", "BIGINT", "BOOLEAN", "DECIMAL(10, 2)", + "DATE", "TIMESTAMP", "TIMESTAMP_NTZ", "BINARY", "STRING", "STRING COLLATE UTF8_BINARY") + val notOfferedTypes = Seq("FLOAT", "DOUBLE", "CHAR(3)", "VARCHAR(3)", + "STRING COLLATE UTF8_LCASE", "STRING COLLATE UNICODE", "STRING COLLATE UTF8_BINARY_RTRIM", + "STRUCT<a: INT>", "ARRAY<INT>", "INTERVAL DAY TO SECOND") + for ((codeType, offered) <- offeredTypes.map(_ -> true) ++ notOfferedTypes.map(_ -> false)) { + var offeredCandidates = Seq.empty[String] + val lookup = lookupRelation(PlanningExternalLookupTable(s"id INT, code $codeType", select = { + candidates => + offeredCandidates = candidates.map(_.toString).toSeq + candidates.take(1) + })) + val Seq(lookupId, lookupCode) = lookup.output + val streamId = stream.output.head + val streamCode = AttributeReference("streamCode", lookupCode.dataType)() + val codesEqual = streamCode === lookupCode + val prepared = prepare(lookupJoin(lookup, streamId === lookupId && codesEqual, + left = LocalRelation(Seq(streamId, streamCode), isStreaming = true))) + val expected = if (offered) Seq("id = ?", "code = ?") else Seq("id = ?") + assert(offeredCandidates === expected, codeType) + // The connector selects only `id = ?`, so Spark evaluates the code equality either way. + assert(prepared.residualCondition === Some(codesEqual), codeType) + } + + // Without another candidate, the join cannot run. + Seq("DOUBLE", "STRING COLLATE UTF8_LCASE").foreach { codeType => + val lookup = lookupRelation(PlanningExternalLookupTable(s"id INT, code $codeType")) + val lookupCode = lookup.output(1) + val streamCode = AttributeReference("streamCode", lookupCode.dataType)() + checkError( + exception = prepareError(lookupJoin(lookup, streamCode === lookupCode, + left = LocalRelation(Seq(streamCode), isStreaming = true))), + condition = "EXTERNAL_LOOKUP_JOIN_UNSUPPORTED.NO_LOOKUP_CANDIDATE", + parameters = Map("table" -> QUOTED_TABLE_NAME)) + } + } + + test("the residual evaluates key equalities and conjuncts that cannot fail first") { + val lookup = lookupRelation(PlanningExternalLookupTable("id INT, label STRING, value STRING")) + val Seq(lookupId, lookupLabel, lookupValue) = lookup.output + val Seq(streamId, streamLabel) = stream.output + // A cast can fail, so it runs after the equality and the comparison written after it, which + // keep their written order. The connector selects only `id = ?`. + val mayFail = streamLabel.cast(IntegerType) > 0 + val conjuncts = + Seq(lookupId === streamId, mayFail, streamLabel === lookupLabel, lookupValue > "a") + val prepared = prepare(lookupJoin(lookup, conjuncts.reduce(_ && _))) + assert(prepared.residualCondition === + Some(streamLabel === lookupLabel && lookupValue > "a" && mayFail)) + } + + test("selected predicates bind in the connector's order, and the residual in written order") { + val Seq(streamId, streamLabel) = stream.output + def prepared(select: Array[Predicate] => Array[Predicate]) + : (PreparedExternalLookupJoin, Seq[Attribute], Seq[Expression]) = { + val lookup = lookupRelation( + PlanningExternalLookupTable("id INT, label STRING, value STRING", select = select)) + val Seq(id, label, value) = lookup.output + // `value = 'a'` is offered as well; `streamId > 0` is not. + val conjuncts = + Seq(id === streamId, streamLabel === label, streamId > 0, value === Literal("a")) + val join = lookupJoin(lookup, conjuncts.reduce(_ && _), LeftOuter) + (prepare(join), join.output, conjuncts) + } + + val (reversed, joinOutput, conjuncts) = + prepared(candidates => Array(candidates(1), candidates(0))) + assert(reversed.lookupParameters === Seq(streamLabel, streamId)) + assert(reversed.nullSafeParameters === Seq(false, false)) + assert(reversed.residualCondition === Some(conjuncts(2) && conjuncts(3))) + assert(reversed.output === joinOutput) + assert(PrepareExternalLookupJoin(reversed) === reversed) + checkError( + exception = intercept[SparkException] { reversed.copy(joinType = FullOuter).output }, + condition = "INTERNAL_ERROR", + parameters = Map("message" -> "Unexpected external lookup join type FullOuter")) + + // An unselected equality stays ahead of the conjuncts written after it. + val (idOnly, _, idOnlyConjuncts) = prepared(candidates => Array(candidates(0))) + assert(idOnly.lookupParameters === Seq(streamId)) + assert(idOnly.residualCondition === Some(idOnlyConjuncts.drop(1).reduce(_ && _))) + } + + test("the read schema binds to the analyzed lookup attributes by exact name") { + val lookup = lookupRelation(PlanningExternalLookupTable( + "id INT NOT NULL, value VARCHAR(8) NOT NULL, s STRUCT<a: INT NOT NULL>", + readSchemaDDL = Some("s STRUCT<a: INT>, value VARCHAR(8), id INT NOT NULL"))) Review Comment: **Nit (P3):** This case covers a read schema whose nullability is weaker than the table's: `s.a` and `value` are nullable where the table says NOT NULL. The Scan contract now also allows a stricter one ('may differ from the table's, at any nested level'), and binding accepts it through `DataType.equalsIgnoreNullability`, but no test declares NOT NULL where the table is nullable. A regression to a weaker-only check would reject such a connector with `UNKNOWN_SCAN_FIELD` while every assertion still passed, and the non-nullable `lookupInput` the rule produces for that case is not pinned either. A table column `value STRING` read as `value STRING NOT NULL`, at the top level and in a nested field, with assertions on `lookupInput`'s nullability and an unchanged prepared output, would close the gap. This extends an [existing discussion](https://github.com/apache/spark/pull/59909#discussion_r4418015122). **Verification:** - **Regression:** A connector whose read schema declares NOT NULL for a nullable table column, at the top level and in a nested field, is prepared successfully. Its value-row attributes are non-nullable for those fields, and the prepared join's output is unchanged from the analyzed join's. - **Compatibility:** The existing weaker-nullability, reordered and case-variant read-schema cases keep passing unchanged. ########## sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/FormExternalLookupJoin.scala: ########## @@ -0,0 +1,155 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.spark.sql.catalyst.analysis + +import org.apache.spark.sql.catalyst.optimizer.EliminateResolvedHint +import org.apache.spark.sql.catalyst.plans.{Inner, LeftOuter} +import org.apache.spark.sql.catalyst.plans.logical.{ExternalLookupJoin, Join, JoinStrategyHint, + LogicalPlan} +import org.apache.spark.sql.catalyst.rules.Rule +import org.apache.spark.sql.catalyst.trees.TreePattern.JOIN +import org.apache.spark.sql.connector.catalog.Table +import org.apache.spark.sql.errors.{QueryCompilationErrors, QueryErrorsBase} +import org.apache.spark.sql.execution.datasources.v2.ExternalLookupRelations + +/** + * Classifies a join for external lookup. [[CheckExternalLookupJoin]] and [[FormExternalLookupJoin]] + * share it, so a join that passes analysis is exactly a join that the optimizer converts. + * + * A join is an external lookup join when its right side reads a table that supports external + * lookup but not batch read. It must be a stream-static join: the left side is a streaming query, + * whose micro-batches tolerate lookup results that change between requests, and the lookup-only + * table is on the right side. + */ +object ExternalLookupJoinEligibility extends QueryErrorsBase { + sealed trait Eligibility + /** The join reads no lookup-only table and stays an ordinary join. */ + case object NotLookupJoin extends Eligibility + /** The join runs as an external lookup join. */ + case object Eligible extends Eligibility + /** The join reads a lookup-only table, with a supported join type, but has no condition. */ + case object MissingCondition extends Eligibility + /** The join reads a lookup-only table, which no other join can read, but cannot run. */ + case class Ineligible(error: Throwable) extends Eligibility + + private val SUPPORTED_JOIN_TYPES = Seq(Inner, LeftOuter) + + def apply(join: Join): Eligibility = { + // The lookup-only table must be on the right side; the sides are never swapped. + // TODO: look through projections, filters and aliases above the lookup relation. + // TODO: allow the EXTERNAL_LOOKUP hint once it is introduced, and classify the joins it opts + // in. + (ExternalLookupRelations.lookupOnlyTable(join.left), + ExternalLookupRelations.lookupOnlyTable(join.right)) match { + case (Some(table), _) => ineligible("LOOKUP_TABLE_ON_LEFT", table) + case (None, Some(table)) => lookupJoinEligibility(join, table) + case (None, None) => NotLookupJoin + } + } + + private def lookupJoinEligibility(join: Join, table: Table): Eligibility = { + if (!join.left.isStreaming) return ineligible("STATIC_LEFT_SIDE", table) + // A join hint the user wrote is never silently dropped: an external lookup join cannot run a + // physical join strategy, and a lookup-only table has no batch scan for one. + joinStrategyHint(join) match { + case Some(strategy) => + ineligible("CONFLICTING_JOIN_STRATEGY", table, + Map("strategy" -> toSQLStmt(strategy.displayName))) + // Checked before the condition, so that a cross join fails while it is analyzed. + case None if !SUPPORTED_JOIN_TYPES.contains(join.joinType) => + ineligible("JOIN_TYPE", table, Map( + "joinType" -> toSQLStmt(join.joinType.sql), + "supportedJoinTypes" -> SUPPORTED_JOIN_TYPES.map(t => toSQLStmt(t.sql)).mkString(", "))) + case None if join.condition.isEmpty => MissingCondition + case None => Eligible + } + } + + private def ineligible( + subClass: String, + table: Table, + parameters: Map[String, String] = Map.empty): Ineligible = + Ineligible(QueryCompilationErrors.unsupportedExternalLookupJoinError( + subClass, parameters + ("relation" -> toSQLId(table.name())))) + + private def joinStrategyHint(join: Join): Option[JoinStrategyHint] = { + // Only the hints that EliminateResolvedHint will attach to this join count; a strategy hint + // on a nested join belongs to that join. + val attached = join.hint.leftHint.toSeq ++ join.hint.rightHint.toSeq ++ + Seq(join.left, join.right).flatMap(EliminateResolvedHint.extractHintsFromPlan(_)._2) Review Comment: **Nit (P3):** The `join.right` half of this extraction can never return a hint. `joinStrategyHint` runs only from `lookupJoinEligibility`, after `lookupOnlyTable(join.right)` has matched a `DataSourceV2Relation` or `ExternalLookupRelation`, and for a leaf `extractHintsFromPlan` returns no hints. A hint on the lookup side, such as `stream.join(lookupOnly.hint("broadcast"), ...)`, which is where a broadcast hint usually goes in a stream-static join, analyzes to `Join(stream, ResolvedHint(ExternalLookupRelation))`. The classifier returns `NotLookupJoin`, so the join is neither reported nor converted, and the query later fails in `PrepareExternalLookupJoin`'s stray-relation check with the batch-scan error, which names neither the hint nor the lookup join. Looking through `ResolvedHint` above the right relation when classifying, and reporting `CONFLICTING_JOIN_STRATEGY` from the shared classifier, would make this extraction effective in both rules. Every hint case in `FormExternalLooku pJoinSuite` puts the hint on the stream side. This extends an [existing discussion](https://github.com/apache/spark/pull/59909#discussion_r4418015201). **Verification:** - **Regression:** A broadcast, merge, shuffle_hash or shuffle_replicate_nl hint applied to the lookup-only side fails with CONFLICTING_JOIN_STRATEGY and the hint's name, in both the analysis-time check and the optimizer-start conversion. - **Compatibility:** Stream-side hints, a hint inside a nested join on the stream side, unhinted eligible joins, and a lookup-only relation under a projection keep their current classification and errors. -- 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]
