Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ public final class FailingSqlTestStep implements TestStep {
FailingSqlTestStep(
String sql, Class<? extends Exception> expectedException, String expectedErrorMessage) {
Preconditions.checkArgument(
// UnsupportedOperationException is a special case in GenerateUtils#generateCompare
expectedException == ValidationException.class
|| expectedException == TableRuntimeException.class
|| expectedException == UnsupportedOperationException.class,
|| expectedException == TableRuntimeException.class,
"Usually a SQL query should fail with either validation or runtime exception. "
+ "Otherwise this might require an update to the exception design.");
this.sql = sql;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.apache.flink.table.planner.codegen
import org.apache.flink.api.common.ExecutionConfig
import org.apache.flink.api.common.serialization.SerializerConfigImpl
import org.apache.flink.api.common.typeinfo.{AtomicType => AtomicTypeInfo}
import org.apache.flink.table.api.ValidationException
import org.apache.flink.table.data._
import org.apache.flink.table.data.binary.{BinaryRowData, BinaryStringData}
import org.apache.flink.table.data.utils.JoinedRowData
Expand Down Expand Up @@ -636,9 +637,10 @@ object GenerateUtils {
INTERVAL_YEAR_MONTH | INTERVAL_DAY_TIME =>
s"($leftTerm > $rightTerm ? 1 : $leftTerm < $rightTerm ? -1 : 0)"
case TIMESTAMP_WITH_TIME_ZONE | MULTISET | MAP | VARIANT | BITMAP =>
throw new UnsupportedOperationException(
s"Type($t) is not an orderable data type, " +
s"it is not supported as a ORDER_BY/GROUP_BY/JOIN_EQUAL field.")
throw new ValidationException(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't it be TableRuntimeException?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just compare javadoc


vs
* Exception for all errors occurring during validation phase.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we are not in execution yet. This is still plan / job graph preparation.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought a bit about this and it's a deterministic error that will be thrown during validation time, so I think validation is the right call as well

s"Type '$t' cannot be ordered, so it cannot be used as a key for sorting, grouping, " +
s"or joining (for example in ORDER BY, GROUP BY, DISTINCT, or a join condition). " +
s"Remove it from the key, or replace it with a value that can be ordered.")
// TODO support MULTISET and MAP?
case ARRAY =>
val at = t.asInstanceOf[ArrayType]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.flink.table.planner.plan.nodes.exec.stream;

import org.apache.flink.table.api.DataTypes;
import org.apache.flink.table.api.ValidationException;
import org.apache.flink.table.functions.AggregateFunction;
import org.apache.flink.table.functions.ScalarFunction;
import org.apache.flink.table.functions.TableFunction;
Expand Down Expand Up @@ -217,9 +218,11 @@ public List<TableTestProgram> programs() {
"INSERT INTO sink_t "
+ "SELECT FIRST_VALUE(ts) OVER (ORDER BY bm) "
+ "FROM TABLE(TUMBLE(TABLE t, DESCRIPTOR(ts), INTERVAL '1' SECOND))",
UnsupportedOperationException.class,
"Type(BITMAP) is not an orderable data type, "
+ "it is not supported as a ORDER_BY/GROUP_BY/JOIN_EQUAL field.")
ValidationException.class,
"Type 'BITMAP' cannot be ordered, so it cannot be used as a key for "
+ "sorting, grouping, or joining (for example in ORDER BY, "
+ "GROUP BY, DISTINCT, or a join condition). Remove it from the "
+ "key, or replace it with a value that can be ordered.")
.build();

static final TableTestProgram BITMAP_AS_DISTINCT_KEY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1063,8 +1063,12 @@ class CalcITCase extends BatchTestBase {
assertThatThrownBy(
() =>
checkResult("SELECT COUNT(*) FROM SmallTable3 GROUP BY MAP[1, 'Hello', 2, 'Hi']", Seq()))
.isInstanceOf(classOf[ValidationException])
.hasMessage(
"Type(MAP<INT NOT NULL, VARCHAR(5) NOT NULL> NOT NULL) is not an orderable data type, it is not supported as a ORDER_BY/GROUP_BY/JOIN_EQUAL field.")
"Type 'MAP<INT NOT NULL, VARCHAR(5) NOT NULL> NOT NULL' cannot be ordered, so it cannot " +
"be used as a key for sorting, grouping, or joining (for example in ORDER BY, GROUP " +
"BY, DISTINCT, or a join condition). Remove it from the key, or replace it with a " +
"value that can be ordered.")
}

@Test
Expand Down