use of org.apache.flink.table.api.ValidationException in project flink by apache.
the class DataGenTableSourceFactoryTest method testLackStartForSequence.
@Test
public void testLackStartForSequence() {
try {
DescriptorProperties descriptor = new DescriptorProperties();
descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen");
descriptor.putString(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, DataGenConnectorOptionsUtil.SEQUENCE);
descriptor.putLong(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.END, 100);
createTableSource(ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), descriptor.asMap());
} catch (ValidationException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause.toString(), cause instanceof ValidationException);
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("Could not find required property 'fields.f0.start' for sequence generator."));
return;
}
Assert.fail("Should fail by ValidationException.");
}
use of org.apache.flink.table.api.ValidationException in project flink by apache.
the class DataGenTableSourceFactoryTest method testWrongStartInRandom.
@Test
public void testWrongStartInRandom() {
try {
DescriptorProperties descriptor = new DescriptorProperties();
descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen");
descriptor.putString(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, DataGenConnectorOptionsUtil.RANDOM);
descriptor.putLong(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.START, 0);
createTableSource(ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), descriptor.asMap());
} catch (ValidationException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause.toString(), cause instanceof ValidationException);
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("Unsupported options:\n\nfields.f0.start"));
return;
}
Assert.fail("Should fail by ValidationException.");
}
use of org.apache.flink.table.api.ValidationException in project flink by apache.
the class DataGenTableSourceFactoryTest method testWrongLenInRandomLong.
@Test
public void testWrongLenInRandomLong() {
try {
DescriptorProperties descriptor = new DescriptorProperties();
descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen");
descriptor.putString(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, DataGenConnectorOptionsUtil.RANDOM);
descriptor.putInt(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.LENGTH, 100);
createTableSource(ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), descriptor.asMap());
} catch (ValidationException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause.toString(), cause instanceof ValidationException);
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("Unsupported options:\n\nfields.f0.length"));
return;
}
Assert.fail("Should fail by ValidationException.");
}
use of org.apache.flink.table.api.ValidationException in project flink by apache.
the class DataGenTableSourceFactoryTest method testWrongTypes.
@Test
public void testWrongTypes() {
try {
DescriptorProperties descriptor = new DescriptorProperties();
descriptor.putString(FactoryUtil.CONNECTOR.key(), "datagen");
descriptor.putString(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.KIND, DataGenConnectorOptionsUtil.SEQUENCE);
descriptor.putString(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.START, "Wrong");
descriptor.putString(DataGenConnectorOptionsUtil.FIELDS + ".f0." + DataGenConnectorOptionsUtil.END, "Wrong");
createTableSource(ResolvedSchema.of(Column.physical("f0", DataTypes.BIGINT())), descriptor.asMap());
} catch (ValidationException e) {
Throwable cause = e.getCause();
Assert.assertTrue(cause.toString(), cause instanceof IllegalArgumentException);
Assert.assertTrue(cause.getMessage(), cause.getMessage().contains("Could not parse value 'Wrong' for key 'fields.f0.start'"));
return;
}
Assert.fail("Should fail by ValidationException.");
}
use of org.apache.flink.table.api.ValidationException in project flink by apache.
the class TableImpl method select.
@Override
public Table select(Expression... fields) {
List<Expression> expressionsWithResolvedCalls = preprocessExpressions(fields);
CategorizedExpressions extracted = OperationExpressionsUtils.extractAggregationsAndProperties(expressionsWithResolvedCalls);
if (!extracted.getWindowProperties().isEmpty()) {
throw new ValidationException("Window properties can only be used on windowed tables.");
}
if (!extracted.getAggregations().isEmpty()) {
QueryOperation aggregate = operationTreeBuilder.aggregate(Collections.emptyList(), extracted.getAggregations(), operationTree);
return createTable(operationTreeBuilder.project(extracted.getProjections(), aggregate, false));
} else {
return createTable(operationTreeBuilder.project(expressionsWithResolvedCalls, operationTree, false));
}
}
Aggregations