This is an automated email from the ASF dual-hosted git repository. twalthr pushed a commit to branch release-1.9 in repository https://gitbox.apache.org/repos/asf/flink.git
commit f2db40bfb5db641e554e4f09b5f9d58969dac551 Author: godfreyhe <[email protected]> AuthorDate: Wed Jul 17 20:08:01 2019 +0800 [FLINK-13266] [table] move ExpressionParserException & UnresolvedException to table-common module --- .../flink/table/api/ExpressionParserException.java | 29 +++++++++++ .../flink/table/api/UnresolvedException.java | 28 ++++++++++ .../table/api/ExpressionParserException.scala | 60 ---------------------- .../expressions/PlannerExpressionParserImpl.scala | 2 +- .../apache/flink/table/expressions/composite.scala | 2 +- .../flink/table/expressions/fieldExpression.scala | 12 ++--- .../org/apache/flink/table/api/exceptions.scala | 10 ---- .../expressions/PlannerExpressionParserImpl.scala | 2 +- .../apache/flink/table/expressions/composite.scala | 2 +- .../flink/table/expressions/fieldExpression.scala | 12 ++--- 10 files changed, 73 insertions(+), 86 deletions(-) diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/ExpressionParserException.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/ExpressionParserException.java new file mode 100644 index 0000000..89595ab --- /dev/null +++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/ExpressionParserException.java @@ -0,0 +1,29 @@ +/* + * 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.flink.table.api; + +/** + * Exception for all errors occurring during expression parsing. + */ +public class ExpressionParserException extends RuntimeException { + + public ExpressionParserException(String msg) { + super(msg); + } +} diff --git a/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/UnresolvedException.java b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/UnresolvedException.java new file mode 100644 index 0000000..4f7454c --- /dev/null +++ b/flink-table/flink-table-common/src/main/java/org/apache/flink/table/api/UnresolvedException.java @@ -0,0 +1,28 @@ +/* + * 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.flink.table.api; + +/** + * Exception for unwanted method calling on unresolved expression. + */ +public class UnresolvedException extends RuntimeException { + public UnresolvedException(String msg) { + super(msg); + } +} diff --git a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/api/ExpressionParserException.scala b/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/api/ExpressionParserException.scala deleted file mode 100644 index 91283bf..0000000 --- a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/api/ExpressionParserException.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.flink.table.api - -/** - * Exception for all errors occurring during expression parsing. - */ -case class ExpressionParserException(msg: String) extends RuntimeException(msg) - -/** - * Exception for unwanted method calling on unresolved expression. - */ -case class UnresolvedException(msg: String) extends RuntimeException(msg) - -/** - * Exception for adding an already existent table - * - * @param catalog catalog name - * @param table table name - * @param cause the cause - */ -case class TableAlreadyExistException( - catalog: String, - table: String, - cause: Throwable) - extends RuntimeException(s"Table $catalog.$table already exists.", cause) { - - def this(catalog: String, table: String) = this(catalog, table, null) - -} - -/** - * Exception for adding an already existent catalog - * - * @param catalog catalog name - * @param cause the cause - */ -case class CatalogAlreadyExistException( - catalog: String, - cause: Throwable) - extends RuntimeException(s"Catalog $catalog already exists.", cause) { - - def this(catalog: String) = this(catalog, null) -} diff --git a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala b/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala index 9f71209..aba1fc4 100644 --- a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala +++ b/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala @@ -719,7 +719,7 @@ object PlannerExpressionParserImpl extends JavaTokenParsers private def throwError(msg: String, next: Input): Nothing = { val improvedMsg = msg.replace("string matching regex `\\z'", "End of expression") - throw ExpressionParserException( + throw new ExpressionParserException( s"""Could not parse expression at column ${next.pos.column}: $improvedMsg |${next.pos.longString}""".stripMargin) } diff --git a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/composite.scala b/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/composite.scala index 64a2f63..d9726e8 100644 --- a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/composite.scala +++ b/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/composite.scala @@ -32,7 +32,7 @@ case class Flattening(child: PlannerExpression) extends UnaryExpression { override def toString = s"$child.flatten()" override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException(s"Invalcall to on ${this.getClass}.") + throw new UnresolvedException(s"Invalcall to on ${this.getClass}.") override private[flink] def validateInput(): ValidationResult = ValidationFailure(s"Unresolved flattening of $child") diff --git a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala b/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala index 6d19c8f..5da7e49 100644 --- a/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala +++ b/flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala @@ -59,7 +59,7 @@ case class UnresolvedFieldReference(name: String) extends Attribute { UnresolvedFieldReference(newName) override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException(s"Calling resultType on ${this.getClass}.") + throw new UnresolvedException(s"Calling resultType on ${this.getClass}.") override private[flink] def validateInput(): ValidationResult = ValidationFailure(s"Unresolved reference $name.") @@ -112,13 +112,13 @@ case class Alias(child: PlannerExpression, name: String, extraNames: Seq[String] case class UnresolvedAlias(child: PlannerExpression) extends UnaryExpression with NamedExpression { override private[flink] def name: String = - throw UnresolvedException("Invalid call to name on UnresolvedAlias") + throw new UnresolvedException("Invalid call to name on UnresolvedAlias") override private[flink] def toAttribute: Attribute = - throw UnresolvedException("Invalid call to toAttribute on UnresolvedAlias") + throw new UnresolvedException("Invalid call to toAttribute on UnresolvedAlias") override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException("Invalid call to resultType on UnresolvedAlias") + throw new UnresolvedException("Invalid call to resultType on UnresolvedAlias") override private[flink] lazy val valid = false } @@ -126,7 +126,7 @@ case class UnresolvedAlias(child: PlannerExpression) extends UnaryExpression wit case class WindowReference(name: String, tpe: Option[TypeInformation[_]] = None) extends Attribute { override private[flink] def resultType: TypeInformation[_] = - tpe.getOrElse(throw UnresolvedException("Could not resolve type of referenced window.")) + tpe.getOrElse(throw new UnresolvedException("Could not resolve type of referenced window.")) override private[flink] def withName(newName: String): Attribute = { if (newName == name) { @@ -144,7 +144,7 @@ case class TableReference(name: String, tableOperation: QueryOperation) with NamedExpression { override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException(s"Table reference '$name' has no result type.") + throw new UnresolvedException(s"Table reference '$name' has no result type.") override private[flink] def toAttribute = throw new UnsupportedOperationException(s"A table reference '$name' can not be an attribute.") diff --git a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/exceptions.scala b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/exceptions.scala index 91283bf..e355c6f 100644 --- a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/exceptions.scala +++ b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/api/exceptions.scala @@ -19,16 +19,6 @@ package org.apache.flink.table.api /** - * Exception for all errors occurring during expression parsing. - */ -case class ExpressionParserException(msg: String) extends RuntimeException(msg) - -/** - * Exception for unwanted method calling on unresolved expression. - */ -case class UnresolvedException(msg: String) extends RuntimeException(msg) - -/** * Exception for adding an already existent table * * @param catalog catalog name diff --git a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala index 32161a3..895e3da 100644 --- a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala +++ b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/PlannerExpressionParserImpl.scala @@ -721,7 +721,7 @@ object PlannerExpressionParserImpl extends JavaTokenParsers private def throwError(msg: String, next: Input): Nothing = { val improvedMsg = msg.replace("string matching regex `\\z'", "End of expression") - throw ExpressionParserException( + throw new ExpressionParserException( s"""Could not parse expression at column ${next.pos.column}: $improvedMsg |${next.pos.longString}""".stripMargin) } diff --git a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/composite.scala b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/composite.scala index 3e2c374..40e7625 100644 --- a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/composite.scala +++ b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/composite.scala @@ -34,7 +34,7 @@ case class Flattening(child: PlannerExpression) extends UnaryExpression { override def toString = s"$child.flatten()" override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException(s"Invalcall to on ${this.getClass}.") + throw new UnresolvedException(s"Invalcall to on ${this.getClass}.") override private[flink] def validateInput(): ValidationResult = ValidationFailure(s"Unresolved flattening of $child") diff --git a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala index ced9b32..4873bf6 100644 --- a/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala +++ b/flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/expressions/fieldExpression.scala @@ -63,7 +63,7 @@ case class UnresolvedFieldReference(name: String) extends Attribute { UnresolvedFieldReference(newName) override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException(s"Calling resultType on ${this.getClass}.") + throw new UnresolvedException(s"Calling resultType on ${this.getClass}.") override private[flink] def validateInput(): ValidationResult = ValidationFailure(s"Unresolved reference $name.") @@ -124,13 +124,13 @@ case class Alias(child: PlannerExpression, name: String, extraNames: Seq[String] case class UnresolvedAlias(child: PlannerExpression) extends UnaryExpression with NamedExpression { override private[flink] def name: String = - throw UnresolvedException("Invalid call to name on UnresolvedAlias") + throw new UnresolvedException("Invalid call to name on UnresolvedAlias") override private[flink] def toAttribute: Attribute = - throw UnresolvedException("Invalid call to toAttribute on UnresolvedAlias") + throw new UnresolvedException("Invalid call to toAttribute on UnresolvedAlias") override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException("Invalid call to resultType on UnresolvedAlias") + throw new UnresolvedException("Invalid call to resultType on UnresolvedAlias") override private[flink] lazy val valid = false } @@ -141,7 +141,7 @@ case class WindowReference(name: String, tpe: Option[TypeInformation[_]] = None) throw new UnsupportedOperationException("A window reference can not be used solely.") override private[flink] def resultType: TypeInformation[_] = - tpe.getOrElse(throw UnresolvedException("Could not resolve type of referenced window.")) + tpe.getOrElse(throw new UnresolvedException("Could not resolve type of referenced window.")) override private[flink] def withName(newName: String): Attribute = { if (newName == name) { @@ -162,7 +162,7 @@ case class TableReference(name: String, tableOperation: QueryOperation) throw new UnsupportedOperationException(s"Table reference '$name' can not be used solely.") override private[flink] def resultType: TypeInformation[_] = - throw UnresolvedException(s"Table reference '$name' has no result type.") + throw new UnresolvedException(s"Table reference '$name' has no result type.") override private[flink] def toAttribute = throw new UnsupportedOperationException(s"A table reference '$name' can not be an attribute.")
