dongjoon-hyun commented on code in PR #41683:
URL: https://github.com/apache/spark/pull/41683#discussion_r1287774757
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/basicLogicalOperators.scala:
##########
@@ -1118,6 +1122,38 @@ case class Range(
}
}
+@ExpressionDescription(
+ usage = "_FUNC_(identifier: String, options: Map) - " +
+ "Returns the data source relation with the given options.",
+ examples = """
+ Examples:
+ > SELECT * FROM _FUNC_('cat.db.table', map('foo','bar'));
+ 1,a
+ """,
+ since = "3.5.0",
+ group = "table_funcs")
+case class RelationWithOptions(child: LogicalPlan)
+ extends UnaryNode {
+ override def output: Seq[Attribute] = Nil
+
+ def this(identifier: Expression, options: Expression) = {
+ this(RelationWithOptions.childRelation(identifier, options))
+ }
+
+ override protected def withNewChildInternal(newChild: LogicalPlan):
LogicalPlan =
+ copy(child = newChild)
+}
+
+object RelationWithOptions {
+ def childRelation(identifier: Expression, options: Expression):
UnresolvedRelation = {
+ val tableIdentifier = CatalystSqlParser.parseMultipartIdentifier(
+ identifier.asInstanceOf[Literal].toString)
+ val relationOptions = ExprUtils.convertToMapData(options)
+ UnresolvedRelation(tableIdentifier,
+ new CaseInsensitiveStringMap(relationOptions.asJava))
Review Comment:
nit. Shall we make a single line because it's short?
```scala
UnresolvedRelation(tableIdentifier, new
CaseInsensitiveStringMap(relationOptions.asJava))
```
--
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]