Updated sql function in delta