[
https://issues.apache.org/jira/browse/DRILL-4956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15800068#comment-15800068
]
ASF GitHub Bot commented on DRILL-4956:
---------------------------------------
Github user paul-rogers commented on a diff in the pull request:
https://github.com/apache/drill/pull/666#discussion_r94692337
--- Diff:
exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/handlers/DropTableHandler.java
---
@@ -55,35 +58,79 @@ public DropTableHandler(SqlHandlerConfig config) {
*/
@Override
public PhysicalPlan getPlan(SqlNode sqlNode) throws ValidationException,
RelConversionException, IOException {
-
SqlDropTable dropTableNode = ((SqlDropTable) sqlNode);
- SqlIdentifier tableIdentifier = dropTableNode.getTableIdentifier();
-
+ String originalTableName = dropTableNode.getName();
SchemaPlus defaultSchema = config.getConverter().getDefaultSchema();
- AbstractSchema drillSchema = null;
+ List<String> tableSchema = dropTableNode.getSchema();
+
+ boolean removedTemporaryTable = removeTemporaryTable(defaultSchema,
tableSchema, originalTableName);
+ // if table to be dropped is not temporary table, we need to check
among persistent tables or views
+ if (!removedTemporaryTable) {
+ AbstractSchema drillSchema =
SchemaUtilites.resolveToMutableDrillSchema(defaultSchema, tableSchema);
+ Table tableToDrop = SqlHandlerUtil.getTableFromSchema(drillSchema,
originalTableName);
+ if (tableToDrop == null || tableToDrop.getJdbcTableType() !=
Schema.TableType.TABLE) {
+ if (dropTableNode.checkTableExistence()) {
+ return DirectPlan.createDirectPlan(context, false,
String.format("Table [%s] not found", originalTableName));
+ } else {
+ throw UserException.validationError().message("Table [%s] not
found", originalTableName).build(logger);
+ }
+ }
- if (tableIdentifier != null) {
- drillSchema =
SchemaUtilites.resolveToMutableDrillSchema(defaultSchema,
dropTableNode.getSchema());
+ try {
+ drillSchema.dropTable(originalTableName);
+ } catch (Exception e) {
+ // concurrency check: we might have failed because somebody has
already dropped the table
+ if (SqlHandlerUtil.getTableFromSchema(drillSchema,
originalTableName) != null) {
+ throw e;
--- End diff --
Will this exception contain a user-meaningful message? That is will it say
"Failed to delete table x"? Or will it say "Linux error 5 - inode invalid?"
Should we wrap this in a user exception?
> Temporary tables support
> ------------------------
>
> Key: DRILL-4956
> URL: https://issues.apache.org/jira/browse/DRILL-4956
> Project: Apache Drill
> Issue Type: Improvement
> Affects Versions: 1.8.0
> Reporter: Arina Ielchiieva
> Assignee: Arina Ielchiieva
> Labels: doc-impacting
> Fix For: Future
>
>
> Link to design doc -
> https://docs.google.com/document/d/1gSRo_w6q2WR5fPx7SsQ5IaVmJXJ6xCOJfYGyqpVOC-g/edit
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)