wnob commented on code in PR #2973:
URL: https://github.com/apache/calcite/pull/2973#discussion_r1025778875
##########
babel/src/main/codegen/includes/parserImpls.ftl:
##########
@@ -42,6 +42,26 @@ SqlNode DateFunctionCall() :
}
}
+SqlNode TimestampFunctionCall() :
Review Comment:
Here's my understanding: Babel is the "universal" parser ¹ that does not
understand the semantics of individual dialects (hence the name).
Dialect-specific semantic validation is a separate step that occurs after
dialect-agnostic parsing.
This is a [FreeMarker template file][1]. It does not contain any
interpolation or tags, so running this through FreeMarker would simply remove
the license comment at the top of the file. It's processed by [FMPP][2] in
`config.fmpp` [here][3], which is in-turn referenced in the [JavaCC][4] grammar
[here][5], as well as [here][6] via the `builtinFunctionCallMethods` list where
the function name was added above in `config.fmpp`.
Together, these 2 additions to the grammar indicate that there is a
*production* called `TimestampFunctionCall` which consists of the
[`<TIMESTAMP>` token][7] followed by a [`FunctionParameterList`][8] production,
which consists of left-parenthesis, comma-separated arguments,
right-parenthesis. The parser does nothing to validate how many arguments there
are or what types they are.
So yes, long story short, you're right that we didn't have to modify the
`DateFunctionCall` production because it's just a function call either way, and
I just added this new production with a different name token but which is
otherwise identical to the `DATE` one.
¹ I've heard Julian make reference to other parsers being potentially usable
with Calcite but I don't know of any examples.
[1]: https://freemarker.apache.org/docs/dgui_template_overallstructure.html
[2]: https://fmpp.sourceforge.net/index.html
[3]:
https://github.com/apache/calcite/blob/a505b25eacc473c6ec0ef8abd40c1ccae86297b6/babel/src/main/codegen/config.fmpp#L566
[4]: https://javacc.github.io/javacc/
[5]:
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L1163
[6]:
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L5992
[7]:
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L7922
[8]:
https://github.com/apache/calcite/blob/a0e119ea42def418957f214f539469f1aba76c18/core/src/main/codegen/templates/Parser.jj#L948
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]