dongjoon-hyun commented on code in PR #56992: URL: https://github.com/apache/spark/pull/56992#discussion_r3525562684
########## sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/orc/types/ops/OrcTypeOps.scala: ########## @@ -0,0 +1,169 @@ +/* + * 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.orc.types.ops + +import org.apache.hadoop.hive.ql.io.sarg.PredicateLeaf +import org.apache.hadoop.io.WritableComparable +import org.apache.orc.TypeDescription + +import org.apache.spark.sql.catalyst.expressions.SpecializedGetters +import org.apache.spark.sql.types.{DataType, TimestampLTZNanosType, TimestampNTZNanosType, TimeType} + +/** + * Optional trait for ORC storage-format integration in the Types Framework. + * + * Implement this trait to enable ORC read/write support for a framework type. Each framework + * type that supports ORC provides a concrete implementation and registers it in the companion + * object's apply() method. + * + * The trait covers the ORC concerns that are homogeneous across the row-based code paths: + * - Schema mapping: Spark DataType -> ORC schema string (OrcUtils.getOrcSchemaString) and the + * ORC TypeDescription category (OrcUtils.orcTypeDescription). ORC has no native TIME / + * nanosecond-timestamp category, so framework types map onto an existing physical ORC + * category and round-trip the true Spark type via the CATALYST_TYPE_ATTRIBUTE_NAME attribute + * (stamped uniformly by the caller, so the ops only chooses the category). + * - Value write (serialize): Catalyst value -> ORC WritableComparable + * (OrcSerializer.newConverter) + * - Row-based read (deserialize): ORC WritableComparable -> Catalyst value + * (OrcDeserializer.newWriter) + * - Predicate pushdown: PredicateLeaf.Type mapping + literal casting (OrcFilters) + * + * DELIBERATELY NOT ON THE TRAIT: + * - Vectorized read. ORC's vectorized path (OrcAtomicColumnVector, a Java class) dispatches via + * boolean `instanceof` flags set in the constructor plus typed accessor methods + * (getTimestampNTZNanos/getTimestampLTZNanos), NOT via an `Ops(dt).map(_.x)` closure. It has + * no per-type extension seam, so it stays inline. This mirrors Parquet, whose vectorized read + * is likewise not routed through ParquetTypeOps (it dispatches on the Spark type inline in + * ParquetVectorUpdaterFactory.getUpdater). + * - supportDataType. OrcFileFormat.supportDataType / OrcTable.supportsDataType already admit + * every `AtomicType` via `case _: AtomicType => true`, so framework types are supported with + * no per-type arm; no gate method is needed (unlike Parquet, whose default differs). + * + * DISPATCH PATTERN: framework FIRST at each row-path integration site. Each ORC infrastructure Review Comment: Is this correct? This PR seems to inject `framework` at the `LAST` (instead of `FIRST`). -- 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]
