use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class TestImplicitColumnResolver method testProvidedPartitionColModeConflict.
@Test
public void testProvidedPartitionColModeConflict() {
TupleMetadata providedSchema = new SchemaBuilder().add("myDir", MinorType.VARCHAR).build();
SchemaUtils.markAsPartition(providedSchema.metadata("myDir"), 0);
ParserFixture parseFixture = new ParserFixture(RowSetTestUtils.projectAll());
parseFixture.tracker.applyProvidedSchema(providedSchema);
parseFixture.options.maxPartitionDepth(1);
try {
parseFixture.parseImplicit();
} catch (UserException e) {
assertTrue(e.getMessage().contains("wrong type"));
}
}
use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class TestLateralJoinCorrectness method testUnsupportedSelectionVector.
/**
* Test unsupported incoming batch to LATERAL with SelectionVector
* @throws Exception
*/
@Test
public void testUnsupportedSelectionVector() throws Exception {
final RowSet.SingleRowSet leftRowSet2 = fixture.rowSetBuilder(leftSchema).addRow(2, 20, "item20").withSv2().build();
// Get the left container with dummy data for Lateral Join
leftContainer.add(leftRowSet2.container());
// Get the left IterOutcomes for Lateral Join
leftOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
// Create Left MockRecordBatch
final CloseableRecordBatch leftMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, leftContainer, leftOutcomes, leftContainer.get(0).getSchema());
// Get the right container with dummy data
rightContainer.add(emptyRightRowSet.container());
rightOutcomes.add(RecordBatch.IterOutcome.OK_NEW_SCHEMA);
final CloseableRecordBatch rightMockBatch = new MockRecordBatch(fixture.getFragmentContext(), operatorContext, rightContainer, rightOutcomes, rightContainer.get(0).getSchema());
final LateralJoinBatch ljBatch = new LateralJoinBatch(ljPopConfig, fixture.getFragmentContext(), leftMockBatch, rightMockBatch);
try {
ljBatch.next();
fail();
} catch (UserException e) {
assertEquals(ErrorType.UNSUPPORTED_OPERATION, e.getErrorType());
} catch (AssertionError | Exception error) {
fail();
} finally {
// Close all the resources for this test case
ljBatch.close();
leftMockBatch.close();
rightMockBatch.close();
leftRowSet2.clear();
}
}
use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class PreProcessLogicalRel method getConvertFunctionException.
private UserException getConvertFunctionException(final String functionName, final String typeName) {
final String newFunctionName = functionName + typeName;
final String typeNameToPrint = typeName.length() == 0 ? "<empty_string>" : typeName;
final UserException.Builder exceptionBuilder = UserException.unsupportedError().message("%s does not support conversion %s type '%s'.", functionName, functionName.substring(8).toLowerCase(), typeNameToPrint);
// Build a nice error message
if (typeName.length() > 0) {
List<String> ops = new ArrayList<>();
for (SqlOperator op : table.getOperatorList()) {
ops.add(op.getName());
}
final String bestMatch = ApproximateStringMatcher.getBestMatch(ops, newFunctionName);
if (bestMatch != null && bestMatch.length() > functionName.length() && bestMatch.toLowerCase().startsWith("convert")) {
final StringBuilder s = new StringBuilder("Did you mean ").append(bestMatch.substring(functionName.length())).append("?");
exceptionBuilder.addContext(s.toString());
}
}
return exceptionBuilder.build(logger);
}
use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class DrillOptiqTest method testUnsupportedRexNode.
/* Method checks if we raise the appropriate error while dealing with RexNode that cannot be converted to
* equivalent Drill expressions
*/
@Test
public void testUnsupportedRexNode() {
try {
// Create the data type factory.
RelDataTypeFactory relFactory = new SqlTypeFactoryImpl(DrillRelDataTypeSystem.DRILL_REL_DATATYPE_SYSTEM);
// Create the rex builder
RexBuilder rex = new RexBuilder(relFactory);
RelDataType anyType = relFactory.createSqlType(SqlTypeName.ANY);
List<RexNode> emptyList = new LinkedList<>();
ImmutableList<RexFieldCollation> e = ImmutableList.copyOf(new RexFieldCollation[0]);
// create a dummy RexOver object.
RexNode window = rex.makeOver(anyType, SqlStdOperatorTable.AVG, emptyList, emptyList, GuavaUtils.convertToUnshadedImmutableList(e), null, null, true, false, false, false);
DrillOptiq.toDrill(null, (RelNode) null, window);
} catch (UserException e) {
if (e.getMessage().contains(DrillOptiq.UNSUPPORTED_REX_NODE_ERROR)) {
// got expected error return
return;
}
Assert.fail("Hit exception with unexpected error message");
}
Assert.fail("Failed to raise the expected exception");
}
use of org.apache.drill.common.exceptions.UserException in project drill by apache.
the class TestExtendedArrays method testDateNull.
@Test
public void testDateNull() {
LocalDateTime local = LocalDateTime.of(2020, 4, 21, 11, 22, 33);
Instant instant = local.atZone(ZoneId.systemDefault()).toInstant();
String utc = DateTimeFormatter.ISO_INSTANT.format(instant);
String json = "{ a: [ { \"$date\": \"" + utc + "\" }, null ] }\n";
JsonLoaderFixture loader = new JsonLoaderFixture();
loader.jsonOptions.enableExtendedTypes = true;
loader.open(json);
try {
loader.next();
fail();
} catch (UserException e) {
assertTrue(e.getMessage().contains("does not allow null values"));
}
loader.close();
}
Aggregations