Sessionization in SQL, Hive, Pig and Python