Add Teradata FORMAT Clause Parsing#5348
Conversation
Support Teradata FORMAT column syntax Add Teradata format tests Add comments and docs for Teradata FORMAT column Modified Comments
|
Can't figure out why this is failing - running |
|
Perhaps try nuking & recreating your venv, |
georgesittas
left a comment
There was a problem hiding this comment.
Thanks for the PR! Can you test a few more things? E.g., do things like this work?
SELECT ('a' || 'b') (FORMAT '...')Basically, see if a complex expression before (FORMAT ...) is valid syntax.
| arg_types = {"this": True, "zone": True} | ||
|
|
||
|
|
||
| class FormatColumn(Expression): |
There was a problem hiding this comment.
Nit: let's rename this to FormatPhrase. This applies to other things besides columns, right? E.g.:
-- (FORMAT ...) is applied to a SUM expression here
SELECT SUM(Salary) (FORMAT '$$99,999.99') FROM Employee;| if self._match(TokenType.L_PAREN, advance=False): | ||
| index = self._index | ||
| self._match(TokenType.L_PAREN) | ||
| if self._match(TokenType.FORMAT): |
There was a problem hiding this comment.
| if self._match(TokenType.L_PAREN, advance=False): | |
| index = self._index | |
| self._match(TokenType.L_PAREN) | |
| if self._match(TokenType.FORMAT): | |
| if self._match_pair(TokenType.L_PAREN, TokenType.FORMAT): |
|
I'll take this to the finish line, seems like a small lift. Thanks for the PR! |
|
Thanks for picking this up and closing out! Will look to continue contributing in the future |
feat(teradata): parse column format syntax
Support Teradata FORMAT column syntax
_parse_functionclass in the Teradata dialect to add support for this, and adds a new FormatColumn expressionformatcolumn_sqlmethod tosqlglot/expressions.pyto recreate the columnMy original Issue: #5325
Link to Associated Teradata Documentation