Copilot commented on code in PR #12234:
URL: https://github.com/apache/gluten/pull/12234#discussion_r3366918848
##########
gluten-ut/spark35/src/test/scala/org/apache/spark/sql/hive/execution/GlutenHiveSQLQuerySuite.scala:
##########
@@ -119,10 +119,38 @@ class GlutenHiveSQLQuerySuite extends
GlutenHiveSQLQuerySuiteBase {
purge = false)
}
- test("GLUTEN-11062: Supports mixed input format for partitioned Hive table")
{
+ testGluten("orc.force.positional.evolution maps Hive ORC columns by
position") {
val hiveClient: HiveClient =
spark.sharedState.externalCatalog.unwrapped.asInstanceOf[HiveExternalCatalog].client
+ withSQLConf("spark.sql.hive.convertMetastoreOrc" -> "false") {
+ withTempDir {
+ dir =>
+ val orcLoc = s"file:///$dir/test_orc_pos"
+ withTable("test_orc_pos", "test_orc_pos_renamed") {
+ // Write ORC files whose physical column names are c1, c2 (c1 = 1,
c2 = 2).
+ hiveClient.runSqlHive(
+ s"create table test_orc_pos(c1 int, c2 int) stored as orc
location '$orcLoc'")
+ hiveClient.runSqlHive("insert into test_orc_pos select 1, 2")
+
+ // A second table over the SAME files but with mismatched column
names (x, y).
+ // By name, x/y are not present in the files; only position
mapping can read them.
+ hiveClient.runSqlHive(
+ s"create table test_orc_pos_renamed(x int, y int) stored as orc
location '$orcLoc'")
+
+ // orc.force.positional.evolution=true => read by position: x ->
c1 (=1), y -> c2 (=2).
+ withSQLConf("spark.hadoop.orc.force.positional.evolution" ->
"true") {
+ val df = sql("select x, y from test_orc_pos_renamed")
+ checkAnswer(df, Seq(Row(1, 2)))
+ checkOperatorMatch[HiveTableScanExecTransformer](df)
+ }
+ }
+ }
+ }
+ }
+
+ test("GLUTEN-11062: Supports mixed input format for partitioned Hive table")
{
+
withSQLConf("spark.sql.hive.convertMetastoreParquet" -> "false") {
Review Comment:
`hiveClient` is used in the GLUTEN-11062 test block but is not defined in
that scope (it is currently defined only inside the preceding
positional-evolution test), which will make this suite fail to compile.
##########
gluten-substrait/src/main/scala/org/apache/gluten/config/GlutenConfig.scala:
##########
@@ -576,6 +578,19 @@ object GlutenConfig extends ConfigRegistry {
}
.foreach { case (k, v) => nativeConfMap.put(k, v) }
+ // When `orc.force.positional.evolution=true`, vanilla Spark maps ORC
columns by
+ // position rather than by name (see OrcUtils.requestedColumnIds). The
Velox ORC reader
+ // must do the same, otherwise name-based matching against a mismatched
file schema
+ // reads columns back as null/empty. Override the (Velox)
orcUseColumnNames session conf
+ // so native reads ORC by position too. Harmless for backends that ignore
this key.
+ // String literal is used because gluten-substrait cannot depend on
backends-velox.
+ if (
+ backendName == "velox" &&
+ conf.getOrElse(SPARK_ORC_FORCE_POSITIONAL_EVOLUTION, "false").toBoolean
+ ) {
+
nativeConfMap.put("spark.gluten.sql.columnar.backend.velox.orcUseColumnNames",
"false")
+ }
Review Comment:
This introduces a backend-specific branch (`backendName == "velox"`) inside
gluten-substrait, but BackendsApiManager explicitly warns against
backend-specific logic in common modules (gluten-substrait) (see
gluten-substrait/src/main/scala/org/apache/gluten/backendsapi/BackendsApiManager.scala:39-41).
Consider moving this override into the Velox backend’s config post-processing
(e.g., VeloxTransformerApi.postProcessNativeConfig) so the common module
remains backend-agnostic.
--
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]