rahil-c commented on code in PR #18432:
URL: https://github.com/apache/hudi/pull/18432#discussion_r3037488208
##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/spark/sql/hudi/analysis/HoodieSparkBaseAnalysis.scala:
##########
@@ -310,6 +327,61 @@ case class ResolveReferences(spark: SparkSession) extends
Rule[LogicalPlan]
sparkAdapter.getCatalystPlanUtils.unapplyMergeIntoTable(plan)
}
+ /**
+ * Resolves a table reference to a DataFrame. Accepts either a table
identifier
+ * (including multi-part identifiers like catalog.db.table) or a file path.
+ */
+ private def resolveTableToDf(table: String): DataFrame = {
+ try {
+ if (table.contains(StoragePath.SEPARATOR)) {
+ spark.read.format("hudi").load(table)
+ } else {
+ spark.table(table)
+ }
+ } catch {
+ case e: Exception => throw new HoodieAnalysisException(
+ s"hudi_vector_search: unable to resolve table '$table':
${e.getMessage}")
+ }
+ }
+
+ 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
Review Comment:
I still do not understand why the user would pass a single scaler value like
hudi_vector_search('t', 'emb', 1.0, 5) or hudi_vector_search('t', 'emb',
'text', 5).
I can address this but seems highly unlikely.
--
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]