anuragmantri commented on code in PR #60392:
URL: https://github.com/apache/spark/pull/60392#discussion_r4620412994
##########
sql/core/src/test/scala/org/apache/spark/sql/connector/ProcedureSuite.scala:
##########
@@ -1098,6 +1234,59 @@ class ProcedureSuite extends SharedSparkSession with
BeforeAndAfter {
override def description: String = "simple sum integers"
}
+ abstract class TimestampProcedure extends BoundProcedure {
+ override def description: String = "returns a timestamp and an optional
label"
+
+ override def isDeterministic: Boolean = true
+
+ override def parameters: Array[ProcedureParameter] = Array(
+ ProcedureParameter.in("ts", DataTypes.TimestampType).build(),
+ ProcedureParameter.in("label",
DataTypes.StringType).defaultValue("'none'").build())
+
+ def outputType: StructType = new StructType()
+ .add("ts", DataTypes.TimestampType)
+ .add("label", DataTypes.StringType)
+
+ override def call(input: InternalRow): java.util.Iterator[Scan] = {
+ val result = Result(outputType, Array(InternalRow(input.getLong(0),
input.getUTF8String(1))))
+ Collections.singleton[Scan](result).iterator()
+ }
+ }
+
+ object SimpleTimestampProcedure extends TimestampProcedure with
SimpleProcedure {
+ override def name: String = "simple_ts"
+ }
+
+ class RebindingTimestampProcedure(binds: AtomicInteger, isBound: Boolean)
+ extends TimestampProcedure with UnboundProcedure {
+
+ override def name: String = "rebinding_ts"
+
+ override def bind(inputType: StructType): BoundProcedure = {
+ binds.incrementAndGet()
+ new RebindingTimestampProcedure(binds, isBound = true)
+ }
+
+ override def parameters: Array[ProcedureParameter] = {
+ assert(isBound, "only the procedure returned by bind can be used")
+ super.parameters
+ }
+
+ override def call(input: InternalRow): java.util.Iterator[Scan] = {
+ assert(isBound, "only the procedure returned by bind can be used")
+ super.call(input)
+ }
+ }
+
+ object SimpleDateProcedure extends SimpleProcedure {
Review Comment:
I kept DATE, since DOUBLE cannot be cast to DATE even explicitly.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala:
##########
@@ -1039,8 +1039,25 @@ trait CheckAnalysis extends LookupCatalog with
QueryErrorsBase with PlanToString
varName,
c.defaultExpr.originalSQL)
- case c: Call if c.resolved && c.bound && c.checkArgTypes().isFailure
=>
+ case c: Call if c.resolved =>
Review Comment:
Updated the description.
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala:
##########
@@ -1039,8 +1039,25 @@ trait CheckAnalysis extends LookupCatalog with
QueryErrorsBase with PlanToString
varName,
c.defaultExpr.originalSQL)
- case c: Call if c.resolved && c.bound && c.checkArgTypes().isFailure
=>
+ case c: Call if c.resolved =>
+ if (!c.bound) {
+ val invalidExprSqls = c.args.map {
+ case NamedArgumentExpression(_, value) => value
+ case arg => arg
+ }.filter(_.references.nonEmpty).map(toSQLExpr)
Review Comment:
Done. The list now also has the aggregate, window and generator expressions,
without duplicates. Added both cases to the time window test.
--
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]