CTTY commented on code in PR #9717:
URL: https://github.com/apache/hudi/pull/9717#discussion_r1380918121
##########
hudi-spark-datasource/hudi-spark/pom.xml:
##########
@@ -245,6 +245,12 @@
<groupId>org.apache.parquet</groupId>
<artifactId>parquet-avro</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.parquet</groupId>
+ <artifactId>parquet-hadoop-bundle</artifactId>
+ <version>${parquet.version}</version>
+ <scope>provided</scope>
+ </dependency>
Review Comment:
Added parquet-hadoop-bundle to fix classpath issues
```
java.lang.NoClassDefFoundError: Could not initialize class
org.apache.spark.sql.execution.datasources.parquet.ParquetOptions$
at
org.apache.spark.sql.execution.datasources.parquet.ParquetOptions.<init>(ParquetOptions.scala:50)
at
org.apache.spark.sql.execution.datasources.parquet.ParquetOptions.<init>(ParquetOptions.scala:40)
at
org.apache.spark.sql.execution.datasources.parquet.Spark34LegacyHoodieParquetFileFormat.buildReaderWithPartitionValues(Spark34LegacyHoodieParquetFileFormat.scala:150)
##########
hudi-integ-test/src/main/java/org/apache/hudi/integ/testsuite/dag/nodes/BaseValidateDatasetNode.java:
##########
@@ -244,10 +239,6 @@ private Dataset<Row> getInputDf(ExecutionContext context,
SparkSession session,
}
private ExpressionEncoder getEncoder(StructType schema) {
- List<Attribute> attributes =
JavaConversions.asJavaCollection(schema.toAttributes()).stream()
- .map(Attribute::toAttribute).collect(Collectors.toList());
- return RowEncoder.apply(schema)
-
.resolveAndBind(JavaConverters.asScalaBufferConverter(attributes).asScala().toSeq(),
- SimpleAnalyzer$.MODULE$);
+ return SparkAdapterSupport$.MODULE$.sparkAdapter().getEncoder(schema);
Review Comment:
[SPARK-44531](https://github.com/apache/spark/pull/42134) Encoder inference
moved elsewhere in Spark 3.5.0
##########
hudi-spark-datasource/hudi-spark3.5.x/src/main/scala/org/apache/spark/sql/parser/HoodieSpark3_5ExtendedSqlAstBuilder.scala:
##########
@@ -0,0 +1,3496 @@
+/*
+ * 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.parser
+
+import org.antlr.v4.runtime.tree.{ParseTree, RuleNode, TerminalNode}
+import org.antlr.v4.runtime.{ParserRuleContext, Token}
+import org.apache.hudi.spark.sql.parser.HoodieSqlBaseParser._
+import org.apache.hudi.spark.sql.parser.{HoodieSqlBaseBaseVisitor,
HoodieSqlBaseParser}
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.AnalysisException
+import org.apache.spark.sql.catalyst.analysis._
+import org.apache.spark.sql.catalyst.catalog.{BucketSpec, CatalogStorageFormat}
+import org.apache.spark.sql.catalyst.expressions._
+import org.apache.spark.sql.catalyst.expressions.aggregate.{First, Last}
+import
org.apache.spark.sql.catalyst.parser.ParserUtils.{checkDuplicateClauses,
checkDuplicateKeys, entry, escapedIdentifier, operationNotAllowed, source,
string, stringWithoutUnescape, validate, withOrigin}
+import org.apache.spark.sql.catalyst.parser.{EnhancedLogicalPlan,
ParseException, ParserInterface}
Review Comment:
[SPARK-44333](https://github.com/apache/spark/pull/41890),
EnhancedLogicalPlan moved to a different package
##########
hudi-spark-datasource/hudi-spark3.5.x/src/main/scala/org/apache/spark/sql/HoodieSpark35CatalystExpressionUtils.scala:
##########
@@ -0,0 +1,112 @@
+/*
+ * 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
+
+import org.apache.spark.sql.HoodieSparkTypeUtils.isCastPreservingOrdering
+import org.apache.spark.sql.catalyst.expressions.{Add, Attribute,
AttributeReference, AttributeSet, BitwiseOr, Cast, DateAdd, DateDiff,
DateFormatClass, DateSub, Divide, EvalMode, Exp, Expm1, Expression,
FromUTCTimestamp, FromUnixTime, Log, Log10, Log1p, Log2, Lower, Multiply,
ParseToDate, ParseToTimestamp, PredicateHelper, ShiftLeft, ShiftRight,
ToUTCTimestamp, ToUnixTimestamp, Upper}
+import org.apache.spark.sql.execution.datasources.DataSourceStrategy
+import org.apache.spark.sql.types.DataType
+
+object HoodieSpark35CatalystExpressionUtils extends
HoodieSpark3CatalystExpressionUtils with PredicateHelper {
+
+ override def normalizeExprs(exprs: Seq[Expression], attributes:
Seq[Attribute]): Seq[Expression] = {
+ DataSourceStrategy.normalizeExprs(exprs, attributes)
+ }
+
+ override def extractPredicatesWithinOutputSet(condition: Expression,
outputSet: AttributeSet): Option[Expression] = {
+ super[PredicateHelper].extractPredicatesWithinOutputSet(condition,
outputSet)
+ }
+
+ override def matchCast(expr: Expression): Option[(Expression, DataType,
Option[String])] = {
+ expr match {
+ case Cast(child, dataType, timeZoneId, _) => Some((child, dataType,
timeZoneId))
+ case _ => None
+ }
+ }
+
+ override def tryMatchAttributeOrderingPreservingTransformation(expr:
Expression): Option[AttributeReference] = {
+ expr match {
+ case OrderPreservingTransformation(attrRef) => Some(attrRef)
+ case _ => None
+ }
+ }
+
+ def canUpCast(fromType: DataType, toType: DataType): Boolean =
+ Cast.canUpCast(fromType, toType)
+
+ override def unapplyCastExpression(expr: Expression): Option[(Expression,
DataType, Option[String], Boolean)] =
+ expr match {
+ case Cast(castedExpr, dataType, timeZoneId, ansiEnabled) =>
+ Some((castedExpr, dataType, timeZoneId, if (ansiEnabled ==
EvalMode.ANSI) true else false))
+ case _ => None
+ }
+
+ private object OrderPreservingTransformation {
+ def unapply(expr: Expression): Option[AttributeReference] = {
+ expr match {
+ // Date/Time Expressions
+ case DateFormatClass(OrderPreservingTransformation(attrRef), _, _) =>
Some(attrRef)
+ case DateAdd(OrderPreservingTransformation(attrRef), _) =>
Some(attrRef)
+ case DateSub(OrderPreservingTransformation(attrRef), _) =>
Some(attrRef)
+ case DateDiff(OrderPreservingTransformation(attrRef), _) =>
Some(attrRef)
+ case DateDiff(_, OrderPreservingTransformation(attrRef)) =>
Some(attrRef)
+ case FromUnixTime(OrderPreservingTransformation(attrRef), _, _) =>
Some(attrRef)
+ case FromUTCTimestamp(OrderPreservingTransformation(attrRef), _) =>
Some(attrRef)
+ case ParseToDate(OrderPreservingTransformation(attrRef), _, _, _) =>
Some(attrRef)
Review Comment:
Added a new empty argument due to
[SPARK-43779](https://github.com/apache/spark/pull/41298/files), ParseToDate
API change
##########
packaging/hudi-utilities-slim-bundle/pom.xml:
##########
@@ -109,6 +109,8 @@
<include>com.github.davidmoten:guava-mini</include>
<include>com.github.davidmoten:hilbert-curve</include>
+ <!-- SPARK-43489 Spark 3.5+ has marked protobuf as provided
-->
+ <include>com.google.protobuf:protobuf-java</include>
Review Comment:
This is needed otherwise deltastreamer would fail due to
```
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/protobuf/Message
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2729)
##########
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/InsertIntoHoodieTableCommand.scala:
##########
@@ -180,11 +180,13 @@ object InsertIntoHoodieTableCommand extends Logging with
ProvidesHoodieConfig wi
conf: SQLConf): LogicalPlan = {
val planUtils = sparkAdapter.getCatalystPlanUtils
try {
- planUtils.resolveOutputColumns(catalogTable.catalogTableName,
expectedSchema.toAttributes, query, byName = true, conf)
+ planUtils.resolveOutputColumns(catalogTable.catalogTableName,
sparkAdapter.toAttributes(expectedSchema), query, byName = true, conf)
} catch {
// NOTE: In case matching by name didn't match the query output, we will
attempt positional matching
- case ae: AnalysisException if ae.getMessage().startsWith("Cannot write
incompatible data to table") =>
- planUtils.resolveOutputColumns(catalogTable.catalogTableName,
expectedSchema.toAttributes, query, byName = false, conf)
+ // SPARK-42309 Error message changed in Spark 3.5.0 so we need to match
two strings here
+ case ae: AnalysisException if
(ae.getMessage().startsWith("[INCOMPATIBLE_DATA_FOR_TABLE.CANNOT_FIND_DATA]
Cannot write incompatible data for the table")
+ || ae.getMessage().startsWith("Cannot write incompatible data to
table")) =>
+ planUtils.resolveOutputColumns(catalogTable.catalogTableName,
sparkAdapter.toAttributes(expectedSchema), query, byName = false, conf)
}
Review Comment:
SPARK-42309 Error message changed in Spark 3.5.0
##########
pom.xml:
##########
@@ -2507,6 +2508,66 @@
</activation>
</profile>
+ <profile>
+ <id>spark3.5</id>
+ <properties>
+ <spark3.version>${spark35.version}</spark3.version>
+ <spark.version>${spark3.version}</spark.version>
+ <sparkbundle.version>3.5</sparkbundle.version>
+ <scala12.version>2.12.18</scala12.version>
+ <scala.version>${scala12.version}</scala.version>
+ <scala.binary.version>2.12</scala.binary.version>
+ <hudi.spark.module>hudi-spark3.5.x</hudi.spark.module>
+ <!-- This glob has to include hudi-spark3-common,
hudi-spark3.2plus-common -->
+
<hudi.spark.common.modules.1>hudi-spark3-common</hudi.spark.common.modules.1>
+
<hudi.spark.common.modules.2>hudi-spark3.2plus-common</hudi.spark.common.modules.2>
+ <scalatest.version>${scalatest.spark3.version}</scalatest.version>
+ <kafka.version>${kafka.spark3.version}</kafka.version>
+ <hive.storage.version>2.8.1</hive.storage.version>
+ <!-- NOTE: Some Hudi modules require standalone Parquet/Orc/etc
file-format dependency (hudi-hive-sync,
+ hudi-hadoop-mr, for ex). Since these Hudi modules might be
used from w/in the execution engine(s)
+ bringing these file-formats as dependencies as well, we
need to make sure that versions are
+ synchronized to avoid classpath ambiguity -->
+ <parquet.version>1.13.1</parquet.version>
+ <orc.spark.version>1.9.1</orc.spark.version>
+ <avro.version>1.11.2</avro.version>
+ <antlr.version>4.9.3</antlr.version>
+ <fasterxml.spark3.version>2.15.2</fasterxml.spark3.version>
+ <fasterxml.version>${fasterxml.spark3.version}</fasterxml.version>
+
<fasterxml.jackson.databind.version>${fasterxml.spark3.version}</fasterxml.jackson.databind.version>
+
<fasterxml.jackson.module.scala.version>${fasterxml.spark3.version}</fasterxml.jackson.module.scala.version>
+
<fasterxml.jackson.dataformat.yaml.version>${fasterxml.spark3.version}</fasterxml.jackson.dataformat.yaml.version>
+
<pulsar.spark.version>${pulsar.spark.scala12.version}</pulsar.spark.version>
+ <log4j2.version>2.20.0</log4j2.version>
+ <slf4j.version>2.0.7</slf4j.version>
+ <skip.hudi-spark2.unit.tests>true</skip.hudi-spark2.unit.tests>
+ <skipITs>true</skipITs>
+ </properties>
+ <modules>
+ <module>hudi-spark-datasource/hudi-spark3.5.x</module>
+ <module>hudi-spark-datasource/hudi-spark3-common</module>
+ <module>hudi-spark-datasource/hudi-spark3.2plus-common</module>
+ </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>${hive.groupid}</groupId>
+ <artifactId>hive-storage-api</artifactId>
+ <version>${hive.storage.version}</version>
+ </dependency>
+ </dependencies>
+ <activation>
+ <property>
+ <name>spark3.5</name>
+ </property>
+ </activation>
+ </profile>
+
Review Comment:
I haven't changed the default Spark3 profile to Spark 3.5
##########
packaging/hudi-utilities-bundle/pom.xml:
##########
@@ -122,6 +122,8 @@
<include>com.github.davidmoten:guava-mini</include>
<include>com.github.davidmoten:hilbert-curve</include>
<include>com.github.ben-manes.caffeine:caffeine</include>
+ <!-- SPARK-43489 Spark 3.5+ has marked protobuf as provided
-->
+ <include>com.google.protobuf:protobuf-java</include>
<include>com.twitter:bijection-avro_${scala.binary.version}</include>
Review Comment:
This is needed otherwise deltastreamer would fail due to
```
Exception in thread "main" java.lang.NoClassDefFoundError:
com/google/protobuf/Message
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2729)
--
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]