IF is reserved in Hive: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL
Julian > On Jun 27, 2016, at 06:30, Vitalii Diravka <[email protected]> wrote: > > Thank's Julian > > This isn't drill UDF, this is hive UDF. Dril can use hive UDF while query > hive tables. That's why most likely I can't use IIF as UDF name. > Can I make changes in calcite parser in next manner: by default IF - > reserved word but in case when IF appears after TABLE or VIEW - recognize > IF as function name? > Also I found that hive uses SQL2011 and IF is a non-reserved word there. > > Kind regards > Vitalii > > 2016-06-17 16:35 GMT+00:00 Julian Hyde <[email protected]>: > >> Ah, you're right. It's reserved in 2011. However, I'm looking at a >> draft of 2014 and it's gone. >> >> Calcite attempts to follow the latest version of the standard, but we >> don't do so slavishly. People want something that complies with all >> versions of the standard (at least in the features that they care >> about). >> >> Given that 4 versions of the SQL standard treat "IF" as a reserved >> word, I think it would be foolish to create a function called "IF". >> Most databases that have such a function call it "IIF". Could you use >> that instead? >> >> On Fri, Jun 17, 2016 at 5:25 AM, Vitalii Diravka >> <[email protected]> wrote: >>> Adding "IF" to a non-reserved keywords list can resolve that issue. >>> >>> But I saw that in Parser.jj SQL:2003 is used. Also I found "IF" keyword >> as >>> a reserved word in ISO/IEC 9075-4 (Fourth edition 2011-12-15). >>> >>> So what standard actually calcite uses? Can we add anyway "IF" to the >>> non-reserved keywords list? >>> >>> >>> Kind regards >>> Vitalii >>> >>> 2016-06-15 18:07 GMT+00:00 Julian Hyde <[email protected]>: >>> >>>> There are two kinds of keywords: reserved and non-reserved. A >> non-reserved >>>> keyword can be used as a keyword in the right context, and as an >>>> identifier elsewhere. >>>> >>>> IF was reserved in SQL:92, SQL:99, SQL:2003 but is no longer reserved in >>>> SQL:2011 (see table in SqlParserTest). So you could add it to Calcite >> as a >>>> non-reserved keyword. >>>> >>>> >>>>> On Jun 15, 2016, at 8:11 AM, Vitalii Diravka < >> [email protected]> >>>> wrote: >>>>> >>>>> Hi all! >>>>> >>>>> I need to add a new keyword "IF" for sql parser. >>>>> How can I use one keyword for two purposes: as a part of "IF EXISTS" >>>>> statement and as a function name? >>>>> >>>>> Actually I added "IF" as a new keyword in FMPP configuration file >> which >>>>> allows to extend Calcite's SQL parser. >>>>> After this "IF" isn't considered as an IDENTIFIER and function name. >>>>> >>>>> >>>>> >>>>> Kind regards >>>>> Vitalii >>
