Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Apache Drill Dialect to SqlGlot #707

Merged
merged 6 commits into from
Nov 15, 2022
Merged

Conversation

cgivre
Copy link
Contributor

@cgivre cgivre commented Nov 15, 2022

This PR adds a dialect for Apache Drill to SQLGlot.

Remaining work:

  • Add support for Drill table() function
  • Add unit tests for table() function.

ESCAPES = ["\\"]
ENCODE = "utf-8"

KEYWORDS = {**tokens.Tokenizer.KEYWORDS, "VARBINARY": TokenType.BINARY}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you add varbinary? that's already a type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed. Drill doesn't have a BINARY data type, just a VARBINARY, so that's what I was trying to do here, but I think that is covered elsewhere.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then it should instead be in the generator binary mapping to varbinary, look at what presto does

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha.... and it's already there. 👍

exp.DataType.Type.SMALLINT: "INTEGER",
exp.DataType.Type.TINYINT: "INTEGER",
exp.DataType.Type.BINARY: "VARBINARY",
exp.DataType.Type.TEXT: "VARCHAR",

@tobymao
Copy link
Owner

tobymao commented Nov 15, 2022

this is a pretty good start, why don't we get this merged in and then fix the xlsx table afterwards?

@cgivre
Copy link
Contributor Author

cgivre commented Nov 15, 2022

this is a pretty good start, why don't we get this merged in and then fix the xlsx table afterwards?

@tobymao I'd defer to you on that. Drill's SQL dialect follows ANSI 2003 pretty closely, so I don't anticipate there's much more do to. I'm happy to proceed if that's what you think is best. Going to sleep now, but tomorrow, I'll remove the unit test for the table() function.

@tobymao
Copy link
Owner

tobymao commented Nov 15, 2022

ok yea, let's just get this merged. it's nice and clean. the table function is going to be much harder

@cgivre cgivre marked this pull request as ready for review November 15, 2022 12:32
@cgivre cgivre changed the title Add Drill Dialect to SqlGlot Add Apache Drill Dialect to SqlGlot Nov 15, 2022
@tobymao tobymao merged commit 543eca3 into tobymao:main Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants