I have a subquery and I want to return some default value if subquery if empty. I.e. I need something like
coalesce((select top 1 Id from ...),0)
The problem is that in Hive subqueries are only supported in FROM clause and such code returns me compile error. I am not sure about Spark.
Is there any way to implement such simple logic so that it works in both Hive and Spark SQL?