apache / apache/drill

Use of catalog inside queries

Open
#2,334 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2k
Forks
990
Avg merge
1d 8h
Merged PRs (30d)
5

Description

**Is your feature request related to a problem? Please describe.**
Hello, I am developing a connector to query Drill from Dremio via JDBC and I noticed that the catalog name ("DRILL") cannot be used to fully qualify a table when querying it. E.g. the query `select * from DRILL.mypostgresdb.mytable` gives the following error:

`java.sql.SqlException: VALIDATION ERROR: Schema [[DRILL, mypostgresdb]] is not valid with respect to either root schema or default schema`

while `select * from mypostgresdb.mytable` is the valid query. By analysing the DatabaseMetaData returned when I connect to Drill, though, I see that tables are associated to a schema which is associated to a catalog, therefore I would expect to reference a table as _catalog.schema.table_. In fact when Dremio retrieves the metadata from Drill, Drill returns “DRILL” as the root of its schemas, causing Dremio to submit this back to Drill which causes the queries to fail.

**Describe the solution you'd like**
Allowing the use of catalog to qualify tables inside queries.

**Describe alternatives you've considered**
Removing the concept of catalog, as there is a unique catalog, although I am not sure of its use, so I don't know the implications.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the three-part catalog.schema.table query through Drill's JDBC path and tracing how DatabaseMetaData schemas are represented and validated. Done means DRILL.mypostgresdb.mytable resolves successfully, while the existing two-part query remains valid; also examine the implications of retaining a single catalog versus removing it.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.