java - 通过 Apache Drill 访问 Postgres 中的复合数据

标签 java apache postgresql apache-drill

我对 Apache Drill 相当陌生。我需要查询我的 PostgreSQL 数据库 使用 Apache 钻。 我浏览了documentation并且可以 为我的 Postgres 数据库配置存储插件。

{

  "type": "jdbc",

  "driver": "org.postgresql.Driver",

  "url": "jdbc:postgresql://localhost/mydb",

  "username": <username>,

  "password": <password>,

  "enabled": true

}



我可以成功查询具有主数据类型的表,但无法查询 具有复合数据类型的。 我尝试使用各种方式查询它,example .

这是我得到的异常:

Caused by: java.lang.NullPointerException: null
at
org.apache.calcite.sql2rel.RelStructuredTypeFlattener.restructureFields(RelStructuredTypeFlattener.java:201)
~[calcite-core-1.4.0-drill-r21.jar:1.4.0-drill-r21]
at
org.apache.calcite.sql2rel.RelStructuredTypeFlattener.restructure(RelStructuredTypeFlattener.java:225)
~[calcite-core-1.4.0-drill-r21.jar:1.4.0-drill-r21]
at
org.apache.calcite.sql2rel.RelStructuredTypeFlattener.restructureFields(RelStructuredTypeFlattener.java:205)
~[calcite-core-1.4.0-drill-r21.jar:1.4.0-drill-r21]
at
org.apache.calcite.sql2rel.RelStructuredTypeFlattener.rewrite(RelStructuredTypeFlattener.java:184)
~[calcite-core-1.4.0-drill-r21.jar:1.4.0-drill-r21]
at
org.apache.calcite.sql2rel.SqlToRelConverter.flattenTypes(SqlToRelConverter.java:435)
~[calcite-core-1.4.0-drill-r21.jar:1.4.0-drill-r21]
at
org.apache.drill.exec.planner.sql.SqlConverter.toRel(SqlConverter.java:270)
~[drill-java-exec-1.11.0.jar:1.11.0]
at
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.convertToRel(DefaultSqlHandler.java:638)
~[drill-java-exec-1.11.0.jar:1.11.0]
at
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.validateAndConvert(DefaultSqlHandler.java:196)
~[drill-java-exec-1.11.0.jar:1.11.0]
at
org.apache.drill.exec.planner.sql.handlers.DefaultSqlHandler.getPlan(DefaultSqlHandler.java:165)
~[drill-java-exec-1.11.0.jar:1.11.0]
at
org.apache.drill.exec.planner.sql.DrillSqlWorker.getQueryPlan(DrillSqlWorker.java:131)
~[drill-java-exec-1.11.0.jar:1.11.0]
at
org.apache.drill.exec.planner.sql.DrillSqlWorker.getPlan(DrillSqlWorker.java:79)
~[drill-java-exec-1.11.0.jar:1.11.0]
at org.apache.drill.exec.work.foreman.Foreman.runSQL(Foreman.java:1050)
[drill-java-exec-1.11.0.jar:1.11.0]
at org.apache.drill.exec.work.foreman.Foreman.run(Foreman.java:280)
[drill-java-exec-1.11.0.jar:1.11.0]

在drill中查询复合数据类型根本不可行吗? 如果我遗漏了什么,请告诉我。

谢谢

最佳答案

Apache Drill v1.11 数据类型文档:https://drill.apache.org/docs/supported-data-types/

In this release of Drill, you cannot reference a composite type by name in a query, but Drill supports array values coming from data sources.

编辑

我建议尝试 Apache Drill 社区在文档中提供的方法。这是复合类型部分的一些内容:

For example, you can use the index syntax to query data and get the value of an array element:

a[1]

You can refer to the value for a key in a map using dot notation:

t.m.k

The section “Query Complex Data” shows how to use composite types to access nested arrays. "Handling Different Data Types" includes examples of JSON maps and arrays. Drill provides functions for handling array and map types:

关于java - 通过 Apache Drill 访问 Postgres 中的复合数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46149266/

相关文章:

java - 有没有更好的方法将该字符串划分为子字符串?

apache - Apache:返回404错误而不是500错误

linux - 错误 : You must install at least one postgresql-client-<version> package

java - JSP Spring eval 是 parse int (为什么不解析 long)

java - 启动 Thread 或进行计算的 SwingWorker 时的 Swing 伪 block

java - 如何在Java中进行.MOV到3GP的转换操作

apache - Hadoop、HBase 和 Apache Nutch 兼容版本

apache - 为什么在升级到 High Sierra 时需要从我的配置文件中删除 "Listen 80"?

postgresql - 使用 LEFT JOIN 和 ON 子句时如何修复 WHEREerror

postgresql - 将当前时间的默认值设置为 Ecto 迁移中的日期时间列