[
https://issues.apache.org/jira/browse/FLINK-3754?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15278207#comment-15278207
]
ASF GitHub Bot commented on FLINK-3754:
---------------------------------------
Github user fhueske commented on a diff in the pull request:
https://github.com/apache/flink/pull/1958#discussion_r62685176
--- Diff:
flink-libraries/flink-table/src/main/scala/org/apache/flink/api/table/table.scala
---
@@ -472,61 +339,39 @@ class Table(
tableEnv.emitToSink(this, configuredSink)
}
- private def createRenamingProject(exprs: Seq[RexNode]): LogicalProject =
{
-
- val names = exprs.map{ e =>
- e.getKind match {
- case SqlKind.AS =>
- e.asInstanceOf[RexCall].getOperands.get(1)
- .asInstanceOf[RexLiteral].getValue
- .asInstanceOf[NlsString].getValue
- case SqlKind.INPUT_REF =>
-
relNode.getRowType.getFieldNames.get(e.asInstanceOf[RexInputRef].getIndex)
- case _ =>
- throw new PlanGenException("Unexpected expression type
encountered.")
- }
-
- }
- LogicalProject.create(relNode, exprs.toList.asJava,
names.toList.asJava)
- }
-
private def checkUniqueNames(exprs: Seq[Expression]): Unit = {
val names: mutable.Set[String] = mutable.Set()
exprs.foreach {
- case n: Naming =>
+ case n: Alias =>
// explicit name
if (names.contains(n.name)) {
- throw new IllegalArgumentException(s"Duplicate field name
$n.name.")
+ throw new ValidationException(s"Duplicate field name $n.name.")
} else {
names.add(n.name)
}
case u: UnresolvedFieldReference =>
// simple field forwarding
if (names.contains(u.name)) {
- throw new IllegalArgumentException(s"Duplicate field name
$u.name.")
+ throw new ValidationException(s"Duplicate field name $u.name.")
} else {
names.add(u.name)
}
case _ => // Do nothing
}
}
+ @inline protected def validate(logicalNode: => LogicalNode): Table = {
+ new Table(tableEnv, logicalNode.validate(tableEnv))
--- End diff --
Would it be OK to remove this method and move the `new Table` call to each
API method?
I think this would make the code easier to read.
> Add a validation phase before construct RelNode using TableAPI
> --------------------------------------------------------------
>
> Key: FLINK-3754
> URL: https://issues.apache.org/jira/browse/FLINK-3754
> Project: Flink
> Issue Type: Improvement
> Components: Table API
> Affects Versions: 1.0.0
> Reporter: Yijie Shen
> Assignee: Yijie Shen
>
> Unlike sql string's execution, which have a separate validation phase before
> RelNode construction, Table API lacks the counterparts and the validation is
> scattered in many places.
> I suggest to add a single validation phase and detect problems as early as
> possible.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)