Apache Drill 无法设置默认工作区

Apache Drill not able to set default workspace

目前我只能在 dfs.tmp. 工作区工作,这很烦人。所以我尝试 change the default workspace 到一个新的(现有的)文件夹(由 drill 用户拥有):

"workspaces": {
    "default": {
      "location": "/var/drill",
      "writable": true,
      "defaultInputFormat": null
    },
    "root": {
      "location": "/",
      "writable": false,
      "defaultInputFormat": null
    },
...

但是不行:

CREATE TABLE `test` as SELECT 'Test' FROM (VALUES(1))

Returns下面的错误,说明修改的设置被忽略了。

org.apache.drill.common.exceptions.UserRemoteException: PARSE ERROR: Root schema is immutable. Creating or dropping tables/views is not allowed in root schema.Select a schema using 'USE schema' command.

我也试过带前缀的(没有成功)

CREATE TABLE dfs.default.`test` as SELECT 'Test' FROM (VALUES(1))

PARSE ERROR: Encountered ". default" at line 1, column 17.

还尝试重新启动 drill 并使 root 可写。

在工作区中使用 default 以外的任何其他名称。

default 对于 Drill 来说是 reserved keyword

"Note: Default is a reserved word. You must enclose reserved words when used as identifiers in back ticks."

添加这个答案只是为了结合 ColemanTO 和 devツ 的两个现有答案 并展示一个例子。

所以,就像到目前为止的其他答案所说的那样,"default" 这个词在钻取查询中是保留的。您正确引用 docs that say to create a new default workspace in order to, say, define a writable root(/) workspace. However, the documentation 还给出了一个示例,其中为了实际引用自定义 "default" 工作区,您需要添加反引号。

因此,如果您添加了一个工作区

{
  "type": "file",
  "enabled": true,
  "connection": "hdfs:///",
  "config": null,
  "workspaces": {
    "default": {
      "location": "/some/path",
      "writable": true,
      "defaultInputFormat": null
    }
  ...
  }
 ...
}

您可以在如下查询中引用:

SELECT * FROM dfs.`default`.`path/relative/to/custom/default/location` LIMIT 10;

对于您最初发布的问题,您还可以创建一个名为 "var_drill" 的新工作区,这样您就不必在查询中转义关键字 "default" .

是的,默认是保留关键字,应该用反引号表示