Search code examples
sqlapache-sparkpysparkapache-spark-sqlhql

Meaning of ascii(my_field) & 8 <> 8 condition in SQL request


I'm working on a SQL script that contains this condition :

select *
from my_table
where ascii(my_field) & 8 <> 8;

What does it mean?

I would like to implement this request on a PySpark script but if I don't understand the meaning of this condition it will be hard to do it.

PS: the SQL script is a .hql

Thank you all :)


Solution

  • it mean where the ascii code of the value is not 8 (backspace)

    <> is like x > y || x < y that equals to x!=y. (<> mean not equal of numbers)

    & it is 'AND' operation on the bit of the value (8&8=8).

    This sql is equal to:

    SELECT * FROM my_table where my_field != ' '