[ https://issues.apache.org/jira/browse/CALCITE-3987?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17108806#comment-17108806 ]
Danny Chen commented on CALCITE-3987: ------------------------------------- I thought of 2 ways to solve the problem: 1. Extend the parser.jj to pass around the sql conformance into the PLUS operator so that we can tweak the operands type inference based on that. 2. Extend the implicit type coercion in TypeCoercionImpl.java to convert the NUMERIC in "DATE + NUMERIC" into an interval Option 2 seems more natural from my side. It is not easy to override a basic builtin operator from the parser, although we have many for that (e.g. all the JSON functions). The most ideal way is to not hard code the operators in parser(all unresolved), we resolve the operators only during the SqlValidator validation. > Allow addition and subtraction operations between DATE and NUMERIC types. > ------------------------------------------------------------------------- > > Key: CALCITE-3987 > URL: https://issues.apache.org/jira/browse/CALCITE-3987 > Project: Calcite > Issue Type: Improvement > Reporter: Drew Schmitt > Priority: Minor > > We should allow addition (PLUS operator) and subtraction (MINUS operator) > between DATE and NUMERIC types to be valid during the validation phase. > Downstream, the result of the operation can be interpreted differently > depending on the dialect. For example, some dialects would interpret any > arithmetic with a DATE as implying adding/subtracting a number of days. > Example query: > CREATE TABLE foo (bar DATE); > SELECT bar - 1 FROM foo; -- This message was sent by Atlassian Jira (v8.3.4#803005)