rahil-c commented on code in PR #18432:
URL: https://github.com/apache/hudi/pull/18432#discussion_r3033374629
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/analysis/HoodieSparkBaseAnalysis.scala:
##########
@@ -310,6 +332,52 @@ case class ResolveReferences(spark: SparkSession) extends
Rule[LogicalPlan]
sparkAdapter.getCatalystPlanUtils.unapplyMergeIntoTable(plan)
}
+ private def resolveTableToDf(tableName: String): DataFrame = {
+ if (tableName.contains(StoragePath.SEPARATOR)) {
+ spark.read.format("hudi").load(tableName)
+ } else {
+ spark.table(tableName)
+ }
+ }
+
+ private def evaluateQueryVector(expr: Expression): Array[Double] = {
+ if (!expr.foldable) {
+ throw new HoodieAnalysisException(
+ s"Function '${HoodieVectorSearchTableValuedFunction.FUNC_NAME}': " +
+ "query vector must be a constant expression (e.g., ARRAY(1.0, 2.0,
3.0))")
+ }
+ val value = expr.eval(null)
+ if (value == null) {
+ throw new HoodieAnalysisException(
+ s"Function '${HoodieVectorSearchTableValuedFunction.FUNC_NAME}': query
vector cannot be null")
+ }
+
+ val arrayData = value.asInstanceOf[ArrayData]
+ val numElements = arrayData.numElements()
+ val elementType = expr.dataType.asInstanceOf[ArrayType].elementType
+ val result = new Array[Double](numElements)
+ var i = 0
+ elementType match {
+ case DoubleType =>
+ while (i < numElements) { result(i) = arrayData.getDouble(i); i += 1 }
+ case FloatType =>
+ while (i < numElements) { result(i) = arrayData.getFloat(i).toDouble;
i += 1 }
+ case IntegerType =>
+ while (i < numElements) { result(i) = arrayData.getInt(i).toDouble; i
+= 1 }
+ case LongType =>
Review Comment:
ok let me look into adding this.
--
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]