kazdy commented on code in PR #8729: URL: https://github.com/apache/hudi/pull/8729#discussion_r1217898440
########## hudi-spark-datasource/hudi-spark3.2plus-common/src/main/scala/org/apache/spark/sql/catalyst/plans/logcal/HoodieTableChanges.scala: ########## @@ -0,0 +1,91 @@ +/* + * 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.catalyst.plans.logcal + +import org.apache.hudi.common.util.ValidationUtils.checkState +import org.apache.spark.sql.AnalysisException +import org.apache.spark.sql.catalyst.expressions.{Attribute, Expression} +import org.apache.spark.sql.catalyst.plans.logical.LeafNode + +object HoodieTableChangesOptionsParser { + def parseOptions(exprs: Seq[Expression], funcName: String): (String, Map[String, String]) = { + val args = exprs.map(_.eval().toString) + + if (args.size < 3) { + throw new AnalysisException(s"Too few arguments for function `$funcName`") Review Comment: I only found that in one case in pgsql dblink function uses ```sql select * from dblink('dbname=mydb options=-csearch_path=', 'select proname, prosrc from pg_proc') ``` But that's a db connection string passed as one argument so not exactly the same case. I've only seen tvf arguments to be resolved by position. The declaration of func arguments can be done by name, but I have not seen anywhere that I can call my function by using `select * from myfunc(path='abc')`. I like this: ``` hudi_table_changes(path='xxx/yyy', 'cdc', 123456, 123456) ``` but this not so much: ``` hudi_table_changes('path=xxx/yyy', 'cdc', 123456, 123456) ``` and 1st is not supported in Spark SQL syntax atm. I found one ticket that aims to implement named argument support in parser for function call: https://issues.apache.org/jira/browse/SPARK-43922 targeted for Spark 3.5, so maybe this can be done in the future in an elegant way. This is how another implementation for a similar function in spark was done: https://learn.microsoft.com/en-us/azure/databricks/delta/delta-change-data-feed#sql Nevertheless, what should the syntax in the mentioned standard look like then? I was not able to find any information on what the sql standard defines. Can you give me an example? Should only the first argument be either "path=xxx/xxx", "identifier=db.tableName", or "identifier=tableName" and the rest stay as is so that users don't need to write too much in their queries? -- 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]
