I am new to Impala having come from an Oracle SQL background. I am tasked with improving an existing SQL script from a performance point of view. The existing script includes the following in the where clause
colA > 0 and colB - colA > 10
I am fairly sure that the first part, colA > 0, is just there in an effort to prevent the second part being evaluated. I am of this opinion because, in the context that this script is being run, the evaluation of colB - colA > 10 can go ahead irrespective of whether colA > 0 or not.
Can someone confirm to me that neither AND nor OR are short-circuit evaluated in Impala? I would be really surprised if they are but I cannot find a definitive answer anywhere.
Its hard to find this information in the internet, free version of chatGPT is not sure so i think that we can take a look at source code and try to find something here
Lets start from sql-scanner (Lexer in jflex): sql-scanner.flex
Here you can see that in Impala you can't use "&", the second thing is that "and" and "&&" are resolved to the same key word - KW_AND
It suggests that only short-circuit "and" is used in Impala but lets dig deeper
In sql parser i found this: sql-parser
Which shows that KW_AND with its operands is translated to CompoundPredicate(CompoundPredicate.Operator.AND, e1, e2)
In this file i found this: AndPredicate
Which probably confirms that it is short-circuit but i think that you should treat my finding with causion.
You can try to dig dipper if you want to see more, i think that my answer is good starting point :)