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 @@ -29,6 +29,7 @@
import org.apache.druid.catalog.model.table.ExternalTableSpec;
import org.apache.druid.data.input.InputFormat;
import org.apache.druid.data.input.InputSource;
import org.apache.druid.error.DruidException;
import org.apache.druid.guice.annotations.Json;
import org.apache.druid.java.util.common.IAE;
import org.apache.druid.segment.column.RowSignature;
Expand Down Expand Up @@ -120,7 +121,9 @@ public ExternalTableSpec apply(
);
}
catch (JsonProcessingException e) {
throw new RuntimeException(e);
throw DruidException.forPersona(DruidException.Persona.USER)
.ofCategory(DruidException.Category.INVALID_INPUT)
.build(e, e.getMessage());
Comment on lines +124 to +126
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.

For this one specifically, just so you know, there is an InvalidInput.exception() that you can use. This makes it part of the "invalidInput" group of exceptions instead of the "general" group of exceptions.

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1410,4 +1410,34 @@ public void testInsertWithSqlOuterLimit()
)
.verify();
}

@Test
public void testErrorWithUnableToConstructColumnSignatureWithExtern()
{
final String sqlString = "insert into dst \n"
+ "select time_parse(\"time\") as __time, * \n"
+ "from table( \n"
+ "extern(\n"
+ "'{\"type\": \"s3\", \"uris\": [\\\"s3://imply-eng-datasets/qa/IngestionTest/wikipedia/files/wikiticker-2015-09-12-sampled.mini.json.gz\\\"]}',\n"
+ "'{\"type\": \"json\"}',\n"
+ "'[{\"name\": \"time\", \"type\": \"string\"}, {\"name\": \"channel\", \"type\": \"string\"}, {\"countryName\": \"string\"}]'\n"
+ ")\n"
+ ")\n"
+ "partitioned by DAY\n"
+ "clustered by channel";
HashMap<String, Object> context = new HashMap<>(DEFAULT_CONTEXT);
context.put(PlannerContext.CTX_SQL_OUTER_LIMIT, 100);
testIngestionQuery().context(context).sql(sqlString)
.expectValidationError(
new DruidExceptionMatcher(
DruidException.Persona.USER,
DruidException.Category.INVALID_INPUT,
"general"
)
.expectMessageContains(
"Cannot construct instance of `org.apache.druid.segment.column.ColumnSignature`, problem: `java.lang.NullPointerException`\n"
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.

For this case specificaly, it would be great if the original NPE actually carried with it an indication of which field it expected to exist. That is, we likely need to get even deeper and make a better message for the NPE as well.

)
)
.verify();
}
}